mirror of
https://github.com/qurator-spk/modstool.git
synced 2025-06-08 19:29:57 +02:00
🐛 Fix mods:relatedItem with mods:recordIdentifier source=dnb-ppn
mods:relatedItem may have a mods:recordIdentifier with source="dnb-ppn". This may happen for digitized works that have their original work in another library and use a DNB PPN there. Fixes gh-22.
This commit is contained in:
parent
4e7b8ed642
commit
100b2a5e6c
2 changed files with 20 additions and 1 deletions
|
@ -95,7 +95,13 @@ def mods_to_dict(mods, raise_errors=True):
|
||||||
elif tag == '{http://www.loc.gov/mods/v3}recordInfo':
|
elif tag == '{http://www.loc.gov/mods/v3}recordInfo':
|
||||||
value['recordInfo'] = TagGroup(tag, group).is_singleton().has_no_attributes().descend(raise_errors)
|
value['recordInfo'] = TagGroup(tag, group).is_singleton().has_no_attributes().descend(raise_errors)
|
||||||
elif tag == '{http://www.loc.gov/mods/v3}recordIdentifier':
|
elif tag == '{http://www.loc.gov/mods/v3}recordIdentifier':
|
||||||
value['recordIdentifier'] = TagGroup(tag, group).is_singleton().has_attributes({'source': 'gbv-ppn'}).text()
|
# By default we assume source="gbv-ppn" mods:recordIdentifiers (= PPNs),
|
||||||
|
# however, in mods:relatedItems, there may be source="dnb-ppns",
|
||||||
|
# which we need to distinguish by using a separate field name.
|
||||||
|
try:
|
||||||
|
value['recordIdentifier'] = TagGroup(tag, group).is_singleton().has_attributes({'source': 'gbv-ppn'}).text()
|
||||||
|
except ValueError:
|
||||||
|
value['recordIdentifier-dnb-ppn'] = TagGroup(tag, group).is_singleton().has_attributes({'source': 'dnb-ppn'}).text()
|
||||||
elif tag == '{http://www.loc.gov/mods/v3}identifier':
|
elif tag == '{http://www.loc.gov/mods/v3}identifier':
|
||||||
for e in group:
|
for e in group:
|
||||||
if len(e.attrib) != 1:
|
if len(e.attrib) != 1:
|
||||||
|
|
|
@ -138,3 +138,16 @@ def test_relatedItem():
|
||||||
""")
|
""")
|
||||||
|
|
||||||
assert d['relatedItem-original_recordInfo_recordIdentifier'] == 'PPN167755803'
|
assert d['relatedItem-original_recordInfo_recordIdentifier'] == 'PPN167755803'
|
||||||
|
|
||||||
|
# mods:relatedItem may also have source="dnb-ppn" recordIdentifiers:
|
||||||
|
d = dict_fromstring("""
|
||||||
|
<mods:mods xmlns:mods="http://www.loc.gov/mods/v3">
|
||||||
|
<mods:relatedItem type="original">
|
||||||
|
<mods:recordInfo>
|
||||||
|
<mods:recordIdentifier source="dnb-ppn">1236513355</mods:recordIdentifier>
|
||||||
|
</mods:recordInfo>
|
||||||
|
</mods:relatedItem>
|
||||||
|
</mods:mods>
|
||||||
|
""")
|
||||||
|
|
||||||
|
assert d['relatedItem-original_recordInfo_recordIdentifier-dnb-ppn'] == '1236513355'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue