1. Kirill Simonov
  2. pyyaml-legacy

Source

pyyaml-legacy / patches / stream.py.patch

--- yaml/stream.py	2002-12-26 09:53:42.000000000 -0800
+++ yaml/stream.py	2003-12-04 13:14:41.000000000 -0800
@@ -94,12 +94,15 @@
         return self.commentEater.lastLineRead()
 
     def reset(self):
         self.indentLevel = 0
         self.oldIndents = [0]
+        self.empty = 0
 
     def peek(self):
+        if self.empty:
+            return
         nextLine = self.commentEater.peek()
         if nextLine is not None:
             if indentLevel(nextLine) >= self.indentLevel:
                 return nextLine[self.indentLevel:]
             elif nextLine == '':
@@ -107,10 +110,11 @@
 
     def pop(self):
         line = self.peek()
         if line is None:
             self.indentLevel = self.oldIndents.pop()
+            self.empty = 0
             return
         self.commentEater.pop()
         return line
 
     def popNestedLines(self):
@@ -128,19 +132,20 @@
 
     def nestToNextLine(self):
         line = self.commentEater.peek()
         indentation = indentLevel(line)
         if len(self.oldIndents) > 1 and indentation <= self.indentLevel:
-            self.error("Inadequate indentation", line)
+            self.empty = 1
+            #self.error("Inadequate indentation", line)
         self.setNewIndent(indentation)
 
     def nestBySpecificAmount(self, adjust):
         self.setNewIndent(self.indentLevel + adjust)
         
     def setNewIndent(self, indentLevel):
         self.oldIndents.append(self.indentLevel)
-        self.indentLevel = indentLevel    
+        self.indentLevel = indentLevel
 
 class YamlLoaderException(Exception):
     def __init__(self, *args):
         (self.msg, self.lineNum, self.line, self.filename) = args