From 3ac974cf5df01ed241627548e18b6b9ee0265557 Mon Sep 17 00:00:00 2001 From: wrznr Date: Tue, 23 Jul 2019 16:31:50 +0200 Subject: [PATCH 1/2] Add manuscript edition to the bibliographic meta data Taken from `mods:edition`, put into `tei:biblFull/editionStmt`. --- mets_mods2teiHeader/api/mets.py | 15 +++++++++++++++ mets_mods2teiHeader/api/tei.py | 9 +++++++++ mets_mods2teiHeader/data/tei_skeleton.xml | 3 --- .../scripts/mets_mods2teiHeader.py | 4 ++++ 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/mets_mods2teiHeader/api/mets.py b/mets_mods2teiHeader/api/mets.py index dbf7f83..f6b370a 100644 --- a/mets_mods2teiHeader/api/mets.py +++ b/mets_mods2teiHeader/api/mets.py @@ -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 @@ -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): @@ -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? diff --git a/mets_mods2teiHeader/api/tei.py b/mets_mods2teiHeader/api/tei.py index 4f7a8b8..99cd7e7 100644 --- a/mets_mods2teiHeader/api/tei.py +++ b/mets_mods2teiHeader/api/tei.py @@ -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. diff --git a/mets_mods2teiHeader/data/tei_skeleton.xml b/mets_mods2teiHeader/data/tei_skeleton.xml index 14ce83e..430c3d4 100644 --- a/mets_mods2teiHeader/data/tei_skeleton.xml +++ b/mets_mods2teiHeader/data/tei_skeleton.xml @@ -15,9 +15,6 @@ [Haupttitel einer Monographie] - - - diff --git a/mets_mods2teiHeader/scripts/mets_mods2teiHeader.py b/mets_mods2teiHeader/scripts/mets_mods2teiHeader.py index 4b8a10c..34dbfec 100644 --- a/mets_mods2teiHeader/scripts/mets_mods2teiHeader.py +++ b/mets_mods2teiHeader/scripts/mets_mods2teiHeader.py @@ -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()) From f35825cf8f282cda2c332a658464935eab1e3f27 Mon Sep 17 00:00:00 2001 From: wrznr Date: Tue, 23 Jul 2019 16:36:05 +0200 Subject: [PATCH 2/2] Add test for manuscript edition extraction --- tests/test_mets.py | 3 +++ tests/test_mets/test_mets.xml | 1 + 2 files changed, 4 insertions(+) diff --git a/tests/test_mets.py b/tests/test_mets.py index 8178062..d6de679 100644 --- a/tests/test_mets.py +++ b/tests/test_mets.py @@ -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.') diff --git a/tests/test_mets/test_mets.xml b/tests/test_mets/test_mets.xml index a86fdd8..1ab67ce 100644 --- a/tests/test_mets/test_mets.xml +++ b/tests/test_mets/test_mets.xml @@ -65,6 +65,7 @@ ein Führer für Reisende; mit Kartenbeilagen und Illustrationen in Holzschnitt 1789 Brüdergemeinen Kummer + 3. Aufl.