Exemple #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
Exemple #2
0
 def testOneLineNoIndent(self):
     self.assertEqual("x=1", tools.unindent("x=1"))
Exemple #3
0
 def testEmptyString(self):
     self.assertEqual("", tools.unindent(""))
Exemple #4
0
 def testPartiallyIndendedComment(self):
     self.assertEqual("#comment\nx=1", tools.unindent(" #comment\n   x=1"))
Exemple #5
0
 def testIgnoreComments(self):
     self.assertEqual("#comment\nx=1", tools.unindent("#comment\n   x=1"))
Exemple #6
0
 def testIgnoreEmtptyLines(self):
     self.assertEqual("\nx=1", tools.unindent("\n   x=1"))
Exemple #7
0
 def testStructurePreservedTabs(self):
     self.assertEqual("def foo():\n  x=1", tools.unindent("\tdef foo():\n\t  x=1"))
Exemple #8
0
 def testStructurePreservedSpaces(self):
     self.assertEqual("def foo():\n  x=1", tools.unindent("  def foo():\n    x=1"))
Exemple #9
0
 def testTwoLinesMixed(self):
     self.assertEqual("x=1\ny=2", tools.unindent("\tx=1\n        y=2"))
Exemple #10
0
 def testTwoLinesTabs(self):
     self.assertEqual("x=1\ny=2", tools.unindent("\tx=1\n\ty=2"))
Exemple #11
0
 def testTwoLinesSpaces(self):
     self.assertEqual("x=1\ny=2", tools.unindent("  x=1\n  y=2"))
Exemple #12
0
 def testOneLineMix(self):
     self.assertEqual("x=1", tools.unindent(" \t \t  x=1"))