pyhaystack.util package¶
Submodules¶
pyhaystack.util.asyncexc module¶
Asynchronous Exception Handler. This implements a small lightweight object for capturing an exception in a manner that can be passed in callback arguments then re-raised elsewhere for handling in the callback function.
Typical usage:
def _some_async_function(…, callback_fn):
try:
do some async op that may fail
result = ...
except: # Capture all exceptions
result = AsynchronousException()
callback_fn(result)
pyhaystack.util.filterbuilder module¶
Filter abstract syntax tree builder. These classes and functions attempt to build a filter string for use with ‘read’ operations by combining Python’s operators to trick it into producing the desired values.
Yes, we’re hijacking operators to do what they weren’t expected to do.
Typical usage:
from pyhaystack.util import filterbuilder as fb
# Get all historical points:
session.find_points(fb.Field('his'))
# All historical points in Brisbane timezone.
session.find_points(fb.Field('his') & ( fb.Field('tz') == fb.Scalar('Brisbane') ))
-
class
pyhaystack.util.filterbuilder.
And
(x, y)¶ Bases:
pyhaystack.util.filterbuilder.Binary
-
OP
= 'and'¶
-
-
class
pyhaystack.util.filterbuilder.
Binary
(x, y)¶
-
class
pyhaystack.util.filterbuilder.
Equal
(x, y)¶ Bases:
pyhaystack.util.filterbuilder.Binary
-
OP
= '=='¶
-
-
class
pyhaystack.util.filterbuilder.
Field
(value)¶
-
class
pyhaystack.util.filterbuilder.
GreaterThan
(x, y)¶ Bases:
pyhaystack.util.filterbuilder.Binary
-
OP
= '>'¶
-
-
class
pyhaystack.util.filterbuilder.
GreaterThanOrEqual
(x, y)¶ Bases:
pyhaystack.util.filterbuilder.Binary
-
OP
= '>='¶
-
-
class
pyhaystack.util.filterbuilder.
LessThan
(x, y)¶ Bases:
pyhaystack.util.filterbuilder.Binary
-
OP
= '<'¶
-
-
class
pyhaystack.util.filterbuilder.
LessThanOrEqual
(x, y)¶ Bases:
pyhaystack.util.filterbuilder.Binary
-
OP
= '<='¶
-
-
class
pyhaystack.util.filterbuilder.
Not
(value)¶ Bases:
pyhaystack.util.filterbuilder.Unary
-
OP
= 'not'¶
-
-
class
pyhaystack.util.filterbuilder.
NotEqual
(x, y)¶ Bases:
pyhaystack.util.filterbuilder.Binary
-
OP
= '!='¶
-
-
class
pyhaystack.util.filterbuilder.
Or
(x, y)¶ Bases:
pyhaystack.util.filterbuilder.Binary
-
OP
= 'or'¶
-
-
class
pyhaystack.util.filterbuilder.
Scalar
(value)¶
-
class
pyhaystack.util.filterbuilder.
Unary
(value)¶
pyhaystack.util.state module¶
State machine interface. This is a base class for implementing state machines.
-
class
pyhaystack.util.state.
HaystackOperation
(result_copy=True, result_deepcopy=True)¶ Bases:
pyhaystack.util.operation.BaseHaystackOperation
Initialisation. This should be overridden by subclasses to accept and validate the inputs presented for the operation, raising an appropriate Exception subclass if the inputs are found to be invalid.
These should be stored here by the initialisation function as private variables in suitably sanitised form. The core state machine object shall then be created and stored before the object is returned to the caller.
pyhaystack.util.tools module¶
-
pyhaystack.util.tools.
isBool
(value)¶ Helper function to detect if a value is boolean
-
pyhaystack.util.tools.
isfloat
(value)¶ Helper function to detect if a value is a float
-
pyhaystack.util.tools.
prettyprint
(jsonData)¶ Pretty print json object