Package flumotion :: Package extern :: Package command :: Module command :: Class Command
[hide private]

Class Command

source code

object --+
         |
        Command
Known Subclasses:

I am a class that handles a command for a program. Commands can be nested underneath a command for further processing.

Instance Methods [hide private]
 
__init__(self, parentCommand=None, stdout=None, stderr=None, width=None)
Create a new command instance, with the given parent.
source code
 
addOptions(self)
Override me to add options to the parser.
source code
int
do(self, args)
Override me to implement the functionality of the command.
source code
int
parse(self, argv)
Parse the given arguments and act on them.
source code
 
handleOptions(self, options)
Handle the parsed options.
source code
 
outputHelp(self, file=None)
Output help information.
source code
 
outputUsage(self, file=None)
Output usage information.
source code
 
getRootCommand(self)
Return the top-level command, which is typically the program.
source code
 
debug(self, format, *args)
Override me to handle debug output from this class.
source code
 
getFullName(self) source code
 
_getStdout(self) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  name = None
name of the command, lowercase; defaults to the lowercase version of the class name
list of str aliases = None
list of alternative lowercase names recognized
  usage = None
short one-line usage string; %command gets expanded to a sub-command or [commands] as appropriate.
  summary = None
short one-line summary of the command
  description = None
longer paragraph explaining the command
  parentCommand = None
hash(x)
dict of str -> Command subCommands = None
dict of name -> commands below this command
  subCommandClasses = None
hash(x)
  aliasedSubCommands = None
hash(x)
optparse.OptionParser parser = None
the option parser used for parsing
Properties [hide private]
  stdout
  stderr

Inherited from object: __class__

Method Details [hide private]

__init__(self, parentCommand=None, stdout=None, stderr=None, width=None)
(Constructor)

source code 

Create a new command instance, with the given parent. Allows for redirecting stdout and stderr if needed. This redirection will be passed on to child commands.

Overrides: object.__init__

do(self, args)

source code 

Override me to implement the functionality of the command.

Returns: int
an exit code, or None if no actual action was taken.

parse(self, argv)

source code 

Parse the given arguments and act on them.

Parameters:
  • argv (list of unicode) - list of arguments to parse
Returns: int
an exit code, or None if no actual action was taken.

outputUsage(self, file=None)

source code 

Output usage information. Used when the options or arguments were missing or wrong.


Class Variable Details [hide private]

usage

short one-line usage string; %command gets expanded to a sub-command or [commands] as appropriate. Don't specify the command name itself, it will be added automatically. If not set, defaults to name.
Value:
None

Property Details [hide private]

stdout

Get Method:
_getStdout(self)

stderr

Get Method:
_getStdout(self)