Skip to content

Commit

Permalink
format options only if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
landam committed May 31, 2024
1 parent 834a8cc commit e2ac8e7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions gui/wxpython/gmodeler/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3600,12 +3600,18 @@ def _getPythonActionCmd(self, item, task, cmdIndent, variables={}):
value = 'options["{}"]'.format(self._getParamName(name, item))
else:
# check for variables
formattedVar = False
for var in variables["vars"]:
pattern = re.compile("%" + var)
if pattern.search(value):
found = pattern.search(value)
if found:
foundVar = True
value = pattern.sub("{options['" + var + "']}", value)
if foundVar:
if found.end() != len(value):
formattedVar = True
value = pattern.sub("{options['" + var + "']}", value)
else:
value = f"options['{var}']"
if formattedVar:
value = 'f"' + value + '"'

if (
Expand Down

0 comments on commit e2ac8e7

Please sign in to comment.