Skip to content

Commit 67dab6f

Browse files
tZimmermann98arunkannawadi
authored andcommitted
Update publication_parser.py
for arrow errors, fallback to regex year extraction
1 parent c19c99b commit 67dab6f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

scholarly/publication_parser.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,11 @@ def fill(self, publication: Publication)->Publication:
312312
'YYYY/M/DD',
313313
'YYYY/M/D',
314314
'YYYY/MM/D']
315-
publication['bib']['pub_year'] = arrow.get(val.text, patterns).year
315+
try:
316+
publication['bib']['pub_year'] = arrow.get(val.text, patterns).year
317+
except ValueError:
318+
# fallback to regex year extraction if arrow fails
319+
publication['bib']['pub_year'] = re.search(r'\d{4}', val.text).group()
316320
publication['bib']['pub_date'] = val.text
317321
elif key == 'description':
318322
# try to find all the gsh_csp if they exist

0 commit comments

Comments
 (0)