Home | Trees | Index | Help |
|
---|
Package CedarBackup2 :: Module cli :: Class Options |
|
object
--+
|
Options
Class representing command-line options for the cback script.
The Options
class is a Python object representation of
the command-line options of the cback script.
The object representation is two-way: a command line string or a list
of command line arguments can be used to create an Options
object, and then changes to the object can be propogated back to a list
of command-line arguments or to a command-line string. An
Options
object can even be created from scratch
programmatically (if you have a need for that).
There are two main levels of validation in the Options
class. The first is field-level validation. Field-level validation comes
into play when a given field in an object is assigned to or updated. We
use Python's property
functionality to enforce specific
validations on field values, and in some places we even use customized
list classes to enforce validations on list members. You should expect to
catch a ValueError
exception when making assignments to
fields if you are programmatically filling an object.
The second level of validation is post-completion validation. Certain validations don't make sense until an object representation of options is fully "complete". We don't want these validations to apply all of the time, because it would make building up a valid object from scratch a real pain. For instance, we might have to do things in the right order to keep from throwing exceptions, etc.
All of these post-completion validations are encapsulated in theOptions.validate
method. This method can be
called at any time by a client, and will always be called immediately
after creating a Options
object from a command line and
before exporting a Options
object back to a command line.
This way, we get acceptable ease-of-use but we also don't accept or emit
invalid command lines.
Note: Lists within this class are "unordered" for equality comparisons.
Method Summary | |
---|---|
Initializes an options object. | |
Official string representation for class instance. | |
Informal string representation for class instance. | |
Definition of equals operator for this class. | |
Extracts options into a list of command line arguments. | |
Extracts options into a string of command-line arguments. | |
Validates command-line options represented by the object. | |
Inherited from object | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
x.__hash__() <==> hash(x) | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
helper for pickle | |
helper for pickle | |
x.__setattr__('name', value) <==> x.name = value |
Property Summary | |
---|---|
actions : Command-line actions list. | |
config : Command-line configuration file (-c,--config )
parameter. | |
debug : Command-line debug (-d,--debug ) flag. | |
full : Command-line full-backup (-f,--full ) flag. | |
help : Command-line help (-h,--help ) flag. | |
logfile : Command-line logfile (-l,--logfile ) parameter. | |
mode : Command-line mode (-m,--mode ) parameter. | |
output : Command-line output (-O,--output ) flag. | |
owner : Command-line owner (-o,--owner ) parameter, as tuple
(user,group) . | |
quiet : Command-line quiet (-q,--quiet ) flag. | |
stacktrace : Command-line stacktrace (-s,--stack ) flag. | |
verbose : Command-line verbose (-b,--verbose ) flag. | |
version : Command-line version (-V,--version ) flag. |
Method Details |
---|
__init__(self,
argumentList=None,
argumentString=None,
validate=True)
|
__repr__(self)
Official string representation for class instance.
|
__str__(self)
Informal string representation for class instance.
|
__cmp__(self,
other)
Definition of equals operator for this class. Lists within this
class are "unordered" for equality comparisons.
|
buildArgumentList(self, validate=True)Extracts options into a list of command line arguments. The original order of the various arguments (if, indeed, the object
was initialized with a command-line) is not preserved in this generated
argument list. Besides that, the argument list is normalized to use the
long option names (i.e. --version rather than -V). The resulting list
will be suitable for passing back to the constructor in the
validate parameter is False ,
the Options.validate method will be called
(with its default arguments) against the options before extracting the
command line. If the options are not valid, then an argument list will
not be extracted.
|
buildArgumentString(self, validate=True)Extracts options into a string of command-line arguments. The original order of the various arguments (if, indeed, the object
was initialized with a command-line) is not preserved in this generated
argument string. Besides that, the argument string is normalized to use
the long option names (i.e. --version rather than -V) and to quote all
string arguments with double quotes ( validate parameter is False ,
the Options.validate method will be called
(with its default arguments) against the options before extracting the
command line. If the options are not valid, then an argument string
will not be extracted.
|
validate(self)Validates command-line options represented by the object. Unless--help or --version are supplied,
at least one action must be specified. Other validations (as for
allowed values for particular options) will be taken care of at
assignment time by the properties functionality.
|
Property Details |
---|
actionsCommand-line actions list. |
configCommand-line configuration file (-c,--config )
parameter.
|
debugCommand-line debug (-d,--debug ) flag.
|
fullCommand-line full-backup (-f,--full ) flag.
|
helpCommand-line help (-h,--help ) flag.
|
logfileCommand-line logfile (-l,--logfile ) parameter.
|
modeCommand-line mode (-m,--mode ) parameter.
|
outputCommand-line output (-O,--output ) flag.
|
ownerCommand-line owner (-o,--owner ) parameter, as tuple
(user,group) .
|
quietCommand-line quiet (-q,--quiet ) flag.
|
stacktraceCommand-line stacktrace (-s,--stack ) flag.
|
verboseCommand-line verbose (-b,--verbose ) flag.
|
versionCommand-line version (-V,--version ) flag.
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Mon Dec 18 22:53:30 2006 | http://epydoc.sf.net |