Skip to content

Commit

Permalink
Merge pull request #19 from wrznr/add_edition_stmt
Browse files Browse the repository at this point in the history
Add manuscript edition to the bibliographic meta data
  • Loading branch information
wrznr authored Jul 24, 2019
2 parents 8e7e899 + f35825c commit 45e5599
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 3 deletions.
15 changes: 15 additions & 0 deletions mets_mods2teiHeader/api/mets.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __init__(self):
self.places = None
self.dates = None
self.publishers = None
self.edition = None
self.digital_origin = None
self.owner_digital = None
self.license = None
Expand Down Expand Up @@ -156,6 +157,14 @@ def __spur(self):
for publisher in self.tree.xpath("//mets:dmdSec[1]//mods:mods/mods:originInfo[1]/mods:publisher", namespaces=ns):
self.publishers.append(publisher.text)

#
# edition of the manuscript
edition = self.tree.xpath("//mets:dmdSec[1]//mods:mods/mods:originInfo[1]/mods:edition", namespaces=ns)
if edition:
self.edition = edition[0].text
else:
self.edition = ""

#
# digital_origin
for digital_origin in self.tree.xpath("//mets:dmdSec[1]//mods:mods/mods:physicalDescription[1]/mods:digitalOrigin", namespaces=ns):
Expand Down Expand Up @@ -280,6 +289,12 @@ def get_publishers(self):
"""
return self.publishers

def get_edition(self):
"""
Return the edition of the source manuscript
"""
return self.edition

def has_digital_origin(self):
"""
Element "digitalOrigin" present?
Expand Down
9 changes: 9 additions & 0 deletions mets_mods2teiHeader/api/tei.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ def add_publisher(self, publisher):
name.text = publisher
publication_stmt.insert(0, publisher_node)

def add_source_edition(self, manuscript_edition):
"""
Adds an edition statement with details on the source manuscript.
"""
bibl_full = self.tree.xpath('//tei:fileDesc/tei:sourceDesc/tei:biblFull', namespaces=ns)[0]
edition_stmt = etree.SubElement(bibl_full, "editionStmt")
edition = etree.SubElement(edition_stmt, "edition")
edition.text = manuscript_edition

def add_digital_edition(self, digital_edition):
"""
Adds an edition statement with details on the digital edition.
Expand Down
3 changes: 0 additions & 3 deletions mets_mods2teiHeader/data/tei_skeleton.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
<titleStmt>
<title level="m" type="main">[Haupttitel einer Monographie]</title>
</titleStmt>
<editionStmt>
<edition n="1"/>
</editionStmt>
<publicationStmt>
</publicationStmt>
</biblFull>
Expand Down
4 changes: 4 additions & 0 deletions mets_mods2teiHeader/scripts/mets_mods2teiHeader.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def cli(mets):
for publisher in mets.get_publishers():
tei.add_publisher(publisher)

# manuscript edition
if mets.get_edition():
tei.add_source_edition(mets.get_edition())

# digital edition
if mets.has_digital_origin():
tei.add_digital_edition(mets.get_digital_origin())
Expand Down
3 changes: 3 additions & 0 deletions tests/test_mets.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ def test_data_assignment(subtests, datadir):

with subtests.test("Check place(s)"):
assert(mets.get_places() == [{'text': 'Barby'}, {'text': 'Leipzig'}])

with subtests.test("Check manuscript edition"):
assert(mets.get_edition() == '3. Aufl.')
1 change: 1 addition & 0 deletions tests/test_mets/test_mets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ ein Führer für Reisende; mit Kartenbeilagen und Illustrationen in Holzschnitt
<mods:dateOther encoding="w3cdtf" type="order">1789</mods:dateOther>
<mods:publisher>Brüdergemeinen</mods:publisher>
<mods:publisher>Kummer</mods:publisher>
<mods:edition>3. Aufl.</mods:edition>
</mods:originInfo>
<mods:name type="personal">
<mods:role>
Expand Down

0 comments on commit 45e5599

Please sign in to comment.