Skip to content

Commit

Permalink
Proper location of pickle files
Browse files Browse the repository at this point in the history
  • Loading branch information
kthoden committed Dec 16, 2019
1 parent c159ae8 commit cb9f666
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
15 changes: 9 additions & 6 deletions src/fix_tei.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
ns_tei = "http://www.tei-c.org/ns/1.0"
NS_MAP = {"t" : ns_tei}

TMP_DIR = os.path.expanduser("output/imxml/tmp_files")
PICKLE_DIR = os.path.expanduser("output/pickle_from_tei")
OUTPUT_DIR = os.path.expanduser("output/imxml_from_tei")

RUNNING_DIRECTORY = os.path.dirname(os.path.realpath(__file__))
logging.debug("The script is run from {}".format(RUNNING_DIRECTORY))
Expand Down Expand Up @@ -675,8 +676,10 @@ def main():
sys.stderr.write("Specify either 'chapter' or 'part' as highest level. Exiting")
sys.exit()

if not os.path.exists(TMP_DIR):
os.makedirs(TMP_DIR)
if not os.path.exists(OUTPUT_DIR):
os.makedirs(OUTPUT_DIR)
if not os.path.exists(PICKLE_DIR):
os.makedirs(PICKLE_DIR)

with open(args.teifile, 'r') as xmlfile:
xml_tree = etree.parse(xmlfile)
Expand All @@ -697,7 +700,7 @@ def main():
bibdata = parse_bibtex(args.bibfile)

xml_cleaned = cleanup_xml(xml_tree)
cleaned_path = TMP_DIR + os.path.sep + args.teifile.replace(".xml", "-cleaned.xml")
cleaned_path = OUTPUT_DIR + os.path.sep + args.teifile.replace(".xml", "-cleaned.xml")
xml_cleaned.write(cleaned_path, pretty_print=True, xml_declaration=True, encoding="utf-8")
logging.info("Wrote %s." % cleaned_path)

Expand All @@ -719,7 +722,7 @@ def main():

math_string = convert_math(mod_string3)

debug_output = TMP_DIR + os.path.sep + args.teifile.replace(".xml", "-modified.xml")
debug_output = OUTPUT_DIR + os.path.sep + args.teifile.replace(".xml", "-modified.xml")
with open(debug_output, "w") as debugfile:
debugfile.write(math_string)
logging.info("Wrote %s." % debug_output)
Expand Down Expand Up @@ -781,7 +784,7 @@ def main():

etree.strip_tags(xml_tree2, "tagtobestripped")

picklefile = "output/imxml/tmp_files/data.pickle"
picklefile = "output/pickle_from_tei/data.pickle"
pickle_data(citekeys_not_in_bib, used_citekeys, picklefile)

fix_document_structure(xml_tree2, highest_level)
Expand Down
4 changes: 2 additions & 2 deletions src/imxml2epub.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8; mode: python -*-
# Time-stamp: <2019-11-26 12:30:59 (kthoden)>
# Time-stamp: <2019-12-09 16:26:29 (kthoden)>

""" Convert a customized DocBook XML file into a set of files that
constitute the contents of an EPUB file.
Expand Down Expand Up @@ -165,7 +165,7 @@

xmlTree = etree.parse( str(INPUT_DIR / "IntermediateXMLFile.xml") )

with open(INPUT_DIR / "tmp_files" / 'data.pickle', 'rb') as f:
with open(INPUT_DIR / 'data.pickle', 'rb') as f:
data = pickle.load(f)

dictSections = data["secdict"]
Expand Down

0 comments on commit cb9f666

Please sign in to comment.