Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Debugging
  • Loading branch information
Klaus Thoden committed Aug 31, 2018
1 parent f6fed94 commit 3a1e9e2
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions tei2imxml.py
Expand Up @@ -962,37 +962,30 @@ def main():
# print(cited_dict)

tei_body = xml_tree.xpath("//t:body", namespaces=NS_MAP)[0]

body_transformed = transform_body(tei_body, cited_dict, publang=publication_language)

resulting_tree = etree.ElementTree(body_transformed)

tmp_output_filename = TMP_DIR + os.path.sep + "after_transformation.xml"

# resulting_tree.write(output_filename, pretty_print=True, xml_declaration=True,encoding="utf-8")
resulting_tree.write(tmp_output_filename, pretty_print=True, xml_declaration=True, encoding="utf-8")
logging.info("Wrote %s for debugging purposes." % tmp_output_filename)
body_transformed_tmp = transform_body(tei_body, cited_dict, publang=publication_language)
libeoaconvert.debug_xml_here(body_transformed_tmp, "body_transformed")
body_transformed = etree.ElementTree(body_transformed_tmp)

if bib_data["type"] == "monograph":
xml_add_bib = add_bibliography_monograph(resulting_tree, refs_for_bib_chapter)
xml_add_bib = add_bibliography_monograph(body_transformed, refs_for_bib_chapter)
elif bib_data["type"] == "anthology":
xml_add_bib = add_bibliography_anthology(resulting_tree, formatted_references_dict)

# xml_add_bib = add_bibliography(resulting_tree, refs_for_bib_chapter)
xml_add_bib = add_bibliography_anthology(body_transformed, formatted_references_dict)

etree.strip_tags(xml_add_bib, "tagtobestripped")
libeoaconvert.debug_xml_here(xml_add_bib, "xml_add_bib")

elements_with_ids = xml_add_bib.xpath("//div1 | //div2 | //div3 | //note | //item | //table | //EOAfigure/anchor | //EOAequation | //formula | //theorem")
element_counter = 1
for element in elements_with_ids:
element.set("id", "uid" + str(element_counter))
element_counter += 1

assigned_ids, data_to_pickle = assign_ids(resulting_tree, data)
assigned_ids, data_to_pickle = assign_ids(xml_add_bib, data)

updated_xml_tree = update_ids(assigned_ids)

xml_root = updated_xml_tree.getroot()
# libeoaconvert.debug_xml_here(updated_xml_tree, "updated_tree")
nearly_final_tree = etree.ElementTree(updated_xml_tree)
xml_root = nearly_final_tree.getroot()

xml_root.tag = "Book"

Expand All @@ -1019,7 +1012,6 @@ def main():
os.mkdir(os.path.expanduser(TMP_DIR))
output_filename = TMP_DIR + os.path.sep + "IntermediateXMLFile.xml"

# resulting_tree.write(output_filename, pretty_print=True, xml_declaration=True,encoding="utf-8")
final_tree.write(output_filename, pretty_print=True, xml_declaration=True, encoding="utf-8")
logging.info("Wrote %s." % output_filename)

Expand Down

0 comments on commit 3a1e9e2

Please sign in to comment.