demessaging.backend.utils module
Utitlity functions for the backend framework.
Classes:
|
A thread that runs an async function. |
Mixin class for |
Functions:
|
Camelize a word by making the first letter upper case. |
|
Get the description of an object. |
|
Get the model fields from a function signature. |
|
Get keywords from a signature and a base model. |
|
Get all the imports from a module |
|
Run an async function and wait for the result. |
|
Transform a list of words into its camelized version. |
- class demessaging.backend.utils.AsyncIoThread(func: Callable, args: Tuple, kwargs: Dict)[source]
Bases:
Thread
A thread that runs an async function.
See: func: run_async for the implementation.
Methods:
run
()Method representing the thread's activity.
- run()[source]
Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
- class demessaging.backend.utils.ImportMixin[source]
Bases:
object
Mixin class for
isort.identify.Import
.A response to https://github.com/PyCQA/isort/issues/1641.
Methods:
- demessaging.backend.utils.camelize(w: str) str [source]
Camelize a word by making the first letter upper case.
- demessaging.backend.utils.get_desc(docstring: docstring_parser.Docstring) str [source]
Get the description of an object.
- Parameters:
docstring (docstring_parser.Docstring) – The parser that analyzed the docstring.
- Returns:
The description of the callable.
- Return type:
- demessaging.backend.utils.get_fields(name: str, sig: inspect.Signature, docstring: docstring_parser.Docstring, config: FunctionConfig | ClassConfig) Dict[str, Tuple[Any, Any]] [source]
Get the model fields from a function signature.
- Parameters:
name (str) – The name of the function or class
sig (inspect.Signature) – The signature of the callable
docstring (docstring_parser.Docstring) – The parser that analyzed the docstring
config (FunctionConfig or ClassConfig) – The configuration for the callable
- Returns:
A mapping from field name to field parameters to be used in
pydantic.create_model()
.- Return type:
- demessaging.backend.utils.get_kws(sig, obj) Dict[str, Any] [source]
Get keywords from a signature and a base model.
- demessaging.backend.utils.get_module_imports(mod: Any) str [source]
Get all the imports from a module
- Parameters:
mod (module) – The module to use