1. Ben Trofatter
  2. mako-197

Commits

bentrofatter  committed 2b83332 Draft

Debugging statements abound. Will be removing all of them.

  • Participants
  • Parent commits f2d1989
  • Branches default

Comments (0)

Files changed (4)

File mako/codegen.py

View file
 
         self.write_variable_declares(self.identifiers, toplevel=True)
 
+        #print "".join(self.printer.stream.data)
         for n in self.node.nodes:
+        #    print "-"*80
+        #    print n
             n.accept_visitor(self)
+        #print "="*80
+        #print "".join(self.printer.stream.data)
 
         self.write_def_finish(self.node, buffered, filtered, cached)
         self.printer.writeline(None)

File mako/lexer.py

View file
         if self.control_line:
             control_frame = self.control_line[-1]
             control_frame.nodes.append(node)
+            print "Control Line:", self.control_line
+            print "Node:", node
+            print "Ternary stack before append:", self.ternary_stack
             if not (isinstance(node, parsetree.ControlLine) and
                     control_frame.is_ternary(node.keyword)):
                 if self.ternary_stack and self.ternary_stack[-1]:
                     self.ternary_stack[-1][-1].nodes.append(node)
+                    print "-"*80
+                    print "Ternary stack after append:", self.ternary_stack
         if isinstance(node, parsetree.Tag):
             if len(self.tag):
                 node.parent = self.tag[-1]
             self.tag.append(node)
         elif isinstance(node, parsetree.ControlLine):
+            print "Node.isend", node.isend
+            print "Node.is_primary", node.is_primary
             if node.isend:
                 self.control_line.pop()
                 self.ternary_stack.pop()
                           "Keyword '%s' not a legal ternary for keyword '%s'" %
                           (node.keyword, self.control_line[-1].keyword),
                           **self.exception_kwargs)
+            print "="*80
 
     _coding_re = re.compile(r'#.*coding[:=]\s*([-\w.]+).*\r?\n')
 

File mako/parsetree.py

View file
 
         return keyword in {
             'if':set(['else', 'elif']),
-            'try':set(['except', 'finally']),
+            'try':set(['except', 'else', 'finally']),
             'for':set(['else'])
         }.get(self.keyword, [])
 

File test_tryelse.py

View file
+from mako.template import Template
+
+text = """
+% for i in range(2):
+  % try:
+    <% v = l[i] %>
+  % except IndexError:
+    Couldn't get index ${i}.
+  % else:
+    Found ${v} at index ${i}.
+  % endtry
+% endfor
+"""
+#  % finally:
+#   Done checking index ${i}.
+
+templ = Template(text=text)
+
+print templ.code