Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parsers: relax JATS parser date handling #222

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions hepcrawl/parsers/jats.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def parse(self):
self.builder.add_doi(**doi)
for keyword in self.keywords:
self.builder.add_keyword(**keyword)
self.builder.add_imprint_date(self.publication_date.dumps())
if self.publication_date:
self.builder.add_imprint_date(self.publication_date.dumps())
for reference in self.references:
self.builder.add_reference(reference)

Expand Down Expand Up @@ -284,11 +285,10 @@ def publication_date(self):
'./front//pub-date[starts-with(@date-type,"pub")] |'
'./front//date[starts-with(@date-type,"pub")]'
)
publication_date = min(
self.get_date(date_node) for date_node in date_nodes
)

return publication_date
if date_nodes:
return min(
self.get_date(date_node) for date_node in date_nodes
)

@property
def publication_info(self):
Expand Down Expand Up @@ -366,11 +366,10 @@ def year(self):
not_online=not_online
)

year = min(
self.get_date(date_node) for date_node in date_nodes
).year

return year
if date_nodes:
return min(
self.get_date(date_node) for date_node in date_nodes
).year

def get_author_affiliations(self, author_node):
"""Extract an author's affiliations."""
Expand Down