Package ProcImap :: Package Utils :: Module CLI :: Class ProcImapOptParser
[hide private]
[frames] | no frames]

Class ProcImapOptParser

source code

optparse.OptionContainer --+    
                           |    
       optparse.OptionParser --+
                               |
                              ProcImapOptParser

A special OptionParser for ProcImap. This takes the exact same arguments as optparse.OptionParser.

However, there is a predefined option '-p' or '--profile'. If not given explicitely, this option takes the value of the environment variable PROC_IMAP_PROFILE. If the option is not given, neither explicitely nor implicitely through the envirnoment variable, ProcImapOptParser will shoot down the program it's running in with an error message.

You can use ProcImapOptParser in this manner:

>>> opt = ProcImapOptParser()
>>> (options, args) = opt.parse_args(args=sys.argv)

if sys.argv included e.g. '-p mailboxes.cfg', options.profile will NOT be the string 'mailboxes.cfg', but instead will be an instance of MailboxFactory, generated from the file mailboxes.cfg.

ProcImapOptParser also has a modified default formatter that allows explicit linebreaks (for paragraphs) in help-generating arguments like 'epilogue'.

Instance Methods [hide private]
 
__init__(self, **args)
See documentation of optparse.OptionParser for arguments.
source code
 
parse_args(self, args=None, values=None)
parse_args(args : [string] = sys.argv[1:], values : Values = None) -> (values : Values, args : [string])
source code

Inherited from optparse.OptionParser: add_option_group, check_values, destroy, disable_interspersed_args, enable_interspersed_args, error, exit, expand_prog_name, format_epilog, format_help, format_option_help, get_default_values, get_description, get_option_group, get_prog_name, get_usage, get_version, print_help, print_usage, print_version, set_default, set_defaults, set_process_default_values, set_usage

Inherited from optparse.OptionParser (private): _add_help_option, _add_version_option, _create_option_list, _get_all_options, _get_args, _get_encoding, _init_parsing_state, _match_long_opt, _populate_option_list, _process_args, _process_long_opt, _process_short_opts

Inherited from optparse.OptionContainer: add_option, add_options, format_description, get_option, has_option, remove_option, set_conflict_handler, set_description

Inherited from optparse.OptionContainer (private): _check_conflict, _create_option_mappings, _share_option_mappings

Class Variables [hide private]

Inherited from optparse.OptionParser: standard_option_list

Method Details [hide private]

__init__(self, **args)
(Constructor)

source code 

See documentation of optparse.OptionParser for arguments.

Overrides: optparse.OptionContainer.__init__

parse_args(self, args=None, values=None)

source code 

parse_args(args : [string] = sys.argv[1:],
           values : Values = None)
-> (values : Values, args : [string])

Parse the command-line options found in 'args' (default:
sys.argv[1:]).  Any errors result in a call to 'error()', which
by default prints the usage message to stderr and calls
sys.exit() with an error message.  On success returns a pair
(values, args) where 'values' is an Values instance (with all
your option values) and 'args' is the list of arguments left
over after parsing options.

Overrides: optparse.OptionParser.parse_args