[Checkins] SVN: Sandbox/malthe/chameleon.core/ Added label property to expressions, allowing better debugging information.

Malthe Borch mborch at gmail.com
Wed Nov 19 08:18:12 EST 2008


Log message for revision 93132:
  Added label property to expressions, allowing better debugging information.

Changed:
  U   Sandbox/malthe/chameleon.core/CHANGES.txt
  U   Sandbox/malthe/chameleon.core/src/chameleon/core/generation.py
  U   Sandbox/malthe/chameleon.core/src/chameleon/core/translation.py
  U   Sandbox/malthe/chameleon.core/src/chameleon/core/types.py

-=-
Modified: Sandbox/malthe/chameleon.core/CHANGES.txt
===================================================================
--- Sandbox/malthe/chameleon.core/CHANGES.txt	2008-11-19 11:58:11 UTC (rev 93131)
+++ Sandbox/malthe/chameleon.core/CHANGES.txt	2008-11-19 13:18:12 UTC (rev 93132)
@@ -4,6 +4,10 @@
 HEAD
 ~~~~
 
+- Added ``label`` property to expressions; this allows providing a
+  human-readable label for values that are going to
+  evaluated. [malthe]
+
 - Normalize METAL slot names to ensure they're valid Python variable
   names. Non-valid characters are converted to underscore. [malthe]
 

Modified: Sandbox/malthe/chameleon.core/src/chameleon/core/generation.py
===================================================================
--- Sandbox/malthe/chameleon.core/src/chameleon/core/generation.py	2008-11-19 11:58:11 UTC (rev 93131)
+++ Sandbox/malthe/chameleon.core/src/chameleon/core/generation.py	2008-11-19 13:18:12 UTC (rev 93132)
@@ -116,8 +116,10 @@
             self.cook()
             self.indentation -= amount
 
-    def annotate(self, item):
-        self.annotation = self.annotations[self.l_counter] = item
+    def annotate(self, annotation):
+        if annotation.label is not None:
+            annotation = annotation.label
+        self.annotation = self.annotations[self.l_counter] = annotation
 
     def out(self, string):
         if isinstance(string, unicode) and self.encoding:

Modified: Sandbox/malthe/chameleon.core/src/chameleon/core/translation.py
===================================================================
--- Sandbox/malthe/chameleon.core/src/chameleon/core/translation.py	2008-11-19 11:58:11 UTC (rev 93131)
+++ Sandbox/malthe/chameleon.core/src/chameleon/core/translation.py	2008-11-19 13:18:12 UTC (rev 93132)
@@ -363,8 +363,10 @@
                       itertools.chain(*self.stream.scope))+
                 tuple("%s=%s" % kwarg for kwarg in kwargs))
 
-            _.append(clauses.Write(
-                types.value("%s.render(%s)" % (self.symbols.metal, arguments))))
+            value = types.value(
+                "%s.render(%s)" % (self.symbols.metal, arguments))
+            value.label = self.use_macro.label
+            _.append(clauses.Write(value))
 
         # translate body
         elif self.translate is not None:

Modified: Sandbox/malthe/chameleon.core/src/chameleon/core/types.py
===================================================================
--- Sandbox/malthe/chameleon.core/src/chameleon/core/types.py	2008-11-19 11:58:11 UTC (rev 93131)
+++ Sandbox/malthe/chameleon.core/src/chameleon/core/types.py	2008-11-19 13:18:12 UTC (rev 93132)
@@ -1,8 +1,9 @@
 from utils import emptydict
 
 class expression:
+    label = None
     symbol_mapping = emptydict()
-
+    
 class parts(tuple, expression):
     def __repr__(self):
         return 'parts'+tuple.__repr__(self)
@@ -11,7 +12,7 @@
     def __init__(self, *args):
         super(value, self).__init__()
         self.symbol_mapping = {}
-
+        
     def __repr__(self):
         try:
             r = repr(self.encode())



More information about the Checkins mailing list