Gathering unknown option data without quitting

Allan Crooks <[email protected]> Wed, 03 May 2006 22:41:35 +0100
Newsgroups gmane.comp.python.optik.user
Message-ID <[email protected]>
Hi all,

I'm just wondering whether anyone has come across this problem and
written something to deal with it.

I've written some code which does something like this:

def setup(func):
    configure parser
    options, args = parser.parse_args()
    environment.handle(options)
    func(environment)

So the caller of the code will pass some callable object to the setup
function - the setup function then invokes the func object with the
parsed arguments.

At the moment, any command line arguments given are processed by the
setup function. However, I want the ability for command line arguments
to be given where they are intended for the function to process them. I
would like to do something like this:

def setup(func):
    configure parser
    options, args, unknown_options = parser.parse_args()
    environment.handle(options)
    func(environment, unknown_options)

At the moment, you can't pass any options intended for the func
function, since it is rejected as an unknown option for the parser
created by the setup function.

Has anyone written something to extend optik to do this? I think I could
probably write something to get what I want, but I'm just wondering
whether I could reuse existing code rather than writing something myself.

Thanks,
Allan.


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642