1
0
Fork 0
mirror of https://github.com/qurator-spk/modstool.git synced 2025-06-26 12:09:55 +02:00

Convert mods:relatedItem for types original and host

Fixes gh-21.
This commit is contained in:
Mike Gerber 2023-04-14 12:53:11 +02:00
parent 6d8ba871eb
commit 4e7b8ed642
2 changed files with 22 additions and 2 deletions

View file

@ -152,7 +152,15 @@ def mods_to_dict(mods, raise_errors=True):
.has_attributes({'authority': 'iso15924', 'type': 'code'}) \
.text_set()
elif tag == '{http://www.loc.gov/mods/v3}relatedItem':
pass
tag_group = TagGroup(tag, group)
for type_, grouped_group in sorted_groupby(tag_group.group, key=lambda g: g.attrib['type']):
sub_tag = 'relatedItem-{}'.format(type_)
grouped_group = list(grouped_group)
if type_ in ["original", "host"]:
value[sub_tag] = TagGroup(sub_tag, grouped_group).is_singleton().descend(raise_errors)
else:
# TODO type="series"
pass
elif tag == '{http://www.loc.gov/mods/v3}name':
for n, e in enumerate(group):
value['name{}'.format(n)] = mods_to_dict(e, raise_errors)