Skip to content
Permalink
Browse files

Fill header with more dummy data

  • Loading branch information...
kthoden committed Nov 21, 2018
1 parent 53580f8 commit 82b97189f0f56cc3d6c739624b7f8a987124d5de
Showing with 25 additions and 16 deletions.
  1. +25 −16 fix_tei.py
@@ -59,19 +59,6 @@
BOILERPLATES = configparser.ConfigParser()
BOILERPLATES.read(TEI_BOILERPLATE)

def get_place_in_xml_tree(element, tree):
"""Find out the position of an element in a tree.
Return the index. Example: how to insert an element after a specific
element
"""

xml_children = tree.getchildren()
position = xml_children.index(element)

return position
# def get_place_in_xml_tree ends here

def parse_bibtex(bibfile):
"""Parse the bibtex file, return a dict"""

@@ -383,6 +370,23 @@ def fix_tei_header(xml_tree, bibfile_string, bibtype):
else:
pass

author_element = title_statement.find("t:author", namespaces=NS_MAP)
author_element.tag = "editor"
author_element.set("n", "1")
author_element.set("ref", "#nn")
author_element.set("role", "volumeeditor")
author_element.set("key", "eoa_00")
author_element.text = "N.N."

example_resp = etree.Element("respStmt")
example_resp.attrib["{http://www.w3.org/XML/1998/namespace}id"] = "nn"
respresp = etree.SubElement(example_resp, "resp")
respresp.text = "chapter author"
respname = etree.SubElement(example_resp, "persName")
surname = etree.SubElement(respname, "surname").text = "N"
forename = etree.SubElement(respname, "forename").text = "N"
libeoaconvert.insert_after(example_resp, author_element)

edition = xml_tree.xpath("//t:editionStmt/t:edition", namespaces=NS_MAP)[0]
edition_date = edition.find("t:date", namespaces=NS_MAP)
edition_date.clear()
@@ -395,6 +399,11 @@ def fix_tei_header(xml_tree, bibfile_string, bibtype):
unknown_paragraph.clear()
unknown_paragraph.tag = "tagtobestripped"

extent_element = etree.Element("extent")
pages = etree.SubElement(extent_element, "measure", commodity="pages", quantity="0")
price = etree.SubElement(extent_element, "measure", type="price", unit="EUR", quantity="0")
libeoaconvert.insert_after(extent_element, publication_statement, before=True)

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")
@@ -408,14 +417,14 @@ 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").text = "Series_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")
series_number = etree.SubElement(series_stmt, "idno", type="number").text = "number"
publication_stmt_parent = publication_statement.getparent()
series_stmt_insertion_point = get_place_in_xml_tree(publication_statement, publication_stmt_parent) + 1
series_stmt_insertion_point = libeoaconvert.get_place_in_xml_tree(publication_statement, publication_stmt_parent) + 1
publication_stmt_parent.insert(series_stmt_insertion_point, series_stmt)

source_desc = xml_tree.xpath("//t:sourceDesc", namespaces=NS_MAP)[0]
@@ -436,7 +445,7 @@ def fix_tei_header(xml_tree, bibfile_string, bibtype):
list_keywords = etree.SubElement(keywords, "list")
keyword_item = etree.SubElement(list_keywords, "item").text = BOILERPLATES.get("Header","eoa_name")
langusage = etree.SubElement(profile_desc, "langUsage")
language = etree.SubElement(langusage, "language", ident="principal language")
language = etree.SubElement(langusage, "language", ident="principal_language")
xml_tree.insert(1, profile_desc)

encoding_desc = xml_tree.xpath("//t:encodingDesc", namespaces=NS_MAP)[0]

0 comments on commit 82b9718

Please sign in to comment.
You can’t perform that action at this time.