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
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()
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 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
Gets a COPY of the list of listeners on an event
Parameters:
- event
- the event for which to lookup the listeners
Alias for add_listener
Parameters:
- event
- the event to listen for
- listener
- the listener function / callable
Clears all listeners from an event
Parameters:
- event
- the event to clear listeners from
Remove a listener from an event
Parameters:
- event
- the event from which to remove it
- listener
- the handler to remove
Set the maximum number of listeners for each event.
Parameters:
- max_listeners
- the maximum number of listeners allowed (None for no limit)
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
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
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