From 339f8058528d9def6f554b829d8a1ae1911c9589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Cl=C3=A9rice?= Date: Mon, 17 Jul 2023 09:43:59 +0200 Subject: [PATCH] Fix Github behaviour change regarding straight URI request call (now returning JSON, returned HTML before) --- htruc/catalog.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htruc/catalog.py b/htruc/catalog.py index 1f9e304..7fc5743 100644 --- a/htruc/catalog.py +++ b/htruc/catalog.py @@ -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: @@ -271,6 +271,8 @@ def _get_github_citation_file(catalog_record: CatalogRecord, access_token: Optio citation_file_content = req.text if "" 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"]: @@ -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: