Skip to content

Commit

Permalink
Write failed ids to file
Browse files Browse the repository at this point in the history
  • Loading branch information
kthoden committed Jul 9, 2021
1 parent b9786df commit 7293c43
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/imxml2django.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: <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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 7293c43

Please sign in to comment.