mail[Wesnoth-commits] r20216 - /trunk/data/tools/wesnoth/wmliterator.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by patrick_X99 on September 09, 2007 - 08:28:
Author: sapient
Date: Sun Sep  9 08:27:41 2007
New Revision: 20216

URL: http://svn.gna.org/viewcvs/wesnoth?rev=20216&view=rev
Log:
misc. minor fixes

Modified:
    trunk/data/tools/wesnoth/wmliterator.py

Modified: trunk/data/tools/wesnoth/wmliterator.py
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/wesnoth/wmliterator.py?rev=20216&r1=20215&r2=20216&view=diff
==============================================================================
--- trunk/data/tools/wesnoth/wmliterator.py (original)
+++ trunk/data/tools/wesnoth/wmliterator.py Sun Sep  9 08:27:41 2007
@@ -130,7 +130,7 @@
             elif scopes:
                 scopes.pop()
             else:
-                print >>sys.stderr, 'wmliterator: attempt to close empty 
scope at '+elementType
+                print >>sys.stderr, 'wmliterator: attempt to close empty 
scope at', elementType, 'line', lineno
             scopeDelta += 1
         while scopeDelta > 0:
             openedScopes.append((elementType, lineno))
@@ -148,6 +148,7 @@
         self.lines = lines
         self.endScope = None
         self.end = len(lines)
+        self.reset()
         self.seek(begin)
         self.endScope = endScope
 
@@ -155,16 +156,20 @@
         """The magic iterator method"""
         return self
 
+    def reset(self):
+        """reset any line tracking information to defaults"""
+        self.lineno = -1
+        self.scopes = []
+        self.nextScopes = []
+        self.text = ""
+        self.span = 1
+        self.element = ""
+        
     def seek(self, lineno):
         """Move the iterator to a specific line number"""
-        if lineno < 0 or lineno < self.lineno:
-            # moving backwards or to the beginning forces a reset
-            self.lineno = -1
-            self.scopes = []
-            self.nextScopes = []
-            self.text = ""
-            self.span = 1
-            self.element = ""
+        if lineno < self.lineno:
+        # moving backwards forces a reset
+            self.reset()
         while self.lineno + self.span - 1 < lineno:
             self.next()
 




Related Messages


Powered by MHonArc, Updated Sun Sep 09 08:40:23 2007