Event¶
-
class
wishbone.event.Event(data=None, ttl=254, bulk=False, bulk_size=100)[source]¶ The Wishbone event object.
A class object containing the event data being passed from one Wishbone module to the other.
The keyformat used is the one handled by the
Scalplmodule (https://pypi.python.org/pypi/scalpl/).Parameters: -
data¶ dict – A dict containing the event data structure.
-
bulk_size¶ int – The max allowed bulk size.
-
appendBulk(event)[source]¶ Appends an event to this bulk event.
Parameters: event¶ – The event to add to the bulk instance Raises: InvalidData– Either the event is not of type Bulk oreventis not an wishbone.event.Event instance.
-
clone()[source]¶ Returns a cloned version of the event.
Returns: A ``wishbone.event.Event``instanceReturn type: class
-
delete(key=None)[source]¶ Deletes a key.
Parameters: key¶ – The key to delete
Raises: Exception– Deleting the root of a reserved keyword such asdataortags.KeyError– When a non-existing key is referred to.
-
dump()[source]¶ Dumps the complete event. This complete event is also called a
native eventReturns: The content of the event. Return type: dict
-
get(key='data')[source]¶ Returns the value of
key.keymust be inScalplformat.Parameters: key¶ – The name of the key to read. Returns: The value of the key Return type: str/int/float/dict/list Raises: KeyError– The provided key does not exist.
-
getNative()¶ Dumps the complete event. This complete event is also called a
native eventReturns: The content of the event. Return type: dict
-
has(key='data')[source]¶ Returns a bool indicating the event has
keykeymust be inScalplformat.Parameters: key¶ – The name of the key to check Returns: True if the key is there otherwise false Return type: bool Raises: KeyError– The provided key does not exist
-
isBulk()[source]¶ Tells whether event is
bulkor not.Returns: True if the event is bulk Return type: bool
-
merge(value, key='data')[source]¶ Merges value into
key. Value types should be mergeable otherwise an error is returned.Parameters: Raises: InvalidData– Types are not mergeable
-
raw()¶ Dumps the complete event. This complete event is also called a
native eventReturns: The content of the event. Return type: dict
-
render(template, env_template=None)[source]¶ Returns a formatted string using the provided template and key
Parameters: Returns: The rendered string
Return type: str
Raises: InvalidData– An invalid jinja2 template has been provided
-
renderField(field_name, env_template=None)[source]¶ Expects
field_nameto contain a template, renders it and replaces its content with the result. If the fieldfield_namecontains anything else than a string then it’s silently ignored.Parameters: field_name¶ – A string defining the field to handle. Returns: None Raises: InvalidData– An invalid jinja2 template has been provided
-
renderKwargs(template_kwargs)[source]¶ Renders all the templates found in
template_kwargsand sets self.kwarg, a version of the current module’s kwargs relate to this events’ contentParameters: template_kwargs¶ – A dict of the modules kwargs optoinally containing Template instances.
-
slurp(data)[source]¶ Create an event object from a
native eventdict exported bydump()The timestamp field will be reset to the time this method has been called.
Parameters: data¶ – The dict object containing the complete event. Returns: A Wishbone event instance. Return type: wishbone.event.Event Raises: InvalidData–datadoes not contain valid fields to build an event
-