mirror of
https://github.com/qurator-spk/modstool.git
synced 2025-06-09 03:40:01 +02:00
✨ ALTO: Add Layout/Page's attribute values
This commit is contained in:
parent
102b15ffa9
commit
c9737683b1
2 changed files with 17 additions and 1 deletions
|
@ -53,7 +53,10 @@ def alto_to_dict(alto, raise_errors=True):
|
|||
elif tag == '{http://www.loc.gov/standards/alto/ns-v2#}softwareVersion':
|
||||
value['softwareVersion'] = TagGroup(tag, group).is_singleton().has_no_attributes().text()
|
||||
elif tag == '{http://www.loc.gov/standards/alto/ns-v2#}Layout':
|
||||
pass # TODO
|
||||
value['Layout'] = TagGroup(tag, group).is_singleton().has_no_attributes().descend(raise_errors)
|
||||
elif tag == '{http://www.loc.gov/standards/alto/ns-v2#}Page':
|
||||
value['Page'] = TagGroup(tag, group).is_singleton().attributes()
|
||||
# TODO subelements
|
||||
elif tag == '{http://www.loc.gov/standards/alto/ns-v2#}Styles':
|
||||
pass
|
||||
else:
|
||||
|
|
|
@ -181,6 +181,19 @@ class TagGroup:
|
|||
value[sub_tag] = s
|
||||
return value
|
||||
|
||||
def attributes(self):
|
||||
"""
|
||||
Return a merged dict of all attributes of the tag group.
|
||||
|
||||
Probably most useful if used on a singleton, for example:
|
||||
|
||||
value['Page'] = TagGroup(tag, group).is_singleton().attributes()
|
||||
"""
|
||||
attrib = {}
|
||||
for e in self.group:
|
||||
attrib.update(e.attrib)
|
||||
return attrib
|
||||
|
||||
|
||||
def sorted_groupby(iterable, key=None):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue