Author: sapient
Date: Sat Nov  1 16:46:42 2008
New Revision: 30497

URL: http://svn.gna.org/viewcvs/wesnoth?rev=30497&view=rev
Log:
-fix typo in return statement for ifndef scope element
-remove default function parameter lines=[] (do not use mutable objects as 
default parameters since they will be cached and mutated across multiple calls)
-add simple error checking when opening files

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=30497&r1=30496&r2=30497&view=diff
==============================================================================
--- trunk/data/tools/wesnoth/wmliterator.py (original)
+++ trunk/data/tools/wesnoth/wmliterator.py Sat Nov  1 16:46:42 2008
@@ -175,7 +175,7 @@
     if text.startswith('#ifdef'):
         return (['#ifdef'],)*2
     elif text.startswith('#ifndef'):
-        return (['#ifdef'],)*2
+        return (['#ifndef'],)*2
     elif text.startswith('#else'):
         if not closeScope(scopes, '#else', fname, lineno):
             printScopeError('#else', fname, lineno)
@@ -247,12 +247,17 @@
            always 1, unless text contains a multi-line quoted string
     lineno - a zero-based line index marking where this text begins
     """
-    def __init__(self, lines=[], filename=None, begin=-1, endScope=None):
+    def __init__(self, lines=None, filename=None, begin=-1, endScope=None):
         "Initialize a new WmlIterator."
-        if not lines and filename:
-            ifp = open(filename)
-            lines = ifp.readlines()
-            ifp.close()
+        if lines is None:
+            lines = []
+            if filename:
+                try:
+                    ifp = open(filename)
+                    lines = ifp.readlines()
+                    ifp.close()
+                except Exception:
+                    printError(filename, 'error opening file')
         self.lines = lines
         self.fname = filename
         self.reset()


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to