[z3-checkins] r51657 - z3/deliverance/trunk/deliverance

ianb at codespeak.net ianb at codespeak.net
Tue Feb 19 23:19:59 CET 2008


Author: ianb
Date: Tue Feb 19 23:19:58 2008
New Revision: 51657

Modified:
   z3/deliverance/trunk/deliverance/interpreter.py
   z3/deliverance/trunk/deliverance/utils.py
   z3/deliverance/trunk/deliverance/xslt.py
Log:
Keep xmlns out of places where rules are printed for debugging (error reports, comments).  Not sure when the xmlns snuck in

Modified: z3/deliverance/trunk/deliverance/interpreter.py
==============================================================================
--- z3/deliverance/trunk/deliverance/interpreter.py	(original)
+++ z3/deliverance/trunk/deliverance/interpreter.py	Tue Feb 19 23:19:58 2008
@@ -4,6 +4,7 @@
 from deliverance import utils
 from deliverance.utils import RuleSyntaxError
 from deliverance.utils import RendererBase
+from deliverance.utils import rule_tostring
 
 class Renderer(RendererBase):
     """
@@ -119,7 +120,7 @@
         else:
             raise RuleSyntaxError(
                 "Rule %s (%s) not understood" % (
-                    rule.tag, etree.tostring(rule)))
+                    rule.tag, rule_tostring(rule)))
 
         # process possible "move" attribute 
         self.check_move(rule, theme, content)
@@ -487,6 +488,6 @@
         returns a pair of comments for insertion before and 
         after work done by the rule given during debugging. 
         """
-        comment_before = etree.Comment("Deliverance: applying rule %s" % etree.tostring(rule))
-        comment_after = etree.Comment("Deliverance: done applying rule %s" % etree.tostring(rule))
+        comment_before = etree.Comment("Deliverance: applying rule %s" % rule_tostring(rule))
+        comment_after = etree.Comment("Deliverance: done applying rule %s" % rule_tostring(rule))
         return comment_before, comment_after

Modified: z3/deliverance/trunk/deliverance/utils.py
==============================================================================
--- z3/deliverance/trunk/deliverance/utils.py	(original)
+++ z3/deliverance/trunk/deliverance/utils.py	Tue Feb 19 23:19:58 2008
@@ -128,7 +128,7 @@
         d.attrib['class'] = 'deliverance-error'
         d.text = 'Deliverance error: %s' % message
         br = etree.Element('br')
-        br.tail = 'rule: %s' % etree.tostring(rule)
+        br.tail = 'rule: %s' % rule_tostring(rule)
         d.append(br)
         if elts:
             d.append(etree.Element('br'))
@@ -525,4 +525,13 @@
 
         return new_xpath
 
-
+def rule_tostring(rule, include_xmlns=False):
+    """
+    Convert a rule back to a string
+    """
+    if include_xmlns:
+        return etree.tostring(rule)
+    else:
+        text = etree.tostring(rule)
+        text = text.replace(' xmlns="http://www.plone.org/deliverance"', '')
+        return text

Modified: z3/deliverance/trunk/deliverance/xslt.py
==============================================================================
--- z3/deliverance/trunk/deliverance/xslt.py	(original)
+++ z3/deliverance/trunk/deliverance/xslt.py	Tue Feb 19 23:19:58 2008
@@ -5,6 +5,7 @@
 from deliverance import utils
 from deliverance.utils import RuleSyntaxError
 from deliverance.utils import RendererBase
+from deliverance.utils import rule_tostring
 
 
 xslt_wrapper_skel = """
@@ -425,9 +426,9 @@
         for wrapping inserted content nodes during debugging
         """
         comment_before = etree.Element("{%s}comment" % nsmap["xsl"])
-        comment_before.text = "Deliverance: applying rule %s" % etree.tostring(rule)
+        comment_before.text = "Deliverance: applying rule %s" % rule_tostring(rule)
         comment_after = etree.Element("{%s}comment" % nsmap["xsl"])
-        comment_after.text = "Deliverance: done applying rule %s" % etree.tostring(rule)
+        comment_after.text = "Deliverance: done applying rule %s" % rule_tostring(rule)
         return comment_before, comment_after
 
 


More information about the z3-checkins mailing list