mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-02 05:06:23 +00:00
[[WML engine bug fixes]]
-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
This commit is contained in:
parent
5e5ab28512
commit
b2f84bdbe9
@ -175,7 +175,7 @@ Element Types:
|
||||
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 @@ Important Attributes:
|
||||
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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user