[GRASS-user] info: overwrite option in r.mask

I just wanted to inform you (developers), but the overwrite option
in r.mask is somehow different from the other modules.

Especially if it comes to python scripts usually the
overwrite option is set with "overwrite=True" but for
r.mask it has to be set with a flag like "flags="o"".

I don't know if this is intended (probably because of the
second option "r" (remove existing mask)).

cheers
/johannes
--
GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit
gratis Handy-Flat! http://portal.gmx.net/de/go/dsl

Hi,

2011/4/27 Johannes Radinger <JRadinger@gmx.at>:

I just wanted to inform you (developers), but the overwrite option
in r.mask is somehow different from the other modules.

Especially if it comes to python scripts usually the
overwrite option is set with "overwrite=True" but for
r.mask it has to be set with a flag like "flags="o"".

this flag (o) has been already removed in GRASS 7 and replaced by
`--overwrite`. There is just small bug - the parser doesn't note
--overwrite flag.

Martin

--
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa

Martin Landa wrote:

> I just wanted to inform you (developers), but the overwrite option
> in r.mask is somehow different from the other modules.
>
> Especially if it comes to python scripts usually the
> overwrite option is set with "overwrite=True" but for
> r.mask it has to be set with a flag like "flags="o"".

this flag (o) has been already removed in GRASS 7 and replaced by
`--overwrite`. There is just small bug - the parser doesn't note
--overwrite flag.

It seems to work for me. Taking r.mask.py and changing the main()
function to just:

  def main():
      print grass.overwrite()

results in it printing "True" if --o is given or if the
GRASS_OVERWRITE environment variable is set, and "False" otherwise.

r.mask.py checks whether MASK exists. If it does, it aborts with a
fatal error if grass.overwrite() is false.

The mechanism is as follows:

1. G_parser() sets GRASS_OVERWRITE if the --o flag is used, so that
the setting is inherited by any child processes.
[check_overwrite(), lib/gis/parser.c:1302]

2. If g.parser is run without the -s flag, it executes the script, and
the script will inherit all environment variables.
[reinvoke_script(), general/g.parser/main.c:366]

3. If g.parser is run with the -s flag, it writes all option values to
stdout. The values of the GRASS_OVERWRITE and GRASS_VERBOSE
environment variables are included in the output.
[print_options(), general/g.parser/main.c:292 and 295]

4. The Python grass.script.parser() function recognises these settings
and adds them to the environment.
[_parse_opts(), lib/python/core.py:408]

--
Glynn Clements <glynn@gclements.plus.com>