optionparser

An extension of optparse.OptionParser that has custom error and exit handling

Classes:

OptionParser
the extension class of optparse.OptionParser
class simulations.utils.optionparser.OptionParser(*args, **kwdargs)[source]

Bases: optparse.OptionParser

Overrides the error() and exit() methods to allow prevention of
auto-exit

New Methods:

set_error_handler()
sets an error handler instead of the default
set_exit_handler()
sets an exit handler instead of the default
error(msg)[source]

Declares a user-defined error has occurred.

Parameters:

msg
The error message string
exit(code=0, msg=None)[source]
Exits the parser/program (the default calls sys.exit). Often called
by OptionParser.error().

Parameters:

code
The exit code
msg
The error message
set_error_handler(handler)[source]

Sets an error handling function

Parameters:

handler
A function that takes an error message and does something with it.
set_exit_handler(handler)[source]

Sets an exit handling function

Parameters:

handler
A function that takes an exit code and error message and does something with it.
Read the Docs v: latest
Versions
latest
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.