You are not logged in.

#1 2009-05-21 02:55:16

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Opterator -- taking the boilerplate out of python option parsing

Hey guys,

I've been tossing around this idea for option parsing since attending pycon and finally got around to implementing it. Its the first time I've had a lot of fun coding in a while.

What it does is allow you to create command-line option parsing based on the function signature and docstring of a main method. I could describe it all here, but instead I refer you to the readme and a blog post I wrote:

http://archlinux.me/dusty/2009/05/20/in … opterator/
http://github.com/buchuki/opterator/tree/master

actually here's one example, for those of you like me who think clicking links is work:

from opterator import opterate
@opterate
def main(filename1, filename2, recursive=False, backup=False,
        suffix='~', *other_filenames):
    '''An example copy script with some example parameters that might
    be used in a copy command.
 
    @param recursive store_true -r --recursive copy directories
        recursively
    @param backup store_true -b --backup backup any files you copy over
    @param suffix store -S --suffix override the usual backup
        suffix '''
    # implementation here

Now you saw the example, so you probably want to see how the output looks and how the help text looks for that... now you're going to click the link.

Dusty

Offline

#2 2009-05-21 09:28:08

madhatter
Member
From: Freudenstadt, Germany
Registered: 2004-09-01
Posts: 59

Re: Opterator -- taking the boilerplate out of python option parsing

I had a similar idea a while ago, I have a simple (very crappy) implementation around - I never actually did anything with it, but here it is: http://pastebin.com/f732ff51f

Offline

#3 2009-05-21 09:44:29

Mr.Cat
Member
Registered: 2008-09-27
Posts: 79

Re: Opterator -- taking the boilerplate out of python option parsing

Nice idea.

Offline

Board footer

Powered by FluxBB