Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
More debugging files
  • Loading branch information
Klaus Thoden committed May 29, 2018
1 parent ba29277 commit c232bfb
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions imxml2django.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8; mode: python -*-
# Time-stamp: <2018-03-19 16:07:01 (kthoden)>
# Time-stamp: <2018-04-30 16:24:20 (kthoden)>

import pickle
import os
Expand Down Expand Up @@ -67,8 +67,13 @@
dictTables = data["tabdict"]
dictPagelabels = data["pagelabeldict"]

if not os.path.exists(os.getcwd() + os.path.sep + "debug"):
os.mkdir(os.getcwd() + os.path.sep + "debug")

xmlTree = etree.parse("tmp_files/IntermediateXMLFile.xml")

libeoaconvert.debug_xml_here(xmlTree, "fresh")

print("""
############################################################################
# Convert tralics-XML to Django Data Structure #
Expand All @@ -87,7 +92,7 @@
etree.strip_attributes(xmlTree, "noindent")
# Remove temp-Tag
etree.strip_tags(xmlTree, "temp")

libeoaconvert.debug_xml_here(xmlTree, "afterstriptags")
# Write Temporary XML-Maintree
ergebnisdatei = open("tmp_files/Devel_django.xml", "w")
ergebnis = etree.tostring(xmlTree, pretty_print=True, encoding="unicode")
Expand Down Expand Up @@ -883,6 +888,8 @@ def djangoParseHeadline(xmlElement):
xmlEOAchapter.append(djangoParseObject(xmlChapterChild))
intChapterNumber += 1

libeoaconvert.debug_xml_here(xmlTree, "afterchapter")

print("----------------------------------------------")
print("Processing Facsimile Parts")

Expand Down Expand Up @@ -1047,7 +1054,9 @@ def bring_footnote_down_django(footnote, fragment, footnote_number, object_numbe
xmlEOAsection.set("order", str(intObjectNumber))
intObjectNumber += 1
xmlHead = etree.Element("head")

xmlHead.text = libeoaconvert.dictLangFootnotes[libeoaconvert.two_letter_language(xmlEOAchapter.get("language"))]

xmlEOAsection.append(xmlHead)
xmlResult.append(xmlEOAsection)

Expand Down Expand Up @@ -1476,13 +1485,20 @@ def bring_footnote_down_django(footnote, fragment, footnote_number, object_numbe
logging.debug("Sorting %s entries for regular index." % str(len(xml_regular_EOAindices)))
xml_eoa_print_regular_index = make_index(xml_regular_EOAindices, index_type = "regular")

libeoaconvert.debug_xml_here(xmlDjangoTree, "djangotree")
libeoaconvert.debug_xml_here(xmlEOAdocument, "xmleoadocument")
libeoaconvert.debug_xml_here(xmlTree, "xmltree")

# If EOAprintindex is found, append xml_eoa_print_regular_index to xmlEOAdocument
xmlPrintindex = xmlTree.find(".//EOAprintindex")
if xmlPrintindex is not None != 0:
# Remove <p><EOAprintindex/></p> from xmlDjangoTree
print("found an index")
xmlPrintindex.tag = "temp"
xmlPrintindex.getparent().tag = "temp"
xmlEOAdocument.append(xml_eoa_print_regular_index)
else:
print("found no index")

print("----------------------------------------------")
print("Sorting and Creating Person Index")
Expand Down

0 comments on commit c232bfb

Please sign in to comment.