From dda6184569cdd2333584b6f93474051086724125 Mon Sep 17 00:00:00 2001 From: kthoden Date: Thu, 7 Mar 2019 17:09:32 +0100 Subject: [PATCH] Put config serialization into main() --- tei2imxml.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tei2imxml.py b/tei2imxml.py index 29dfd6b..2582a61 100644 --- a/tei2imxml.py +++ b/tei2imxml.py @@ -220,11 +220,7 @@ def make_publication_cfg(info_dict): except IndexError: authors_config[author_label] = "" - output_filename = OUTPUT_DIR + os.path.sep + "publication.cfg" - with open(output_filename, 'w') as configfile: - config.write(configfile) - - print("Wrote", output_filename) + return config # def make_publication_cfg ends here def render_reference(list_of_xml_elements, cited_data): @@ -1110,9 +1106,20 @@ def main(): if not os.path.exists(OUTPUT_DIR): os.mkdir(os.path.expanduser(OUTPUT_DIR)) + logging.info(f"Created {os.path.expanduser(OUTPUT_DIR)}") + input("press enter") + else: + logging.info(f"We are using {os.path.expanduser(OUTPUT_DIR)} as output dir") + input("press enter") publication_info = get_publication_info(xml_tree) - make_publication_cfg(publication_info) + config_data = make_publication_cfg(publication_info) + + output_filename = OUTPUT_DIR + os.path.sep + "publication.cfg" + with open(output_filename, 'w') as configfile: + config_data.write(configfile) + + print("Wrote", output_filename) if not os.path.exists(TMP_DIR): os.mkdir(os.path.expanduser(TMP_DIR))