summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2010-07-02 17:14:24 +0100
committerWill Thompson <will.thompson@collabora.co.uk>2010-07-06 16:22:43 +0100
commit84255c26086c5e9440a358ced3598fc0892a5923 (patch)
tree3cef2c9468092aa89a2685b0c7a83a821ee42911 /tools
parent3e10a3b03709bf755bd658427520db28cb7eb93f (diff)
Blow up if a spec contains nested rationales.
I just did this and couldn't understand what was going on.
Diffstat (limited to 'tools')
-rw-r--r--tools/specparser.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/specparser.py b/tools/specparser.py
index d23eb1bd..245b5fdc 100644
--- a/tools/specparser.py
+++ b/tools/specparser.py
@@ -42,6 +42,21 @@ class MismatchedFlagsAndEnum(Exception): pass
class TypeMismatch(Exception): pass
class MissingVersion(Exception): pass
+class Xzibit(Exception):
+ def __init__(self, parent, child):
+ self.parent = parent
+ self.child = child
+
+ def __str__(self):
+ print """
+ Nested <%s>s are forbidden.
+ Parent:
+ %s...
+ Child:
+ %s...
+ """ % (self.parent.nodeName, self.parent.toxml()[:100],
+ self.child.toxml()[:100])
+
def getText(dom):
try:
if dom.childNodes[0].nodeType == dom.TEXT_NODE:
@@ -212,6 +227,10 @@ class Base(object):
# rewrite <tp:rationale>
for n in node.getElementsByTagNameNS(XMLNS_TP, 'rationale'):
+ nested = n.getElementsByTagNameNS(XMLNS_TP, 'rationale')
+ if nested:
+ raise Xzibit(n, nested[0])
+
rationale_div = xml.dom.minidom.parseString(
"""
<div class='rationale'>