Skip to content

Commit d83d682

Browse files
committed
Affiliation handling
1 parent 5d01f3a commit d83d682

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

caltechdata_api/decustomize_schema.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ def decustomize_schema(json_record):
5656
for a in authors:
5757
new = {}
5858
if 'authorAffiliation' in a:
59-
new['affiliations'] = a['authorAffiliation']
59+
if isinstance(c['contributorAffiliation'],list):
60+
new['affiliations'] = a['authorAffiliation']
61+
else:
62+
new['affiliations'] = [a['authorAffiliation']]
6063
if 'authorIdentifiers' in a:
6164
idv = []
6265
for cid in a['authorIdentifiers']:
@@ -77,7 +80,10 @@ def decustomize_schema(json_record):
7780
if "contributors" in json_record:
7881
for c in json_record['contributors']:
7982
if 'contributorAffiliation' in c:
80-
c['affiliations'] = c.pop('contributorAffiliation')
83+
if isinstance(c['contributorAffiliation'],list):
84+
c['affiliations'] = c.pop('contributorAffiliation')
85+
else:
86+
c['affiliations'] = [c.pop('contributorAffiliation')]
8187
if 'contributorIdentifiers' in c:
8288
#if isinstance(c['contributorIdentifiers'],list):
8389
newa = []

0 commit comments

Comments
 (0)