Skip to content

Commit

Permalink
added a condition json[result] is a dictionnary to make the distincti…
Browse files Browse the repository at this point in the history
…on to avoid bug when we run run_get_all_de_software.py as json[result] is not a dictionnary when we request the software endpoint of the rest api
  • Loading branch information
Mazztok45 committed Feb 9, 2024
1 parent f956a75 commit 0a3d708
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/zbmath_rest2oai/getAsXml.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ def final_xml2(de, api_source):
raise Exception(f"Unexpected response with status code {r.status_code}: {r.text}")
json = r.json()
# Bugfix as the sates are lists of lists which has no canonical XML mapping
states = {}
for lst in json['result']['states']:
[k, v] = lst
states[k] = v
json['result']['states'] = states
if type(json['result'])==dict:

states = {}
for lst in json['result']['states']:
[k, v] = lst
states[k] = v
json['result']['states'] = states
# End of fix
return (
dict2xml.Converter(wrap="root")
Expand Down

0 comments on commit 0a3d708

Please sign in to comment.