angelos.common.utils¶
Utility module.
The utility module containse all minor extras that is used globally in the application.
-
class
angelos.common.utils.Checksum¶ Bases:
objectGenerate and check checksum based on introspection of data stream.
-
check(sum: bytes) → bool¶ Compare introspected sum with given sum.
-
checksum(length: int = 1) → bytes¶ Generate a checksum of certain byte size.
-
introspect(stream: Union[bytes, bytearray])¶ Build checksum based on a stream with multiple data chunks.
-
-
class
angelos.common.utils.Event(*, loop=None)¶ Bases:
asyncio.locks.EventA threadsafe asynchronous event class.
-
set()¶ Set the internal flag to true. All coroutines waiting for it to become true are awakened. Coroutine that call wait() once the flag is true will not block at all.
-
-
class
angelos.common.utils.EventState(states: list)¶ Bases:
angelos.common.utils.SingleStateA state machine that triggers an event at state change.
-
goto(state: unicode)¶ Go to another state and trigger an event.
-
wait_for(predicate)¶ Wait for a state to happen.
-
-
class
angelos.common.utils.FactoryInterface¶ Bases:
objectDocstring
-
classmethod
factory(**kwargs)¶ Docstring
-
classmethod
-
class
angelos.common.utils.MultiState(states: dict)¶ Bases:
angelos.common.utils.StateMachineA state machine that allows switching between predefined states.
-
property
available¶ Expose available options.
-
goto(state: unicode)¶ Go to another state that is available.
-
property
-
class
angelos.common.utils.SingleState(states: tuple)¶ Bases:
angelos.common.utils.StateMachineA state machine that allows switching between states.
-
property
available¶ Expose available options.
-
goto(state: unicode)¶ Go to another state that is available.
-
property
-
class
angelos.common.utils.StateMachine¶ Bases:
objectA class that can hold a single state at a time.
-
property
available¶ Expose available options.
-
goto(state: unicode)¶ Switch to another state.
-
property
state¶ Get state.
-
property
-
class
angelos.common.utils.Util¶ Bases:
objectGeneral basic utilities.
-
static
class_pkg(klass)¶ Docstring
-
static
generate_checksum(data: Union[bytes, bytearray]) → bytes¶ Generate a checksum out of the entered data.
-
static
headline(title: unicode, filler: unicode = '', barrier='-')¶ Print headlines.
-
static
hours(seconds)¶ Docstring
-
static
is_class(instance, types)¶ check_class is a helper function. Tests for a subclass and raises a standardized TypeError exception.
Instance The instanced variable type The class type of expected type, or tuple of them
Example: check_class(result, (Model, BaseModel))
-
static
is_type(instance, types)¶ check_type is a helper function. Tests for an instance and raises a standardized TypeError exception.
Instance The instanced variable type The class type of expected type, or tuple of them
Example: check_type(result, (NoneType, StringType))
-
is_typing(types)¶ Check instance, even on typing classes.
Instance The instanced variable type The class type of expected type, or tuple of them
-
static
klass(module: unicode, cls: unicode) → Type[Any]¶ Load a class from a module in a package.
-
static
log_exception(exc: Exception)¶ Log exception and traceback using the logging.critical() method.
-
static
path(dirname, filename)¶ Merge directory path and filename.
-
static
populate(klass: object, attributes: dict) → None¶ Populate class attributes from dictionary.
- Parameters
klass –
attributes –
-
static
print_exception(exc: Exception)¶ Print exception and traceback using the python print() method.
-
static
verify_checksum(data: Union[bytes, bytearray], checksum: bytes) → bool¶ Verify the checksum out of the entered data.
-
static