From 6fede3f39516c41be936fb5e4a4f8867ae56ed3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Thu, 15 Sep 2016 10:12:32 +0200 Subject: [PATCH] variants: Allow multiple explicit optional variants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a variant has optional, it is possible to explictly list it in the XML file and add extra groups. However, the original DTD did not allow multiple variants with `id="optional"` as `id` attribute has to be globally unique. This patch changes its type to `CDATA`, which has less restrictions. This also means we can no longer define `` as `IDREF` and instead check the existence of referenced variant in parser. Signed-off-by: Lubomír Sedlář --- pungi/wrappers/variants.py | 6 +++++- share/variants.dtd | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pungi/wrappers/variants.py b/pungi/wrappers/variants.py index 1c3949d3..47822014 100755 --- a/pungi/wrappers/variants.py +++ b/pungi/wrappers/variants.py @@ -150,7 +150,11 @@ class VariantsXmlParser(object): self.add_child(optional, variant) for ref in variant_node.xpath("variants/ref/@id"): - child_variant = self.parse_variant_node(self.addons[ref], variant) + try: + child_variant = self.parse_variant_node(self.addons[ref], variant) + except KeyError: + raise RuntimeError("Variant %s references non-existing variant %s" + % (variant.uid, ref)) self.add_child(child_variant, variant) # XXX: top-level optional diff --git a/share/variants.dtd b/share/variants.dtd index 49d48813..19ef3430 100644 --- a/share/variants.dtd +++ b/share/variants.dtd @@ -2,7 +2,7 @@