Skip to content

Commit 18d58b8

Browse files
committed
Include DMDID attributes in normative structMap
1 parent 7c636f2 commit 18d58b8

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

metsrw/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
LOGGER = logging.getLogger(__name__)
4545
LOGGER.addHandler(logging.NullHandler())
46-
__version__ = "0.3.19"
46+
__version__ = "0.3.20"
4747

4848
__all__ = [
4949
"Agent",

metsrw/fsentry.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,7 @@ def serialize_structmap(self, recurse=True, normative=False):
471471
if (not normative) and self.file_id():
472472
etree.SubElement(el, utils.lxmlns("mets") + "fptr", FILEID=self.file_id())
473473
if self.dmdids:
474-
if (not normative) or (normative and self.is_empty_dir):
475-
el.set("DMDID", " ".join(self.dmdids))
474+
el.set("DMDID", " ".join(self.dmdids))
476475
if self.mets_div_type.lower() == "directory" and self.admids:
477476
el.set("ADMID", " ".join(self.admids))
478477
if recurse and self._children:

tests/test_normative_structmap.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import metsrw
1414
from metsrw.plugins.premisrw import PREMISObject, PREMIS_3_0_NAMESPACES, lxmlns
1515

16+
from lxml import etree
17+
1618

1719
class TestNormativeStructMap(TestCase):
1820
"""Test normative logical structmap class."""
@@ -71,6 +73,7 @@ def test_write_normative_structmap(self):
7173
# Create the parent directory of the empty directory and give it a
7274
# simple PREMIS object also.
7375
f3 = metsrw.FSEntry("level3.txt", file_uuid=str(uuid.uuid4()))
76+
f3.add_dmdsec(etree.Element("data"), "OTHER")
7477
d2 = metsrw.FSEntry("dir2", type="Directory", children=[f3, d_empty])
7578
d2_id = str(uuid.uuid4())
7679
d2_premis_object = PREMISObject(identifier_value=d2_id)
@@ -157,3 +160,14 @@ def test_write_normative_structmap(self):
157160
"{}type".format(lxmlns("xsi", premis_version="3.0"))
158161
)
159162
assert xsi_type == "premis:intellectualEntity"
163+
164+
# Expect that the file in the normative logical structmap includes the
165+
# DMDID attribute.
166+
dmdid = normative_structmap_el.find(exists_in_both_path, metsrw.NAMESPACES).get(
167+
"DMDID"
168+
)
169+
assert dmdid.startswith("dmdSec_")
170+
file_3_dmd_sec = doc.find(
171+
'mets:dmdSec[@ID="{}"]'.format(dmdid), metsrw.NAMESPACES
172+
)
173+
assert file_3_dmd_sec is not None

0 commit comments

Comments
 (0)