artefactual-labs / mets-reader-writer

Library to parse and create METS files, especially for Archivematica.
https://mets-reader-writer.readthedocs.io
GNU Affero General Public License v3.0
20 stars 13 forks source link

Problem: it is difficult to access some attributes of `PREMISElement` instances #45

Closed jrwdunham closed 6 years ago

jrwdunham commented 6 years ago

Right now, it is difficult to access attributes of collections of elements within a PREMISElement instance. For example, to get the premis:relationshipSubType value of all premis:relationship elements in a PREMISObject with current metsrw.plugins.premisrw, the following is necessary::

>>> for relationship in premis_object.relationship:
...     try:
...         sub_type = [el for el in relationship if el[0] == 'relationship_sub_type'][0][1]
...     except IndexError:
...         sub_type = None

It would be better if something like the following were possible:

>>> for relationship in premis_object.relationship:
...     sub_type = relationship.sub_type