diff --git a/src/fix_tei.py b/src/fix_tei.py index b53093f..5b2e755 100755 --- a/src/fix_tei.py +++ b/src/fix_tei.py @@ -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)) @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/src/imxml2epub.py b/src/imxml2epub.py index 8277434..829d619 100755 --- a/src/imxml2epub.py +++ b/src/imxml2epub.py @@ -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. @@ -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"]