From 107ab7f6e94379b3f5b892e25cb20cdeab641fbd Mon Sep 17 00:00:00 2001 From: Xavier Bonaventura Date: Sun, 27 Dec 2020 14:40:04 +0100 Subject: [PATCH] Use list comprehension instead of extending the collection --- auto/bin/parse_xml.py | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/auto/bin/parse_xml.py b/auto/bin/parse_xml.py index 782e42c..6cbe0ec 100755 --- a/auto/bin/parse_xml.py +++ b/auto/bin/parse_xml.py @@ -43,12 +43,7 @@ def findParams(node): return ( t, n.strip()) def findEnums(dom): - ret = {} - for i in findChildren(dom, [ 'registry', 'enums', 'enum' ]): - n = i.getAttribute('name') - v = i.getAttribute('value') - ret[n] = v - return ret + return {i.getAttribute('name'): i.getAttribute('value') for i in findChildren(dom, [ 'registry', 'enums', 'enum' ])} def findCommands(dom): ret = {} @@ -62,12 +57,8 @@ def findFeatures(dom): ret = {} for i in findChildren(dom, [ 'registry', 'feature' ]): n = i.getAttribute('name') - e = [] - c = [] - for j in findChildren(i, [ 'require', 'enum' ]): - e.append(j.getAttribute("name")) - for j in findChildren(i, [ 'require', 'command' ]): - c.append(j.getAttribute("name")) + e = [j.getAttribute("name") for j in findChildren(i, [ 'require', 'enum' ])] + c = [j.getAttribute("name") for j in findChildren(i, [ 'require', 'command' ])] ret[n] = (e,c) return ret @@ -75,12 +66,8 @@ def findExtensions(dom): ret = {} for i in findChildren(dom, [ 'registry', 'extensions', 'extension' ]): n = i.getAttribute('name') - e = [] - c = [] - for j in findChildren(i, [ 'require', 'enum' ]): - e.append(j.getAttribute("name")) - for j in findChildren(i, [ 'require', 'command' ]): - c.append(j.getAttribute("name")) + e = [j.getAttribute("name") for j in findChildren(i, [ 'require', 'enum' ])] + c = [j.getAttribute("name") for j in findChildren(i, [ 'require', 'command' ])] ret[n] = (e,c) return ret