[GRASS-user] problems with gparser-options in python-script

2012-05-03 Thread Johannes Radinger
Hi,

I have some questions concerning the behaviour of gparser.
In the attachment you can find a example-python-script.

Somehow the output from gparser for X (see script) is strange: I try
to use it in a if-command but somehow I fail.
The output when X is set to 'A a' should be a juhuu but it isn't.
I was looking for the bug in my code but somehow I couldn't find it.
When I  replace the options for X with A,B and C (single Letters), it
seems to work...Is there a problem with spaces in the options of gparser?

I am working on GRASS6.5SVN on Mac OS X 10.6.8.

Can anyone try the script and reproduce the error? Does anyone have ideas where 
the problem in the script is located?

Thank you for your help.

Best regards,

Johannes


-- 
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!  

Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a
#!/usr/bin/env python
#

#
# MODULE:		test
#
# AUTHOR(S):	Johannes Radinger
#
# VERSION:		V1.0 Beta
#
# DATE:			2011-05-12
#
#
#%Option
#% key: X
#% type: string
#% required: no
#% multiple: no
#% key_desc: name
#% description: ABC
#% options: A a,B b,C c
#% answer: B b
#%end


# import required base modules
import sys
import os


# import required grass modules
import grass.script as grass


def main():
	
	X = str(options['X'])
	#X = 'A a'
	print X
	print type(X)
	if X is 'A a':
		print juh
		sys.stdout.flush()


if __name__ == __main__:
	options, flags = grass.parser()
	sys.exit(main())
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] problems with gparser-options in python-script

2012-05-03 Thread Glynn Clements

Johannes Radinger wrote:

 I have some questions concerning the behaviour of gparser.
 In the attachment you can find a example-python-script.
 
 Somehow the output from gparser for X (see script) is strange: I try
 to use it in a if-command but somehow I fail.
 The output when X is set to 'A a' should be a juhuu but it isn't.
 I was looking for the bug in my code but somehow I couldn't find it.
 When I  replace the options for X with A,B and C (single Letters), it
 seems to work...Is there a problem with spaces in the options of gparser?
 
 I am working on GRASS6.5SVN on Mac OS X 10.6.8.
 
 Can anyone try the script and reproduce the error? Does anyone have
 ideas where the problem in the script is located?

In 7.0, it fails because upper-case letters are not valid in option
names, so it interprets an argument of the form 'X=A a' as an answer
to the first option, i.e. equivalent to 'X=X=A a'.

I don't know why it would fail in 6.x.

-- 
Glynn Clements gl...@gclements.plus.com
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user