ParseCommandArgs Module
A simple module to generated parsers for the command args of all others scripts.
Warning:
Warning
This module use ‘argparse’, a new 2.7 module.
That brokes the retrocompatibility with Python 2.6... Sorry !
More infos:
-
ParseCommandArgs.default_epilog(version, date, author)[source]
This return the default epilog used to new parsers,
which contains a copyright paragraph, determined by the three arguments version, date, author.
-
ParseCommandArgs.default_description = 'WARNING: No description had been given to ParseCommandArgs.parser_default...'
The default description, used when generate a parser by parser_default function !
-
ParseCommandArgs.add_default_options(parser, version='0.22', date='Tue 18/06/2013 at 11h:13m:33s', author='Lilian BESSON (mailto:lilian.besson@normale.fr)')[source]
parser_default(parser, version, date, author) -> argparse.ArgumentParser instance.
- Return the parser parser, modified by adding default options for the project,
- which put the options : –version, –verbose, –noANSI and –noUTF
and others basic options.
-
ParseCommandArgs.parser_default(parser, version, date, author) → argparse.ArgumentParser instance.[source]
- Make a new parser, initialized by adding default options for the project (with add_default_options)
- The default description is default_description,
The epilog will epilog, then default_epilog(version, date, author).
- preprocessor can be ANSIColors.sprint or __builtin__.str (default value)
- (i.e. a string -> string function),
and it will be used as a preprocessor for description and epilog value.
- Example:
>>> parser = parser_default(description='<DELETE>A description.', epilog='The description will no begin by the balise DELETE, thanks to sprint preprocessing.', preprocessor=lambda s: s.replace('<DELETE>', ''))