Skip to content

Commit

Permalink
Merge pull request #69 from cu-mkp/issue63
Browse files Browse the repository at this point in the history
issue63: add <fr> tag to entry-metadata.csv + bug fixes

Note: see #70 which was discovered evaluating the results of testing update .py in this branch
  • Loading branch information
tcatapano authored Jan 25, 2021
2 parents 445a6ee + bf82e0d commit 7093ddd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions manuscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 <entry> root tag :)
Expand Down
2 changes: 1 addition & 1 deletion update.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Last Updated | 2021-01-08
# Last Updated | 2021-01-25
# Python Modules
import os
import sys
Expand Down
1 change: 1 addition & 0 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
'greek': 'el',
'italian': 'it',
'latin': 'la',
'french': 'fr',
'occitan': 'oc',
'poitevin': 'po'
}
Expand Down

0 comments on commit 7093ddd

Please sign in to comment.