From 7435c762133fdd1e0149b4f6210c1fc3d9851d51 Mon Sep 17 00:00:00 2001 From: Klaus Thoden Date: Wed, 14 Nov 2018 14:33:41 +0100 Subject: [PATCH] Make bibliography type an option for command line --- fix_tei.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fix_tei.py b/fix_tei.py index 2e03743..f1bedaf 100644 --- a/fix_tei.py +++ b/fix_tei.py @@ -370,7 +370,7 @@ def fix_document_structure(xml_tree, highest_level): subsubsection.set("type", "subsubsection") # def fix_document_structure ends here -def fix_tei_header(xml_tree, bibfile_string): +def fix_tei_header(xml_tree, bibfile_string, bibtype): """Populate TEI header with mandatory data""" title_statement = xml_tree.xpath("//t:titleStmt", namespaces=NS_MAP)[0] @@ -421,7 +421,7 @@ def fix_tei_header(xml_tree, bibfile_string): source_desc = xml_tree.xpath("//t:sourceDesc", namespaces=NS_MAP)[0] suggested_citation = etree.SubElement(source_desc, "ab", type="suggestedcitation").text = "Suggested Citation" bibfile = etree.SubElement(source_desc, "ab", type="bibdatabase") - etree.SubElement(bibfile, "ref", type="monograph", target=bibfile_string) + etree.SubElement(bibfile, "ref", type=bibtype, target=bibfile_string) # profile description profile_desc = etree.Element("profileDesc") @@ -517,6 +517,7 @@ def main(): parser = argparse.ArgumentParser() parser.add_argument("-d", "--dochighestorder", default='chapter', help="Specify which divider is at the highest level, possible values: part, chapter. Default is chapter.") parser.add_argument("-f", "--finalize", help="Finalize a publication.", action="store_true") + parser.add_argument("-b", "--bibtype", help="Specify the type of bibliography, possible values: anthology, monograph.", default="monograph") parser.add_argument("teifile", help="Output from oxgarage/metypeset, an TEI XML file.") parser.add_argument("bibfile", help="The bibliography database of the publication.") parser.add_argument("figdir", help="The directory that contains the figures belonging to the publication.") @@ -593,7 +594,7 @@ def main(): report["bad_pageref"] = bad_pageref tei_header = xml_tree2.xpath("//t:teiHeader", namespaces=NS_MAP) - fix_tei_header(tei_header[0], str(args.bibfile)) + fix_tei_header(tei_header[0], str(args.bibfile), str(args.bibtype)) tei_text = xml_tree2.xpath("/t:TEI/t:text", namespaces=NS_MAP)[0] tei_front_part = add_tei_frontpart()