Open sevein opened 5 years ago
Investigating this for some METS parsing work it is counter-intuitive. A potential pattern for some which might not break in the future is as follows (with additional annotation):
for fsentry in mets.all_files():
for premis_event in fsentry.get_premis_events():
something_interesting = None
detail = premis_event.event_detail
if not isinstance(detail, tuple):
"""handle string
Usually the string we're interested in, e.g. AV output.
"""
something_interesting = detail
"""Otherwise, we have a tuple, which looks as follows, and
we can ignore:
detail <-- tuple
detail[0] <-- abstract base class
detail[0].data <-- abstract base class data (tuple)
detail[0].data[0], e.g. field_name e.g. `event detail`
"""
if something_interesting is not None:
do_something_interesting()
Given the following PREMIS event:
If premisrw is used to access
premis:eventOutcomeDetailNote
using the following form:The value returned is:
However, if there was at least one
premis:eventOutcomeDetailNote
populated, the same accessor would return the value of the first match.I find this behaviour to be counterintuitive - but it's also not clear what would be the best solution. A change could break backward compatibility but would be that a big problem? Who's relying on the returned value when there is a mismatch? Should the accessor raise an error? Return a falsy value?
Your environment (version of Archivematica, OS version, etc) Since metsrw.premisrw was conceived?
For Artefactual use: Please make sure these steps are taken before moving this issue from Review to Verified in Waffle: