commit e3d7c625d32a498a45b5ca4e429065414e2f62e8
parent f8fdfc41ded8f7764d177c71a770fac487af34a2
Author: Antoine Amarilli <a3nm@a3nm.net>
Date: Tue, 18 Jan 2022 21:00:56 +0100
fix try/except silliness
Diffstat:
adddoi | | | 47 | ++++++++++++++++++++++------------------------- |
1 file changed, 22 insertions(+), 25 deletions(-)
diff --git a/adddoi b/adddoi
@@ -98,31 +98,28 @@ if __name__ == '__main__':
total = len(bibliography.entries)
for i,entry in enumerate(bibliography.entries):
print("\r{i}/{total} entries processed, please wait...".format(i=i,total=total),flush=True,end="")
- try:
- if "doi" not in entry or entry["doi"].isspace():
- title = normalize(entry["title"])
- authors = get_authors(entry)
- for author in authors:
- doi_match = searchdoi(title,author)
- if doi_match:
- doi = doi_match.groups()[0]
- entry["doi"] = doi
- new += 1
- break
- else:
- before += 1
- if "url" not in entry or entry["url"].isspace():
- if 'doi' in entry.keys():
- doi = entry["doi"]
- if not doi.isspace():
- url_match = searchurl(doi)
- if url_match:
- entry["url"] = url
- new_url += 1
- else:
- before_url += 1
- except:
- pass
+ if "doi" not in entry or entry["doi"].isspace():
+ title = normalize(entry["title"])
+ authors = get_authors(entry)
+ for author in authors:
+ doi_match = searchdoi(title,author)
+ if doi_match:
+ doi = doi_match.groups()[0]
+ entry["doi"] = doi
+ new += 1
+ break
+ else:
+ before += 1
+ if "url" not in entry or entry["url"].isspace():
+ if 'doi' in entry.keys():
+ doi = entry["doi"]
+ if not doi.isspace():
+ url_match = searchurl(doi)
+ if url_match:
+ entry["url"] = url_match
+ new_url += 1
+ else:
+ before_url += 1
print("")
template="We added {new} DOIs and {new_url} URLs !\n"