Skip to content

Commit

Permalink
integrating the file output mapping.json to rename the nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mazztok45 committed Dec 13, 2023
1 parent a294dc2 commit 2163536
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/zbmath_rest2oai/getWithSwagger.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import swagger_client

import json
from zbmath_rest2oai.xml_writer import create_document

import json
import re
with open('/home/maxence/myvenv/python-zbMathRest2Oai/src/zbmath_rest2oai/output mapping - Copy.json') as f:
d = json.load(f)
api_instance = swagger_client.DocumentApi(swagger_client.ApiClient())
res = api_instance.get_document_by_zbmath_id_document_id_get(id="6383667")
doc = res.result
Expand Down Expand Up @@ -68,12 +72,17 @@ def func_get_doc_to_xml(obj, xml):

if type(obj) == list:
for i in range(len(obj)):
parent_name = xml.lastChild.nodeName

str_no_zbmath_parent_name = re.sub("zbmath:", "", parent_name)
if str_no_zbmath_parent_name in d.keys():
parent_name = parent_name.replace(str_no_zbmath_parent_name, d[str_no_zbmath_parent_name][0])

if obj[i]==[]:
xml = append_text_child(xmld, xml, xml.lastChild.nodeName, 'missing')
xml = append_text_child(xmld, xml, parent_name, 'missing')
elif obj[i] is None:
xml = append_text_child(xmld, xml, xml.lastChild.nodeName, 'missing')
xml = append_text_child(xmld, xml, parent_name, 'missing')
elif type(obj[i]) in [str,int]:
parent_name = xml.lastChild.nodeName
if parent_name.endswith('s'):
parent_name = parent_name[:-1]

Expand Down

0 comments on commit 2163536

Please sign in to comment.