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 efc067a commit 914ef82
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions eoatex2imxml.py
Expand Up @@ -1610,22 +1610,26 @@ def cleanup():
# here followed the conversion to epub and the conversion to django.xml
# both parts were removed and put into separate files.

intermediate_file_pre = "tmp_files/IntermediateXMLFile_pre.xml"
intermediate_file = "tmp_files/IntermediateXMLFile.xml"
ergebnisdatei = open(intermediate_file, "w")
ergebnisdatei = open(intermediate_file_pre, "w")
ergebnis = etree.tostring(xmlTree, pretty_print=True, encoding="unicode")
ergebnisdatei.write(ergebnis)
ergebnisdatei.close()

# replacing a milestone element by a closing and opening combination
with open(intermediate_file, 'r') as tmp_file:
with open(intermediate_file_pre, 'r') as tmp_file:
filedata = tmp_file.read()

# add XML declaration
filedata_declaration = "<?xml version='1.0' encoding='UTF-8'?>\n" + filedata

# Replace the target string
filedata = filedata.replace('<msparbreak/>', '</p><p>')
filedata_clean = filedata_declaration.replace('<msparbreak/>', '</p><p>')

# Write the file out again
with open(intermediate_file, 'w') as outfile:
outfile.write(filedata)
outfile.write(filedata_clean)

# saving some data
data_to_pickle = {'chapterdict' : dictChapters,
Expand Down

0 comments on commit 914ef82

Please sign in to comment.