Skip to content

Commit

Permalink
Handle special case for states
Browse files Browse the repository at this point in the history
  • Loading branch information
physikerwelt committed Jan 9, 2024
1 parent a081191 commit 4018e5a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions src/zbmath_rest2oai/getAsXml.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@ def final_xml2(de):
headers = {'Accept': 'application/json'}

r = requests.get('https://api.zbmath.org/v1/document/' + de, headers=headers)

return dict2xml.Converter(wrap="root").build(r.json(), closed_tags_for=[[], '', [None], None])


print(final_xml2("6383667"))
json = r.json()
states = {}
for lst in json['result']['states']:
[k, v] = lst
states[k] = v
json['result']['states'] = states
return (
dict2xml.Converter(wrap="root")
.build(r.json(), closed_tags_for=[
[], '', [None], None
])
)
2 changes: 1 addition & 1 deletion tests/test_plain_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_similarity(self):
'ratio_mode': 'accurate'
})
essentials = list(filter(lambda e: not isinstance(e, MoveNode), diff))
self.assertLessEqual(len(essentials), 46)
self.assertLessEqual(len(essentials), 48)
diff_text = main.diff_texts(expected_string, real_string, {
'ratio_mode': 'accurate'
}, formatter=formatting.XMLFormatter(normalize=formatting.WS_BOTH))
Expand Down

0 comments on commit 4018e5a

Please sign in to comment.