Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Press is either MPRL or EOS
  • Loading branch information
kthoden committed Jan 28, 2020
1 parent 51dddac commit df26e9e
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions src/fix_tei.py
Expand Up @@ -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]
Expand Down Expand Up @@ -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")
Expand All @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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.")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit df26e9e

Please sign in to comment.