Skip to content

Commit 611f969

Browse files
committed
Better handling of publication section
1 parent d695138 commit 611f969

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

caltechdata_api/decustomize_schema.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,17 @@ def decustomize_schema(json_record,pass_emails=False):
3838
#Publication is effectivly a related identifier
3939
if "publications" in json_record:
4040
if 'publicationIDs' in json_record['publications']:
41-
relation = {"relatedIdentifier":
42-
json_record['publications']['publicationIDs']['publicationIDNumber'],
41+
doi = json_record['publications']['publicationIDs']['publicationIDNumber']
42+
relation = {"relatedIdentifier":doi,
4343
"relatedIdentifierType": "DOI",
4444
"relationType": "IsSupplementTo"}
4545
if 'relatedIdentifiers' in json_record:
46-
json_record['relatedIdentifiers'].append(relation)
46+
existing = False
47+
for rec in json_record['relatedIdentifiers']:
48+
if doi == rec['relatedIdentifier']:
49+
existing = True
50+
if existing == False:
51+
json_record['relatedIdentifiers'].append(relation)
4752
else:
4853
json_record['relatedIdentifiers'] = [relation]
4954
del json_record['publications']

0 commit comments

Comments
 (0)