let me explain what I have in mind to do in order to give you some context. I have a bunch of python scripts ( that use argpars or optpars ) and their outputs can be usually on the consolle in json, plaint text or csv format.
I would like to build an webapp ( angular + node for instance) that generates automatically a web page for each of my script including some input box for any of the argument needed by the python script in order to run them form the UI.
I do not want to write, for each python script, the list and type of arguments that they needs to be run, but I am looking for an automatic way to extract such list form each python script itself.
I can try to parse the -h output for each of the script or parse the script itself ( add_option) but it maybe error prone.
Are you aware of any tools/script/module that allow me to do it automatically?
Thanks a lot.
The inspect
module will help here:
>>> import inspect
>>> def example_function(a, b, c=1234):
pass
>>> inspect.getargspec(example_function)
ArgSpec(args=['a', 'b', 'c'], varargs=None, keywords=None, defaults=(1234,))