sammo.utils
#
Small number of utility functions that are used across SAMMO.
Module Contents#
Classes#
Time code with this context manager. |
Functions#
Execute and return result of an async function. Take special care of already running async loops. |
|
Serialize json with orjson to invariant byte string. |
Data#
Path of the main script if not interactive, otherwise working dir. |
|
Name of the main script file if not interactive, otherwise ‘tmp’. |
|
Default save path is folder with the same name as main script. |
API#
- class sammo.utils.CodeTimer#
Time code with this context manager.
Initialization
- property interval: float#
Timed interval in s.
- sammo.utils.MAIN_PATH = 'get_main_script_path(...)'#
Path of the main script if not interactive, otherwise working dir.
- sammo.utils.MAIN_NAME = 'get_main_script_name(...)'#
Name of the main script file if not interactive, otherwise ‘tmp’.
- sammo.utils.DEFAULT_SAVE_PATH = 'get_default_save_path(...)'#
Default save path is folder with the same name as main script.
- sammo.utils.sync(f: collections.abc.Coroutine)#
Execute and return result of an async function. Take special care of already running async loops.
- sammo.utils.serialize_json(key) bytes #
Serialize json with orjson to invariant byte string.