Skip to content

Commit

Permalink
Fix Github behaviour change regarding straight URI request call (now …
Browse files Browse the repository at this point in the history
…returning JSON, returned HTML before)
  • Loading branch information
PonteIneptique committed Jul 17, 2023
1 parent 2ee6262 commit 339f805
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions htruc/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def get_all_catalogs(
if up:
logger.info(f"Successfully retrieved Bibtex or/and APA for {key}")
data[key].update(up)
return data
return dict(sorted(data.items()))


def get_statistics(repositories: Catalog) -> pandas.DataFrame:
Expand Down Expand Up @@ -271,6 +271,8 @@ def _get_github_citation_file(catalog_record: CatalogRecord, access_token: Optio
citation_file_content = req.text
if "</html>" in citation_file_content.lower():
raise Exception("CFF File link is wrong, it returns HTML.")
elif citation_file_content[0] == "{":
raise Exception("Got JSON at the given endpoint instead of YAML")
except Exception as E:
logger.error(f"Error retrieving CITATION File for {catalog_record['citation-file-link']}: {str(E)}")
if "github.com" in catalog_record["url"]:
Expand All @@ -283,7 +285,7 @@ def _get_github_citation_file(catalog_record: CatalogRecord, access_token: Optio
except Exception as E:
logger.error(f"Unable to parse CFF for {catalog_record['url']} ({E})")
nl = "\n"
logger.error(f"Content: \n{citation_file_content.replace(nl, nl+'>>> ')}")
logger.error(f"Content: \n>>> {citation_file_content.replace(nl, nl+'>>> ')}")
return {}
return_obj = {}
try:
Expand Down

0 comments on commit 339f805

Please sign in to comment.