simplify and do el.attrib.get('id') as per review
This commit is contained in:
parent
92470ea361
commit
12ed8b752c
@ -111,8 +111,7 @@ def subset_elements(el: etree.Element, retained_ids: Set[str]) -> bool:
|
||||
# Keep elements if their id is in the subset, or any of their children's id is.
|
||||
# Drop elements whose id is not in the subset, and either have no children,
|
||||
# or all their children are being dropped.
|
||||
el_id = el.attrib.get("id")
|
||||
if el_id is not None and el_id in retained_ids:
|
||||
if el.attrib.get("id") in retained_ids:
|
||||
# if id is in the set, don't recurse; keep whole subtree
|
||||
return True
|
||||
keep = False
|
||||
|
Loading…
x
Reference in New Issue
Block a user