Skip to content

Commit

Permalink
Bibles with duplicate short names for bible books causing issues
Browse files Browse the repository at this point in the history
Keep track of book shortcodes
  • Loading branch information
martijnlentink committed Dec 29, 2024
1 parent 1e93cae commit 0e425ea
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bible_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ def construct_metadataxmls(output_file_loc, book_metadata):

book_names_el = xml_tree.xpath("//bookNames")[0]
books_el = xml_tree.xpath("//bookList/books")[0]
unique_short_list = []

for book in book_metadata["books"]:
book_code = book['usfm']
Expand All @@ -330,11 +331,13 @@ def construct_metadataxmls(output_file_loc, book_metadata):
abbr = book['abbreviation']
book_el = SubElement(book_names_el, "book", code=book_code)
SubElement(book_el, 'long').text = long
SubElement(book_el, 'short').text = short
SubElement(book_el, 'short').text = short if short not in unique_short_list else long
SubElement(book_el, 'abbr').text = abbr

SubElement(books_el, "book", code=book_code)

unique_short_list.append(short)

metadataxml_output = os.path.join(output_file_loc, "metadata.xml")
with open(metadataxml_output, 'wb') as handle:
handle.write(toxml(xml_tree))
Expand Down

0 comments on commit 0e425ea

Please sign in to comment.