[GRASS-dev] formatting expressions for r.mapcalc in GRASS6.4.3
hmitaso at ncsu.edu
Fri Mar 15 07:20:06 PDT 2013
On Mar 15, 2013, at 10:06 AM, Markus Neteler wrote:
> On Fri, Feb 15, 2013 at 2:29 PM, Glynn Clements
> <glynn at gclements.plus.com> wrote:
>> Helena Mitasova wrote:
>>>> The wxGUI command line has its own rules (see shlex.split()
>>>> in the Python library documentation).
>>> running mapcalc through the wxGUI command line is where the students have problems in winGRASS
>>> (but it works on Mac)
>> Is this on Windows?
> A guest in our group has currently the same problem:
> r.mapcalc 'test_rmap=log(abs(elec_accum)+1)'
> Under Windows it does not work with a "syntax error" message.
Markus, have you tried to run this without the quotes? Or in the mapcalculator GUI?
When we skip the quotes, all expressions that I tested worked, except for those that have the pipe symbol ||
I will try the one above today. I would love to get the mapcalc working in the command console, it is very
convenient. Currently, we run all mapcalc operations in the mapcalculator GUI, which is fine with students
who are used to run things by clicking a lot anyway, but as we get to more complex workflows with more map algebra
in-between it can get tedious.
>> gui/wxpython/core/utils.py has:
>> def split(s):
>> """!Platform spefic shlex.split"""
>> if sys.version_info >= (2, 6):
>> return shlex.split(s, posix = (sys.platform != "win32"))
>> elif sys.platform == "win32":
>> return shlex.split(s.replace('\\', r'\\'))
>> return shlex.split(s)
>> However: shlex.split(..., posix=False) will retain any quotes, while
>> posix=True removes them:
>>> shlex.split('a "b c"')
>> ['a', 'b c']
>>> shlex.split('a "b c"', posix=False)
>> ['a', '"b c"']
>> With posix=False, there doesn't appear any way to prevent splitting on
>> whitespace without also adding quotes.
>> From the above code, it appears that posix=False is used on Windows so
>> that backslash characters in filenames are treated as literal
>> backslashes rather than as escape characters. If that's the only
>> reason, then removing the "if" case may suffice.
> I don't know exactly how let our guest test that...
> grass-dev mailing list
> grass-dev at lists.osgeo.org
More information about the grass-dev