flowserv.util.core module
Collection of general utility functions.
- flowserv.util.core.get_unique_identifier() str
Create a new unique identifier.
- Return type
string
- flowserv.util.core.import_obj(import_path: str) Union[Callable, Type]
Import an object (function or class) from a given package path.
- Parameters
import_path (string) – Full package target path for the imported object. Assumes that path components are separated by ‘.’.
- Return type
callable or class
- flowserv.util.core.jquery(doc: Dict, path: List[str]) Any
Json query to extract the value at the given path in a nested dictionary object.
Returns None if the element that is specified by the path does not exist.
- Parameters
doc (dict) – Nested dictionary
path (list(string)) – List of elements in the query path
- Return type
any
- flowserv.util.core.stacktrace(ex) List[str]
Get list of strings representing the stack trace for a given exception.
- Parameters
ex (Exception) – Exception that was raised by flowServ code
- Return type
list of string
- flowserv.util.core.validate_doc(doc: typing.Dict, mandatory: typing.Optional[typing.List[str]] = None, optional: typing.Optional[typing.List[str]] = None, exception: typing.Optional[typing.Type] = <class 'ValueError'>)
Raises error if a dictionary contains labels that are not in the given label lists or if there are labels in the mandatory list that are not in the dictionary. Returns the given dictionary (if valid).
- Parameters
doc (dict) – Dictionary serialization of an object
mandatory (list(string), default=None) – List of mandatory labels for the dictionary serialization
optional (list(string), optional) – List of optional labels for the dictionary serialization
exception (Error, default=ValueError) – Error class that is raised if validation fails. By default, a ValueError is raised.
- Return type
dict
- Raises
ValueError –