Store the parsed variants for possible later re-use

Merges: https://pagure.io/pungi/pull-request/1257
Signed-off-by: Pat Riehecky <riehecky@fnal.gov>
This commit is contained in:
Pat Riehecky 2019-08-19 11:15:49 -05:00 committed by Lubomír Sedlář
parent b420986aa4
commit a99bf8c828

View File

@ -60,6 +60,7 @@ class VariantsXmlParser(object):
with open(get_variants_dtd(logger), 'r') as f: with open(get_variants_dtd(logger), 'r') as f:
self.dtd = lxml.etree.DTD(f) self.dtd = lxml.etree.DTD(f)
self.addons = {} self.addons = {}
self.variants = {}
self.layered_products = {} self.layered_products = {}
self.tree_arches = tree_arches self.tree_arches = tree_arches
self.tree_variants = tree_variants self.tree_variants = tree_variants
@ -228,14 +229,13 @@ class VariantsXmlParser(object):
variant_id = str(variant_node.attrib["id"]) variant_id = str(variant_node.attrib["id"])
self.addons[variant_id] = variant_node self.addons[variant_id] = variant_node
result = {}
for variant_node in self.tree.xpath("/variants/variant[@type='variant']"): for variant_node in self.tree.xpath("/variants/variant[@type='variant']"):
variant = self.parse_variant_node(variant_node) variant = self.parse_variant_node(variant_node)
if not variant or self._is_excluded(variant): if not variant or self._is_excluded(variant):
continue continue
result[variant.id] = variant self.variants[variant.id] = variant
return result return self.variants
class Variant(object): class Variant(object):