Skip to content

Commit 34fbe51

Browse files
Make parsing more robust (close #428, close #429)
1 parent 2bb376a commit 34fbe51

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

pybliometrics/scopus/abstract_retrieval.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ def isbn(self) -> tuple[str, ...] | None:
450450
if len(isbns) == 0:
451451
return None
452452
else:
453-
return tuple((i['$'] for i in isbns))
453+
return tuple(i['$'] if isinstance(i, dict) else str(i) for i in isbns)
454454

455455
@property
456456
def issn(self) -> ISSN | None:
@@ -839,7 +839,7 @@ def __init__(self,
839839
self._json = self._json['abstracts-retrieval-response']
840840
self._head = chained_get(self._json, ["item", "bibrecord", "head"], {})
841841
conf_path = ['source', 'additional-srcinfo', 'conferenceinfo', 'confevent']
842-
self._confevent = chained_get(self._head, conf_path, {})
842+
self._confevent = chained_get(self._head, conf_path, {}) or {}
843843
if self._view == "REF":
844844
ref_path = ["references"]
845845
else:

pybliometrics/scopus/tests/test_AbstractRetrieval.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
ab12 = AbstractRetrieval('2-s2.0-85044008512', view='FULL', refresh=30)
3535
# List of contributors in contributor group
3636
ab13 = AbstractRetrieval("2-s2.0-85038825012", view="FULL", refresh=30)
37+
# None in confcode
38+
ab14 = AbstractRetrieval("2-s2.0-79960092540", view="FULL", refresh=30)
39+
# Single isbn
40+
ab15 = AbstractRetrieval("2-s2.0-14544289566", view="FULL", refresh=30)
3741

3842

3943
def test_abstract():
@@ -129,6 +133,7 @@ def test_chemials():
129133
def test_confcode():
130134
assert ab2.confcode == 44367
131135
assert ab8.confcode is None
136+
assert ab14.confcode is None
132137

133138

134139
def test_confdate():
@@ -320,6 +325,7 @@ def test_isbn():
320325
assert ab3.isbn is None
321326
assert ab5.isbn == ('0203881486', '9780203881484')
322327
assert ab8.isbn is None
328+
assert ab15.isbn == ('0780385969',)
323329

324330

325331
def test_issn():

0 commit comments

Comments
 (0)