Skip to content

Commit db06043

Browse files
tZimmermann98arunkannawadi
authored andcommitted
fallback to regex year extraction or empty String when arrow fails
1 parent 67dab6f commit db06043

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

scholarly/publication_parser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,8 @@ def fill(self, publication: Publication)->Publication:
316316
publication['bib']['pub_year'] = arrow.get(val.text, patterns).year
317317
except ValueError:
318318
# fallback to regex year extraction if arrow fails
319-
publication['bib']['pub_year'] = re.search(r'\d{4}', val.text).group()
319+
match = re.search(r'\d{4}', val.text)
320+
publication['bib']['pub_year'] = match.group() if match else ""
320321
publication['bib']['pub_date'] = val.text
321322
elif key == 'description':
322323
# try to find all the gsh_csp if they exist

0 commit comments

Comments
 (0)