[GRASS-SVN] r48934 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Oct 25 09:35:35 EDT 2011
Author: martinl
Date: 2011-10-25 06:35:35 -0700 (Tue, 25 Oct 2011)
New Revision: 48934
Modified:
grass/trunk/gui/wxpython/gui_modules/gmodeler.py
Log:
wxGUI/modeler: improve validity check (variable substitution)
Modified: grass/trunk/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gmodeler.py 2011-10-25 13:02:05 UTC (rev 48933)
+++ grass/trunk/gui/wxpython/gui_modules/gmodeler.py 2011-10-25 13:35:35 UTC (rev 48934)
@@ -392,6 +392,8 @@
"""!Validate model, return None if model is valid otherwise
error string"""
errList = list()
+
+ pattern = re.compile(r'(.*)(%.+\s?)(.*)')
for action in self.GetItems(objType = ModelAction):
cmd = action.GetLog(string = False, substitute = True)
@@ -402,8 +404,16 @@
if '=' not in opt:
continue
key, value = opt.split('=', 1)
- if '%' in value:
- errList.append(_("%s: undefined variable '%s'") % (cmd[0], value.strip()))
+ sval = pattern.search(value)
+ if sval:
+ var = sval.group(2).strip()[1:] # ignore '%'
+ report = True
+ for item in filter(lambda x: isinstance(x, ModelLoop), action.GetBlock()):
+ if var in item.GetText():
+ report = False
+ break
+ if report:
+ errList.append(_("%s: undefined variable '%s'") % (cmd[0], var))
return errList
@@ -4862,7 +4872,7 @@
variables = self.model.GetVariables()
cond = item.GetText()
for variable in variables:
- pattern= re.compile('%' + variable)
+ pattern = re.compile('%' + variable)
if pattern.search(cond):
value = variables[variable].get('value', '')
if variables[variable].get('type', 'string') == 'string':
More information about the grass-commit
mailing list