Skip to content

Commit 8657035

Browse files
Make author affiliation parsing more generic
1 parent fc7ed90 commit 8657035

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

pybliometrics/scopus/author_retrieval.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def affiliation_current(self) -> Optional[List[NamedTuple]]:
2929
affs = self._json.get('affiliation-current')
3030
else:
3131
return None
32-
return parse_affiliation(affs, self._view)
32+
return parse_affiliation(affs or {}, self._view)
3333

3434
@property
3535
def affiliation_history(self) -> Optional[List[NamedTuple]]:
@@ -44,11 +44,8 @@ def affiliation_history(self) -> Optional[List[NamedTuple]]:
4444
Note: Unlike on their website, Scopus doesn't provide the periods
4545
of affiliation.
4646
"""
47-
if self._view in ('STANDARD', 'ENHANCED'):
48-
affs = chained_get(self._profile, ["affiliation-history", "affiliation"])
49-
else:
50-
return None
51-
return parse_affiliation(affs, self._view)
47+
affs = chained_get(self._profile, ["affiliation-history", "affiliation"])
48+
return parse_affiliation(affs or {}, self._view)
5249

5350
@property
5451
def alias(self) -> Optional[List[str]]:
@@ -71,8 +68,8 @@ def cited_by_count(self) -> int:
7168
def classificationgroup(self) -> Optional[List[Tuple[int, int]]]:
7269
"""List with tuples with form`(subject group ID, number of documents)`."""
7370
path = ['classificationgroup', 'classifications', 'classification']
74-
out = [(int(filter_digits(item['$'])), int(filter_digits(item['@frequency']))) for item in
75-
listify(chained_get(self._profile, path, []))]
71+
out = [(int(filter_digits(item['$'])), int(filter_digits(item['@frequency'])))
72+
for item in listify(chained_get(self._profile, path, []))]
7673
return out or None
7774

7875
@property

pybliometrics/scopus/utils/parse_content.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,14 @@ def parse_affiliation(affs, view):
167167
address_part=address.get("address-part"), city=address.get('city'),
168168
postal_code=address.get('postal-code'), state=address.get('state'),
169169
org_domain=doc.get('org-domain'), org_URL=doc.get('org-URL'))
170-
out.append(new)
170+
if any(val for val in new):
171+
out.append(new)
171172
elif view == 'LIGHT':
172173
new = aff(preferred_name=affs.get('affiliation-name'),
173174
city=affs.get('affiliation-city'),
174175
country=affs.get('affiliation-country'))
175-
out.append(new)
176+
if any(val for val in new):
177+
out.append(new)
176178

177179
return out or None
178180

0 commit comments

Comments
 (0)