Example #1
0
 def parse(self, src):
     if src not in self.cache:
         src = tools.unindent(src)
         node = ast.parse(src)
         lenatu.augment(node)
         self.cache[src] = node
     else:
         node = self.cache[src]
     return node
Example #2
0
 def testOneLineNoIndent(self):
     self.assertEqual("x=1", tools.unindent("x=1"))
Example #3
0
 def testEmptyString(self):
     self.assertEqual("", tools.unindent(""))
Example #4
0
 def testPartiallyIndendedComment(self):
     self.assertEqual("#comment\nx=1", tools.unindent(" #comment\n   x=1"))
Example #5
0
 def testIgnoreComments(self):
     self.assertEqual("#comment\nx=1", tools.unindent("#comment\n   x=1"))
Example #6
0
 def testIgnoreEmtptyLines(self):
     self.assertEqual("\nx=1", tools.unindent("\n   x=1"))
Example #7
0
 def testStructurePreservedTabs(self):
     self.assertEqual("def foo():\n  x=1", tools.unindent("\tdef foo():\n\t  x=1"))
Example #8
0
 def testStructurePreservedSpaces(self):
     self.assertEqual("def foo():\n  x=1", tools.unindent("  def foo():\n    x=1"))
Example #9
0
 def testTwoLinesMixed(self):
     self.assertEqual("x=1\ny=2", tools.unindent("\tx=1\n        y=2"))
Example #10
0
 def testTwoLinesTabs(self):
     self.assertEqual("x=1\ny=2", tools.unindent("\tx=1\n\ty=2"))
Example #11
0
 def testTwoLinesSpaces(self):
     self.assertEqual("x=1\ny=2", tools.unindent("  x=1\n  y=2"))
Example #12
0
 def testOneLineMix(self):
     self.assertEqual("x=1", tools.unindent(" \t \t  x=1"))