simplify and do el.attrib.get('id') as per review

This commit is contained in:
Cosimo Lupo 2021-11-15 17:46:42 +00:00
parent 92470ea361
commit 12ed8b752c

View File

@ -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