From 3d0fae6cffd83c7a8d385ebf3d7100cdba8ceef9 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 29 Jul 2019 11:46:30 +1000 Subject: [PATCH] data: de-duplicate the svg element search Signed-off-by: Peter Hutterer --- data/svgs/check-svg.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/svgs/check-svg.py b/data/svgs/check-svg.py index f62ccea..587d220 100755 --- a/data/svgs/check-svg.py +++ b/data/svgs/check-svg.py @@ -60,9 +60,9 @@ def check_elements(root, prefix, required=0): # elements can be paths and rects # This includes leaders and lines - element_ids = [p.attrib['id'] for p in root.xpath('//svg:path', namespaces=ns) if p.attrib['id'].startswith(prefix)] - element_ids += [p.attrib['id'] for p in root.xpath('//svg:rect', namespaces=ns) if p.attrib['id'].startswith(prefix)] - element_ids += [g.attrib['id'] for g in root.xpath('//svg:g', namespaces=ns) if g.attrib['id'].startswith(prefix)] + element_ids = [] + for element in ['path', 'rect', 'g']: + element_ids += [p.attrib['id'] for p in root.xpath('//svg:{}'.format(element), namespaces=ns) if p.attrib['id'].startswith(prefix)] idx = 0 highest = -1