From 38595f8bb3985642136771d10d7ace5becb76638 Mon Sep 17 00:00:00 2001 From: shirazos7 Date: Tue, 14 Jan 2025 12:50:47 +0100 Subject: [PATCH 1/7] adding the list of year_references --- src/zbmath_rest2oai/getAsXml.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/zbmath_rest2oai/getAsXml.py b/src/zbmath_rest2oai/getAsXml.py index 21148790..7e75e14b 100644 --- a/src/zbmath_rest2oai/getAsXml.py +++ b/src/zbmath_rest2oai/getAsXml.py @@ -77,6 +77,7 @@ def extract_tags(result): def add_references_to_software(api_uri, dict_res): list_articles_ids_to_soft = [] list_articles_ids_and_alter_ids_to_soft = [] + list_references_year_alt = [] if "software" in api_uri: if api_uri.startswith("https://api.zbmath.org/v1/software/_all?start_after=")==False: soft_id=api_uri.split("/")[-1] @@ -101,6 +102,10 @@ def api_doc_endpoint(page): list_ids_and_alter.append(";".join([str(entry["id"])]+list_links)) + if "datestamp" in entry: + year = entry["datestamp"][:4] # Extract the first 4 characters (year) + list_references_year_alt.append(year) + list_articles_ids_to_soft.extend(list_ids) list_articles_ids_and_alter_ids_to_soft.extend(list_ids_and_alter) @@ -110,6 +115,7 @@ def api_doc_endpoint(page): dict_res["references"] = list_articles_ids_to_soft # Wrap it in a list to make it iterable for your existing loop dict_res["references_alt"] = list_articles_ids_and_alter_ids_to_soft + dict_res["references_year_alt"] = list_references_year_alt dict_res = [dict_res] return dict_res From e0e596581f5a7a8c8f54d7c64e27de50b340aa4e Mon Sep 17 00:00:00 2001 From: shirazos7 Date: Tue, 14 Jan 2025 12:51:26 +0100 Subject: [PATCH 2/7] adding the years of references to plain --- test/data/software/plain_with_references.xml | 111 +++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/test/data/software/plain_with_references.xml b/test/data/software/plain_with_references.xml index df1ff406..0964d626 100644 --- a/test/data/software/plain_with_references.xml +++ b/test/data/software/plain_with_references.xml @@ -250,6 +250,117 @@ 6666873;10.1016/j.jcp.2016.06.039 5538352;10.1007/978-3-540-71992-2_17 2234457 + 2005 + 2012 + 2009 + 2007 + 2023 + 2018 + 2007 + 2024 + 2008 + 2008 + 2005 + 2015 + 2015 + 2021 + 2008 + 2011 + 2010 + 2011 + 2007 + 2007 + 2008 + 2008 + 2017 + 2010 + 2019 + 2010 + 2019 + 2023 + 2007 + 2016 + 2011 + 2010 + 2013 + 2016 + 2017 + 2024 + 2019 + 2019 + 2023 + 2011 + 2008 + 2016 + 2023 + 2011 + 2010 + 2009 + 2019 + 2016 + 2015 + 2019 + 2018 + 2014 + 2019 + 2015 + 2018 + 2015 + 2014 + 2013 + 2007 + 2012 + 2021 + 2021 + 2020 + 2010 + 2022 + 2008 + 2007 + 2018 + 2014 + 2009 + 2007 + 2023 + 2011 + 2018 + 2011 + 2010 + 2024 + 2022 + 2010 + 2010 + 2021 + 2010 + 2022 + 2022 + 2022 + 2023 + 2011 + 2021 + 2021 + 2024 + 2014 + 2024 + 2022 + 2010 + 2020 + 2023 + 2016 + 2011 + 2020 + 2020 + 2019 + 2020 + 2024 + 2018 + 2021 + 2016 + 2024 + 2018 + 2016 + 2009 + 2005 4013 MUMPS From ee9e4f87f4cfd9b89594a05e3942444e3da9f84b Mon Sep 17 00:00:00 2001 From: shirazos7 Date: Tue, 14 Jan 2025 12:55:34 +0100 Subject: [PATCH 3/7] removing unwanted comment --- src/zbmath_rest2oai/getAsXml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zbmath_rest2oai/getAsXml.py b/src/zbmath_rest2oai/getAsXml.py index 7e75e14b..a64854d6 100644 --- a/src/zbmath_rest2oai/getAsXml.py +++ b/src/zbmath_rest2oai/getAsXml.py @@ -103,7 +103,7 @@ def api_doc_endpoint(page): list_ids_and_alter.append(";".join([str(entry["id"])]+list_links)) if "datestamp" in entry: - year = entry["datestamp"][:4] # Extract the first 4 characters (year) + year = entry["datestamp"][:4] list_references_year_alt.append(year) list_articles_ids_to_soft.extend(list_ids) From 935d0b6c35b3baa99deb96a33dd6f6efd3420f63 Mon Sep 17 00:00:00 2001 From: Mazztok45 Date: Tue, 14 Jan 2025 14:30:25 +0100 Subject: [PATCH 4/7] renaming the apply_zbmath_api_fixes prefix parameter to fix the issues pointed out by deepsource --- src/zbmath_rest2oai/getAsXml.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zbmath_rest2oai/getAsXml.py b/src/zbmath_rest2oai/getAsXml.py index a64854d6..9c483f79 100644 --- a/src/zbmath_rest2oai/getAsXml.py +++ b/src/zbmath_rest2oai/getAsXml.py @@ -41,13 +41,13 @@ class EntryNotFoundException(Exception): pass -def apply_zbmath_api_fixes(result, prefix): +def apply_zbmath_api_fixes(result, prefix_get_as_xml): if result.get('datestamp'): result['datestamp'] = (result['datestamp']. replace('0001-01-01T00:00:00Z', '0001-01-01T00:00:00')) if result.get('id'): - result['id'] = prefix + str(result['id']) + result['id'] = prefix_get_as_xml + str(result['id']) old_states = result.get('states') if old_states is None: return From 7a90b819c243d131851ed5ee104dad1bde27b099 Mon Sep 17 00:00:00 2001 From: Mazztok45 Date: Tue, 14 Jan 2025 14:42:09 +0100 Subject: [PATCH 5/7] renaming the final_xml2 prefix parameter to fix the issues pointed out by deepsource --- src/zbmath_rest2oai/getAsXml.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/zbmath_rest2oai/getAsXml.py b/src/zbmath_rest2oai/getAsXml.py index 9c483f79..96165250 100644 --- a/src/zbmath_rest2oai/getAsXml.py +++ b/src/zbmath_rest2oai/getAsXml.py @@ -119,7 +119,7 @@ def api_doc_endpoint(page): dict_res = [dict_res] return dict_res -def final_xml2(api_source, prefix): +def final_xml2(api_source, prefix_final_xml2): headers = {'Accept': 'application/json'} r = requests.get(api_source, headers=headers, timeout=(10, 60)) if r.status_code == 404: @@ -141,14 +141,14 @@ def final_xml2(api_source, prefix): for result in json["result"]: if isinstance(result, list): result = result[0] - apply_zbmath_api_fixes(result, prefix) + apply_zbmath_api_fixes(result, prefix_final_xml2) identifier = result["id"] dict_math_entities[identifier] = _illegal_xml_chars_RE.sub("", Converter(wrap="root").build( result, closed_tags_for=[[], '', [None], None])) tags[identifier] = extract_tags(result) elif isinstance(result, dict): - apply_zbmath_api_fixes(result, prefix) + apply_zbmath_api_fixes(result, prefix_final_xml2) identifier = result["id"] dict_math_entities[identifier] = _illegal_xml_chars_RE.sub("", Converter(wrap="root").build( result, @@ -159,7 +159,7 @@ def final_xml2(api_source, prefix): if __name__ == "__main__": if "document" in sys.argv[1]: - prefix="oai:zbmath.org:" + prefix_final_xml2="oai:zbmath.org:" else: - prefix="oai:swmath.org:" - print(final_xml2(sys.argv[1], prefix)) + prefix_final_xml2="oai:swmath.org:" + print(final_xml2(sys.argv[1], prefix_final_xml2)) From 3d8d46a08c8a8b1d2468a0e5bb1bf5476882afd3 Mon Sep 17 00:00:00 2001 From: Mazztok45 Date: Tue, 14 Jan 2025 14:44:58 +0100 Subject: [PATCH 6/7] fix the whitespaces issues pointed out by deepsource --- src/zbmath_rest2oai/getAsXml.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zbmath_rest2oai/getAsXml.py b/src/zbmath_rest2oai/getAsXml.py index 96165250..c92e565e 100644 --- a/src/zbmath_rest2oai/getAsXml.py +++ b/src/zbmath_rest2oai/getAsXml.py @@ -159,7 +159,7 @@ def final_xml2(api_source, prefix_final_xml2): if __name__ == "__main__": if "document" in sys.argv[1]: - prefix_final_xml2="oai:zbmath.org:" + prefix_final_xml2 = "oai:zbmath.org:" else: - prefix_final_xml2="oai:swmath.org:" + prefix_final_xml2 = "oai:swmath.org:" print(final_xml2(sys.argv[1], prefix_final_xml2)) From 1e05055a14e13e4b308f22b795ede5f6e3ed0f98 Mon Sep 17 00:00:00 2001 From: Mazztok45 Date: Tue, 14 Jan 2025 14:49:41 +0100 Subject: [PATCH 7/7] fix the naming issues pointed out by deepsource --- src/zbmath_rest2oai/getAsXml.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/zbmath_rest2oai/getAsXml.py b/src/zbmath_rest2oai/getAsXml.py index c92e565e..b1f29765 100644 --- a/src/zbmath_rest2oai/getAsXml.py +++ b/src/zbmath_rest2oai/getAsXml.py @@ -159,7 +159,7 @@ def final_xml2(api_source, prefix_final_xml2): if __name__ == "__main__": if "document" in sys.argv[1]: - prefix_final_xml2 = "oai:zbmath.org:" + prefix_final_xml2_main = "oai:zbmath.org:" else: - prefix_final_xml2 = "oai:swmath.org:" - print(final_xml2(sys.argv[1], prefix_final_xml2)) + prefix_final_xml2_main = "oai:swmath.org:" + print(final_xml2(sys.argv[1], prefix_final_xml2_main))