Tavmjong Bah wrote:
Could you take a look at the Function Plotter effect? It has got lots of problems which I can't figure out (it was working at the beginning of 0.46 development). It seems to me that all the parameters on the Range and Sampling tab are not working.
It appears to be a problem the command line parsing. The command line passed to the script looks sorta like like (from ' '.join(sys.argv)):
share\extensions\funcplot.py C:\DOCUME~1\NS\LOCALS~1\Temp\ink_ext_XXXXXX.svgVNX14T --id=rect2363 --tab="sampling" --xstart=-50 --xend=20 --times2pi=true --ybottom=-11.600000381469727 --ytop=24.600000381469727 --samples=180 --isoscale=false --polar=false --funcplotuse= --pythonfunctions= --fofx=sin(-x) --fponum=true --fpofx=x --remove=true --drawaxis=false
But Python parses it as:
['share\extensions\funcplot.py', 'C:\DOCUME~1\NS\LOCALS~1\Temp\ink_ext_XXXXXX.svgVNX14T', '--id=rect2363', '--tab="sampling" --xstart=-50 --xend=20 --times2pi=true --ybottom=-11.600000381469727 --ytop=24.600000381469727 --samples=180 --isoscale=false --polar=false --funcplotuse= --pythonfunctions=', '--fofx=sin(-x)', '--fponum=true', '--fpofx=x', '--remove=true', '--drawaxis=false']
And then optparse gets:
{'polar': False, 'ytop': 1.0, 'funcplotuse': '', 'drawaxis': False, 'fpofx': 'x', 'ybottom': -1.0, 'ids': ['rect2363'], 'remove': True, 'fofx': 'sin(-x)', 'pythonfunctions': '', 'isoscale': True, 'fponum': True, 'tab': '"sampling" --xstart=-50 --xend=20 --times2pi=true --ybottom=-11.600000381469727 --ytop=24.600000381469727 --samples=180 --isoscale=false --polar=false --funcplotuse= --pythonfunctions=', 'xstart': 0.0, 'xend': 1.0, 'times2pi': True, 'samples': 8}
But I think we need to put debug prints in Inkscape to see what the actual command line is that inkscape generates because when I give the same command line options to a simple python script like:
import sys print sys.argv
I get a properly parsed command line:
C:\Documents and Settings\NS\Desktop>cmd_parsing_test.py C:\DOCUME~1\NS\LOCALS~1\Temp\ink_ext_XXXXXX.svgVNX14T --id=rect2363 --tab="sampling" --xstart=-50 --xend=20 --times2pi=true --ybottom=-11.600000381469727 --ytop=24.600000381469727 --samples=180 --isoscale=false --polar=false --funcplotuse= --pythonfunctions= --fofx=sin(-x) --fponum=true --fpofx=x --remove=true --drawaxis=false ['C:\Documents and Settings\NS\Desktop\cmd_parsing_test.py', 'C:\DOCUME~1\NS\LOCALS~1\Temp\ink_ext_XXXXXX.svgVNX14T', '--id=rect2363 ', '--tab=sampling', '--xstart=-50', '--xend=20', '--times2pi=true', '--ybottom=-11.600000381469727', '--ytop=24.600000381469727', '--samples =180', '--isoscale=false', '--polar=false', '--funcplotuse=', '--pythonfunctions=', '--fofx=sin(-x)', '--fponum=true', '--fpofx=x', '--remove =true', '--drawaxis=false']
There must be some stray quotes somewhere. I also wonder why the temporary file is no longer the final argument to the script. I think this could screw up scripts with more primitive option parsing. It looks like the revision that I compiled here includes the .svg extension on the temp files. I never noticed that change. And lastly, can anyone tell me why "sampling" is quoted when it is passed to the script? I thought we had done something to address that.
Aaron Spike