Table of Contents

Class: Options Twisted-0.17.4/twisted/python/usage.py

A class which can be subclassed to provide command-line options to your program. See twisted.usage.__doc__ for for details.

Methods   
__getattr__
__init__
__str__
_gather_flags
_gather_handlers
_gather_parameters
_generic_flag
_generic_parameter
opt_help
parseArgs
parseOptions
postOptions
  __getattr__ 
__getattr__ ( self,  attr )

I make sure that old style optObj.option access still works.

Exceptions   
AttributeError("%s instance has no attribute '%s'" %( self.__class__, attr ) )
  __init__ 
__init__ ( self )

  __str__ 
__str__ ( self,  width=None )

  _gather_flags 
_gather_flags ( self )

Gather up boolean (flag) options.

Exceptions   
ValueError, "A flag cannot be without a name."
  _gather_handlers 
_gather_handlers ( self )

Gather up options with their own handler methods.

Exceptions   
UsageError( 'invalid Option function for %s' % name )
  _gather_parameters 
_gather_parameters ( self )

Gather options which take a value.

Exceptions   
ValueError, "A parameter cannot be without a name."
  _generic_flag 
_generic_flag (
        self,
        flagName,
        value=None,
        )

Exceptions   
UsageError, ("Flag '%s' takes no argument." " Not even \"%s\"." %( flagName, value ) )
  _generic_parameter 
_generic_parameter (
        self,
        parameterName,
        value,
        )

Exceptions   
UsageError, ("Parameter '%s' requires an argument." %( parameterName, ) )
  opt_help 
opt_help ( self )

  parseArgs 
parseArgs ( self )

I am called with any leftover arguments which were not options.

Override me to do something with the remaining arguments on the command line, those which were not flags or options. e.g. interpret them as a list of files to operate on.

Note that if there more arguments on the command line than this method accepts, parseArgs will blow up with a getopt.error. This means if you don't override me, parseArgs will blow up if I am passed any arguments at all!

  parseOptions 
parseOptions ( self,  options=None )

The guts of the command-line parser.

Exceptions   
UsageError( "wrong number of arguments." )
UsageError, "No such option '%s'" %( opt, )
UsageError, e
  postOptions 
postOptions ( self )

I am called after the options are parsed.

Override this method in your subclass to do something after the options have been parsed and assigned.

XXX: Like what?


Table of Contents

This document was automatically generated on Sat Apr 20 01:31:23 2002 by HappyDoc version 2.0