[GRASS-dev] formatting expressions for r.mapcalc in GRASS6.4.3

Markus Neteler neteler at osgeo.org
Fri Mar 15 07:06:31 PDT 2013


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.

> 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'\\'))
>             else:
>                 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...

Markus


More information about the grass-dev mailing list