From 7293c43e048fc48afe1d475a1c33ebffad6c2ef0 Mon Sep 17 00:00:00 2001 From: kthoden Date: Fri, 9 Jul 2021 11:16:26 +0200 Subject: [PATCH] Write failed ids to file --- src/imxml2django.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/imxml2django.py b/src/imxml2django.py index 15fac07..cbc19f4 100755 --- a/src/imxml2django.py +++ b/src/imxml2django.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8; mode: python -*- -# Time-stamp: <2021-02-17 09:24:51 (kthoden)> +# Time-stamp: <2021-07-08 19:20:28 (kthoden)> """ Create an XML file that can be inserted into the Django database @@ -1587,6 +1587,13 @@ def bring_footnote_down_django(footnote, fragment, footnote_number, object_numbe logging.info("----------------------------------------------") logging.info("Processing Cross References") +libeoaconvert.debug_xml_here( + xmlDjangoTree, + "beforecrossreference", + DEBUG_DIR +) + +failed_ids = [] # Substitute References with their targets (wit links) for xmlEOAchapter in xmlEOAchapters: # for hyperimage collages @@ -2017,6 +2024,16 @@ def bring_footnote_down_django(footnote, fragment, footnote_number, object_numbe tmpFile.close() logging.debug(f"Wrote {OUTPUT_DIR}/Django.xml.") +if len(failed_ids) > 0: + cleaned_failures = sorted(set(failed_ids)) + tmpFile = open( OUTPUT_DIR / "debug/failed_ids.txt", "w") + tmpFile.writelines(f"Missing IDs by appearance ({len(failed_ids)} in total):\n") + tmpFile.writelines(failed_ids) + tmpFile.writelines(f"\nMissing IDs sorted and uniqued ({len(cleaned_failures)} in total):\n") + tmpFile.writelines(cleaned_failures) + tmpFile.close() + logging.debug(f"Some ids could not be referenced. Check {OUTPUT_DIR}/debug/failed_ids.txt.") + if args.checkpublicationcfg: check_publication_cfg(INPUT_DIR / "publication.cfg") else: