Skip to content

Commit

Permalink
try/exept in getting publication info
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhsmit committed Sep 28, 2023
1 parent 4ad4a6f commit b055f04
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pyhdx/web/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,12 +854,15 @@ def _action_load_datasets(self) -> None:
publications = dataset.metadata.get("publications", [])
if publications:
for pub in publications:
pub_str = pub["title"]
if "DOI" in pub:
pub_str += f' ([{pub["DOI"]}](https://doi.org/{pub["DOI"]}))'
elif "URL" in pub:
pub_str += f' ([URL]({pub["URL"]}))'
self.parent.logger.info("Publication: " + pub_str)
try:
pub_str = pub["title"]
if "DOI" in pub:
pub_str += f' ([{pub["DOI"]}](https://doi.org/{pub["DOI"]}))'
elif "URL" in pub:
pub_str += f' ([URL]({pub["URL"]}))'
self.parent.logger.info("Publication: " + pub_str)
except (KeyError, TypeError):
pass
else:
raise ValueError("Invalid input mode")

Expand Down

0 comments on commit b055f04

Please sign in to comment.