Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make bibliography type an option for command line
  • Loading branch information
Klaus Thoden committed Nov 14, 2018
1 parent c28de82 commit 7435c76
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions fix_tei.py
Expand Up @@ -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]
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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.")
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 7435c76

Please sign in to comment.