From df26e9ef526122e13f05ece478cd6df9701445b2 Mon Sep 17 00:00:00 2001 From: kthoden Date: Tue, 28 Jan 2020 15:28:28 +0100 Subject: [PATCH] Press is either MPRL or EOS --- src/fix_tei.py | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/fix_tei.py b/src/fix_tei.py index ec97f28..26f307d 100755 --- a/src/fix_tei.py +++ b/src/fix_tei.py @@ -433,7 +433,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, bibtype): +def fix_tei_header(xml_tree, bibfile_string, bibtype, organisation): """Populate TEI header with mandatory data""" title_statement = xml_tree.xpath("//t:titleStmt", namespaces=NS_MAP)[0] @@ -486,8 +486,13 @@ def fix_tei_header(xml_tree, bibfile_string, bibtype): publisher_element = etree.SubElement(publication_statement, "publisher") overall_org = etree.SubElement(publisher_element, "orgName", n="EOA", ref=BOILERPLATES.get("Header","eoa_url")) overall_org.text = BOILERPLATES.get("Header","eoa_name") - publishing_org = etree.SubElement(publisher_element, "orgName", n="Press", ref=BOILERPLATES.get("Header","mprl_url")) - publishing_org.text = BOILERPLATES.get("Header","mprl_name") + if organisation == "mprl": + publishing_org = etree.SubElement(publisher_element, "orgName", n="Press", ref=BOILERPLATES.get("Header","mprl_url")) + publishing_org.text = BOILERPLATES.get("Header","mprl_name") + else: + publishing_org = etree.SubElement(publisher_element, "orgName", n="Press", ref=BOILERPLATES.get("Header","eos_url")) + publishing_org.text = BOILERPLATES.get("Header","eos_name") + pub_date = etree.SubElement(publication_statement, "date", when=publication_date.strftime("%Y-%m-%d")) availability = etree.SubElement(publication_statement, "availability") @@ -496,12 +501,16 @@ def fix_tei_header(xml_tree, bibfile_string, bibtype): # series statement series_stmt = etree.Element("seriesStmt") - title_element = etree.SubElement(series_stmt, "title").text = "Series_title" + title_element = etree.SubElement(series_stmt, "title") resp_stmt = etree.SubElement(series_stmt, "respStmt") resp_title = etree.SubElement(resp_stmt, "resp").text = "Series Editors" resp_names = etree.SubElement(resp_stmt, "name", type="serieseditors") - resp_names.text = BOILERPLATES.get("Header","mprl_series_editors") + resp_names.text = BOILERPLATES.get("Header","eoa_series_editors") series_number = etree.SubElement(series_stmt, "idno", type="number").text = "number" + if organisation == "mprl": + title_element.text = "Series_title" + else: + title_element.text = "Sources" publication_statement.addnext(series_stmt) @@ -531,8 +540,15 @@ def fix_tei_header(xml_tree, bibfile_string, bibtype): project_desc = etree.Element("projectDesc") eoainfo_p1 = etree.SubElement(project_desc, "p", n="eoainfo").text = BOILERPLATES.get("Header","eoainfo_p1") eoainfo_p2 = etree.SubElement(project_desc, "p", n="eoainfo").text = BOILERPLATES.get("Header","eoainfo_p2") - mprlinformation = etree.SubElement(project_desc, "p", n="mprlinformation").text = BOILERPLATES.get("Header","mprlinformation") - scientificboard = etree.SubElement(project_desc, "p", n="scientificboard").text = BOILERPLATES.get("Header","scientificboard") + pressinformation = etree.SubElement(project_desc, "p", n="pressinformation") + scientificboard = etree.SubElement(project_desc, "p", n="scientificboard") + if organisation == "mprl": + pressinformation.text = BOILERPLATES.get("Header","pressinformation_mprl") + scientificboard.text = BOILERPLATES.get("Header","scientificboard_mprl") + else: + pressinformation.text = BOILERPLATES.get("Header","pressinformation_eos") + scientificboard.text = BOILERPLATES.get("Header","scientificboard_eos") + eoadevteam = etree.SubElement(project_desc, "p", n="eoadevteam").text = BOILERPLATES.get("Header","eoadevteam") encoding_desc.insert(0, project_desc) @@ -650,6 +666,7 @@ def main(): parser.add_argument("-c", "--chapter", help="Treat the TEI as one chapter, discards header.", action="store_true") parser.add_argument("-a", "--addbibliography", help="Add a section with bibliography PI.", action="store_true") parser.add_argument("-l", "--printlog", help="Write logfile to stdout instead of writing to file.", action="store_true") + parser.add_argument("-o", "--organisation", help="Specify which to publisher this publication belongs.", choices=["eos", "mprl"], default="mprl") 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.") @@ -758,7 +775,7 @@ def main(): else: tei_header = xml_tree2.xpath("//t:teiHeader", namespaces=NS_MAP) - fix_tei_header(tei_header[0], str(args.bibfile), str(args.bibtype)) + fix_tei_header(tei_header[0], str(args.bibfile), str(args.bibtype), args.organisation) tei_text = xml_tree2.xpath("/t:TEI/t:text", namespaces=NS_MAP)[0] # this xml:id is for xmlmind functionality