Skip to content

Commit

Permalink
wts2-1127/fl2-225/LitTriage/EUtils issue
Browse files Browse the repository at this point in the history
  • Loading branch information
leemdi committed Feb 22, 2023
1 parent 89f60e7 commit e89edb2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
6 changes: 6 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
TAG: lib_py_littriage-6-0-22-11
DATE: 02/22/2023
STAFF: lec
wts2-1127/fl2-225/LitTriage/EUtils issue
PubMedAgent.py/getPubMedIDs(); re-organize try/except

TAG: lib_py_littriage-6-0-22-10
TAG: lib_py_littriage-6-0-22-9
DATE: 12/14/2022, 12/15/2022
Expand Down
24 changes: 12 additions & 12 deletions PubMedAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ def getPubMedIDs (self, doiList):
# then that one maps to None.
# Throws: Exception if the URL returns an error
mapping = {} # {doiid: [pubMedId(s)], ...}
try:
#print '### Getting PubMed IDs ###\n'
for doiID in doiList:
for doiID in doiList:
try:
#print('### Getting PubMed IDs for (%s) ###\n' % (doiID))
forUrl = doiID
forUrl = doiID.replace('(', '*')
forUrl = doiID.replace(')', '*')
Expand All @@ -207,15 +207,15 @@ def getPubMedIDs (self, doiList):
else:
for pmID in pubmedIDs:
mapping[doiID].append(pmID.firstChild.data)
except IOError as e:
if hasattr(e, 'code'): # HTTPError
print('HTTP error code: ', e.code)
raise Exception('HTTP error code: %s' % e.code)
elif hasattr(e, 'reason'): # URLError
print("Can't connect, reason: ", e.reason)
raise Exception("Can't connect, reason: %s" % e.reason)
else:
raise Exception('Unknown exception: %s' % e)
except IOError as e:
if hasattr(e, 'code'): # HTTPError
print('HTTP error code: ', e.code)
raise Exception('HTTP error code: %s' % e.code)
elif hasattr(e, 'reason'): # URLError
print("Can't connect, reason: ", e.reason)
raise Exception("Can't connect, reason: %s" % e.reason)
else:
raise Exception('Unknown exception: %s' % e)

return mapping

Expand Down

0 comments on commit e89edb2

Please sign in to comment.