Skip to content

Commit

Permalink
add exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
shigapov committed Jun 26, 2023
1 parent 7939c8d commit 2cd7182
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions madata/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def _sync(self):

for index, row in tqdm(self.OAI_DC_df.iterrows()):
MADATA_URL, DOI = row.relation
if DOI not in list(self.QID_DOI_URL.DOI):
if MADATA_URL not in list(self.QID_DOI_URL.URL):
creators = [self.reorder(c).strip() for c in row.creator]
data = [wdi_core.WDItemID('Q1172284', prop_nr='P31'), # instance of dataset
wdi_core.WDMonolingualText(row.title[0].strip(), prop_nr='P1476')] # title
Expand Down Expand Up @@ -181,10 +181,13 @@ def _sync(self):
if row.get('ubma_url_external'):
for URLext in row.get('ubma_url_external'):
data.append(wdi_core.WDUrl(URLext, prop_nr='P973')) # described at
wd_item = wdi_core.WDItemEngine(data=data)
wd_item.set_label(label=row.title[0].strip()) # set label
if row.get('ubma_additional_title'):
wd_item.set_description(description=row.ubma_additional_title[0].strip()) # set description
wd_item.write(login, bot_account=False)
try:
wd_item = wdi_core.WDItemEngine(data=data)
wd_item.set_label(label=row.title[0].strip()) # set label
if row.get('ubma_additional_title'):
wd_item.set_description(description=row.ubma_additional_title[0].strip()) # set description
wd_item.write(login, bot_account=False)
except Exception as e:
print(e)
else:
print('DOI: ' + DOI + ' is already at Wikidata.')
print('DOI: ' + DOI + ' is already at Wikidata for the MADATA record at: ' + MADATA_URL)

0 comments on commit 2cd7182

Please sign in to comment.