base

Handles basic functionality shared by a number of other modules

Classes:

Base
Handles basic __init__ and listener patterns shared among several classes

Decorators:

listener()
A class decorator adding a listener without disrupting _add_listeners()
once()
A class decorator adding a once-only listener without disrupting _add_listeners()
withoptions()
A class decorator adding basic OptionParser functionality
class simulations.base.Base(*args, **kwdargs)[source]

Bases: simulations.utils.eventemitter.EventEmitter

The base class that handles common functionality from which other EventEmitter classes are derived

Keyword Parameters:

default_handlers
If true or not present, adds the default handlers defined in Base._add_default_listeners()
_add_default_listeners()[source]

Sets up default listeners for various events (should implement)

_add_listeners()[source]

Set up listeners for various events (should implement)

add_listener(event, listener=None)

Adds a listener to an event

Parameters:

event
the event to listen for
listener
the handler for the event (should be a function / callable)
emit(event, *args, **kwargs)

Emit an event, triggering the handlers on it with certain arguments

Parameters:

event
the event to trigger
args
arguments to pass to the triggered listeners
kwargs
keyword arguments to pass to the triggered listeners
listeners(event)

Gets a COPY of the list of listeners on an event

Parameters:

event
the event for which to lookup the listeners
max_errstr = '"\n WARNING: Possible EventEmitter memory leak:\n {0} listeners added for {1}. Use set_max_listeners to increase the limit.\n '
on(*args)

Alias for add_listener

once(event, listener=None)
Add a listener, but only execute it the first time the event
occurs, then remove it

Parameters:

event
the event to listen for
listener
the listener function / callable
remove_all_listeners(event)

Clears all listeners from an event

Parameters:

event
the event to clear listeners from
remove_listener(event, listener=None)

Remove a listener from an event

Parameters:

event
the event from which to remove it
listener
the handler to remove
set_max_listeners(max_listeners)

Set the maximum number of listeners for each event.

Parameters:

max_listeners
the maximum number of listeners allowed (None for no limit)
simulations.base.listener(event, handler)[source]

Class decorator to add listeners in a brief way

This is effectively the same as adding a call to add_listener() in _add_listeners().

Parameters:

event
the name of the event to listen for
handler
the event handler
simulations.base.once(event, handler)[source]

Class decorator to handler once-listeners in a brief way.

This is effectively the same as adding a call to once() in _add_listeners().

Parameters:

event
the name of the event to listen for
handler
the event handler
simulations.base.withoptions()[source]

A class wrapper that handles using an OptionParser

Adds Keyword Parameters:

option_error_handler
An error handler for the OptionParser
option_exit_handler
An exit handler for the OptionParser

Adds Events:

oparser set up
emitted after the OptionParser is set up and able to add options
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.