Fwd: ANNOUNCE: Optik 1.4 released
Robert Olson
olson at mcs.anl.gov
Mon Oct 14 09:31:27 CDT 2002
fyi, argparsing for python. I think this is a package that's going to
become part of the python standard library.
--bob
>Path: news.baymountain.net!not-for-mail
>From: Greg Ward <gward at python.net>
>Newsgroups: comp.lang.python.announce
>Subject: ANNOUNCE: Optik 1.4 released
>Organization: None
>Lines: 109
>NNTP-Posting-Host: mail.python.org
>X-Trace: news.baymountain.net 1034603230 27059 12.155.117.29 (14 Oct 2002
>13:47:10 GMT)
>X-Complaints-To: abuse at baymountain.net
>NNTP-Posting-Date: 14 Oct 2002 13:47:10 GMT
>Mail-Followup-To: optik-users at lists.sourceforge.net,
> python-announce at python.org
>User-Agent: Mutt/1.4i
>X-Spam-Status: No, hits=-2.5 required=5.0
>tests=BODY_PYTHON_ZOPE,LINES_OF_YELLING
>X-Spam-Level:
>X-BeenThere: clpa-moderators at python.org
>X-Mailman-Version: 2.0.13 (101270)
>X-BeenThere: clpa-moderators at python.org
>X-Original-To: optik-users at lists.sourceforge.net
>X-Original-To: python-announce at python.org
>Xref: news.baymountain.net comp.lang.python.announce:2000
>To: python-announce-list at python.org
>Sender: python-announce-list-admin at python.org
>X-BeenThere: python-announce-list at python.org
>List-Help: <mailto:python-announce-list-request at python.org?subject=help>
>List-Post: <mailto:python-announce-list at python.org>
>List-Subscribe:
><http://mail.python.org/mailman/listinfo/python-announce-list>,
> <mailto:python-announce-list-request at python.org?subject=subscribe>
>List-Id: Announcement-only list for the Python programming language
><python-announce-list.python.org>
>List-Unsubscribe:
><http://mail.python.org/mailman/listinfo/python-announce-list>,
> <mailto:python-announce-list-request at python.org?subject=unsubscribe>
>List-Archive: <http://mail.python.org/pipermail/python-announce-list/>
>Date: Sat, 12 Oct 2002 21:17:59 -0400
>
>Optik 1.4
>=========
>
>Optik is a powerful, flexible, extensible, easy-to-use command-line
>parsing library for Python. Using Optik, you can add intelligent,
>sophisticated handling of command-line options to your scripts with very
>little overhead.
>
>Here's an example of using Optik to add some command-line options to a
>simple script:
>
> from optik import OptionParser
> [...]
> parser = OptionParser()
> parser.add_option("-f", "--file",
> action="store", type="string", dest="filename",
> help="write report to FILE", metavar="FILE")
> parser.add_option("-q", "--quiet",
> action="store_false", dest="verbose", default=1,
> help="don't print status messages to stdout")
>
> (options, args) = parser.parse_args()
>
>With these few lines of code, users of your script can now do the
>"usual thing" on the command-line:
>
> <yourscript> -f outfile --quiet
> <yourscript> -qfoutfile
> <yourscript> --file=outfile -q
> <yourscript> --quiet --file outfile
>
>(All of these result in
> options.filename == "outfile"
> options.verbose == 0
>...just as you might expect.)
>
>Even niftier, users can run one of
> <yourscript> -h
> <yourscript> --help
>and Optik will print out a brief summary of your script's optons:
>
> usage: <yourscript> [options]
>
> options:
> -h, --help show this help message and exit
> -fFILE, --file=FILE write report to FILE
> -q, --quiet don't print status messages to stdout
>
>That's just a taste of the flexibility Optik gives you in parsing your
>command-line. See the documentation included in the package for
>details.
>
>
>AUTHOR, COPYRIGHT, AVAILABILITY
>-------------------------------
>
>Optik was written by Greg Ward <gward at python.net>
>
>The latest version of Optik can be found at
> http://optik.sourceforge.net/
>
>Copyright (c) 2001 Gregory P. Ward. All rights reserved.
>
>
>CHANGES IN OPTIK 1.4
>--------------------
>
>[editorial note: most significant code changes in Optik 1.4 were
> made by David Goodger; except as noted below, David should be credited
> with everything in this list! I just rearranged some of his changes,
> renamed a few thing, and put out the release. --Greg]
>
> * Factored the help-formatting code out of OptionParser into
> some new classes (HelpFormatter and subclasses) in help.py. This
> should make it a lot easier to customize how help is formatted.
>
> * Added the notion of "option groups": an OptionParser can now
> contain several option groups, each which contains several options.
> The main purpose of this is to enable sensibly-grouped help output,
> but it opens up all sorts of interesting (and largely untested)
> possibilities for code to throw whole option groups around instead
> of individual options. Added two new classes: OptionGroup, and
> OptionContainer for code common to OptionParser and OptionGroup.
> (OptionContainer should be invisible to programmers using Optik).
>
> * Added the 'description' attribute and set_description() method to
> both OptionParser and OptionGroup (actually OptionContainer, but
> I just said that class was invisible). Again, this is to make
> help output more useful.
>
> * Made it easier for OptionParser subclasses to decide whether
> they should have the standard "help" option, by moving the logic
> from class level to the _populate_option_list() method.
>
> * Added the "choice" option type, which is just a string type
> constrained to a fixed set of values.
>
> * Added method get_default_values() to OptionParser.
>
> * Rewrote how OptionParser recognizes abbreviated long
> options; removed a redundant internal instance attribute.
>
> * Simplify parsing logic in OptionParser a tad by relocating a loop
> and renaming _process_arg() to _process_args().
>
>--
>Greg Ward <gward at python.net> http://www.gerg.ca/
>Jesus Saves -- and you can too, by redeeming these valuable coupons!
>
>--
>http://mail.python.org/mailman/listinfo/python-announce-list
More information about the ag-dev
mailing list