diff --git a/manuscript.py b/manuscript.py index 7a29b4d..b72e909 100644 --- a/manuscript.py +++ b/manuscript.py @@ -31,6 +31,10 @@ def clean_folio(folio: str) -> str: def clean_id(identity: str) -> str: return identity.lstrip("p").lstrip("0").replace("_","") +def display_id(identity: str) -> str: + # inverse of clean_id() + return "p" + identity[:-1].zfill(4) + "_" + identity[-1] + def separate_by_id(filepath: str) -> Dict[str, et.Element]: """Take a file path, read it as XML, and process it into separate elements by ID. Returned object is a dictionary of lxml.etree.Element objects keyed by entry ID as a string. @@ -229,8 +233,9 @@ def update_entries(self, outdir=utils.entries_path, dry_run=False): os.makedirs(xml_path, exist_ok=True) for identity, entry in entries.items(): - filepath_txt = os.path.join(txt_path, f'{version}_{entry.identity}.txt') - filepath_xml = os.path.join(xml_path, f'{version}_{entry.identity}.xml') + # need to leftpad this + filepath_txt = os.path.join(txt_path, f'{version}_{display_id(entry.identity)}.txt') + filepath_xml = os.path.join(xml_path, f'{version}_{display_id(entry.identity)}.xml') content_txt = entry.text content_xml = entry.xml_string # should already have an root tag :) diff --git a/update.py b/update.py index 64a1d14..96823be 100644 --- a/update.py +++ b/update.py @@ -1,4 +1,4 @@ -# Last Updated | 2021-01-08 +# Last Updated | 2021-01-25 # Python Modules import os import sys diff --git a/utils.py b/utils.py index cfaf359..cdf9719 100644 --- a/utils.py +++ b/utils.py @@ -33,6 +33,7 @@ 'greek': 'el', 'italian': 'it', 'latin': 'la', + 'french': 'fr', 'occitan': 'oc', 'poitevin': 'po' }