Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add manuscript edition to the bibliographic meta data #19

Merged
merged 2 commits into from
Jul 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the advantage of self.get_edition() over self.edition?

I think we had that discussion before though but I forgot your reasoning.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's basically a left-over from C++ times. Obviously, getter/setter are not recommended (http://dirtsimple.org/2004/12/python-is-not-java.html) in Python. #21

"""
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]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will that xpath always return results? If not, an error with that xpath might be more intuitive than an IndexError.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#22

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