From 3f77708f83548f8a39ebb7a840d4f1009c363f4a Mon Sep 17 00:00:00 2001 From: shadrach-tayo Date: Fri, 28 Jun 2024 07:23:57 +0200 Subject: [PATCH] better error handling --- .DS_Store | Bin 8196 -> 8196 bytes app/langchain_orcid2.py | 16 ++++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.DS_Store b/.DS_Store index 7dbadd93f59b8852ec697ed35450f98d88dd0eff..bb3816e49be4ee5aa21e1fd5a4ec0bd1526208a6 100755 GIT binary patch delta 42 ycmZp1XmOa}&nUeyU^hRb^kyCbZpO{i1=W}*w}~2V&f}TMyqR6%JIlsQHf8`BybR(1 delta 489 zcmZp1XmOa}aFU^hRb>Si7RZpM0620ex{hE#?;hO(S=!{Frn+yVw5P@LQ(3Z#%^ zbMswXl5+BsfTA3sZS!Jo-Z<)rt|Eniih>M;4XWM>K<%5w1l5`A*%=%eiWrg^G8i&J zj!7v_&PmG8&jHFaph+RSk>Ps$Y)lo%?yPfIv1fiU*qvzRJ?p(m) qpvih74jWSgm^QOZd}pag@&p;~puibr!9{sF`IAjVtTv|lG64WvlX~3% diff --git a/app/langchain_orcid2.py b/app/langchain_orcid2.py index fc8d395..8ad5e97 100644 --- a/app/langchain_orcid2.py +++ b/app/langchain_orcid2.py @@ -201,7 +201,10 @@ def published_metadata(doi, cremail, pyalexemail): authors_info = [] for author in r['message']['author']: - full_name = author['given'] + ' ' + author['family'] + if 'given' in author: + full_name = author['given'] + ' ' + author['family'] + else: + full_name = author['name'] authors_info.append(full_name) if authors_info: @@ -211,11 +214,12 @@ def published_metadata(doi, cremail, pyalexemail): refs = [] - for i in r['message']['reference']: - try: - refs.append(i['DOI']) - except: - refs.append(f"{i['key']}, DOI not present") + if 'reference' in r['message']: + for i in r['message']['reference']: + try: + refs.append(i['DOI']) + except: + refs.append(f"{i['key']}, DOI not present") url_link = r['message']['URL']