Hi,

is there some reason for GRASS parser not checking if the input map exists?
It checks if the output map exists and if it it does it ends execution with
an error.

Having this interface definition (full script attached):

#%option G_OPT_R_INPUT
#% key: elevation
#%end
#%option G_OPT_R_OUTPUT
#% key: aspect
#%end

I now get this:

$ r.mapcalc "aaa = 1"
$ g.list rast m=.
aaa
$ test_parser_inputs.py elevation=bbb aspect=aaa
ERROR: option <aspect>: <aaa> exists.
$ test_parser_inputs.py elevation=bbb aspect=ccc
('bbb', 'ccc') [i.e., no error]

But I would expect to get the error also in the second case:

$ test_parser_inputs.py elevation=bbb aspect=ccc
ERROR: option <elevation>: <bbb> doesn't exist.

Is there some advantage in checking the existence of the input maps and
files manually?

Vaclav
#!/usr/bin/env python

#%module
#% description: Test inputs and outputs in parser
#% keyword: test
#% keyword: raster
#%end
#%option G_OPT_R_INPUT
#% key: elevation
#%end
#%option G_OPT_R_OUTPUT
#% key: aspect
#%end


import grass.script as gscript

def main():
    options, flags = gscript.parser()
    elevation = options['elevation']
    aspect = options['aspect']
    print(elevation, aspect)

if __name__ == '__main__':
    main()
_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev

Reply via email to