Module parseargs
source code
Functions for dealing with arguments, defaults and options.
string
|
splitLine(line,
COLS=80,
indent=10)
Split an output line to a screen width (with indenting). |
source code
|
|
string
|
|
|
|
|
dictionary
|
|
(dictionary, list)
|
parseargs(argv,
options,
minargs=None,
maxargs=None,
presets={})
Parse a list of input arguments and set the configuration options
variable. |
source code
|
|
|
|
|
Imports:
types.IntType,
types.TypeType,
types.BooleanType,
types.CodeType,
types.UnboundMethodType,
types.StringType,
types.BuiltinMethodType,
types.FloatType,
types.DictionaryType,
types.NotImplementedType,
types.BuiltinFunctionType,
types.DictProxyType,
types.GeneratorType,
types.InstanceType,
types.ObjectType,
types.DictType,
types.FileType,
types.EllipsisType,
types.StringTypes,
types.ListType,
types.MethodType,
types.TupleType,
types.ModuleType,
types.FrameType,
types.LongType,
types.BufferType,
types.TracebackType,
types.ClassType,
types.UnicodeType,
types.SliceType,
types.ComplexType,
types.LambdaType,
types.FunctionType,
types.XRangeType,
types.NoneType,
cStringIO.StringIO
Split an output line to a screen width (with indenting).
- Parameters:
line (string) - the output line to split
COLS (int) - the number of columns in the screen width (optional, defaults
to 80)
indent (int) - the number of columns to indent the output lines with spaces
(optional, defaults to 10)
- Returns:
string
- the multiple lines formatted for output
|
formatDefinitions(options,
COLS,
presets={})
| source code
|
Format configuration options for printing to the user.
- Parameters:
options (list of (string, unknown,
string)) - the name, default value, and description for each of the
configuration options
COLS (int) - the width of the screen to format the output for
presets (dictionary) - other default values to use instead (optional)
- Returns:
string
- the formatted options for output
|
Raise an error to indicate a problem.
- Parameters:
str (string) - the error that occurred
- Raises:
|
Make a dictionary of all the default options.
- Parameters:
options (list of (string, unknown,
string)) - the name, default value, and description for each of the
configuration options
- Returns:
dictionary
- the default options, keys are the option names
|
parseargs(argv,
options,
minargs=None,
maxargs=None,
presets={})
| source code
|
Parse a list of input arguments and set the configuration options
variable.
All configuration options must begin with '--', must be followed by a
space and then the new setting to use, and must appear in the options variable keys. Non-options can appear
anywhere in the arguments (except between an option and it's setting),
and there must be between minargs and maxargs of them.
- Parameters:
argv (list of string) - the input command-line arguments
options (list of (string, unknown,
string)) - the name, default value, and description for each of the
configuration options
minargs (int) - the minimum number of non-option arguments required (optional,
defaults to no minimum)
maxargs (int) - the maximum number of non-option arguments required (optional,
defaults to no maximum)
presets (dictionary) - other default values to use instead (optional)
- Returns: (
dictionary, list)
- the configuration options, and any remaining non-option
arguments
- Raises:
ValueError - by calling usage if something goes wrong
|