calypso.utils package
- class calypso.utils.LazyLoader(local_name: str, parent_module_globals: Mapping, name: str)
Bases:
ModuleType
- class calypso.utils.Registry(name)
Bases:
Mapping- register_module(module=None, name=None, force=False)
method to register a module
- Parameters:
module (
LazyLoader) – LazyLoader instance of specific module, by default Nonename (str) – the class name of registry, by default None
force (bool, optional) – whether to replace the module in force, by default False
- Returns:
module – class of
LazyLoader(not instance)- Return type:
- calypso.utils.log_init(level=20, logfile: Path | str | None = None, logdir: Path | str | None = 'log')
- calypso.utils.proxy_attrs(hinted_class: Type[C])
A decorator to proxy attributes and methods for class
- Parameters:
hinted_class (type) – The class to be proxied. Only hinted attributes and normal methods are proxied, and will be called from _data of the decorated class.
Notes
This decorator is usually used to proxy dataclass.
Examples
>>> class Data: ... x: str ... def __init__(self): ... x = "hinted_x" ... y = "unhinted_y" ... def fn(self): ... return "data" ... @property ... def prop(self): ... return "prop" ... >>> @proxy_attrs(Data) ... class ProxyData: ... def __init__(self): ... self._data = Data() ... >>> proxyed_data = ProxyData() >>> proxyed_data.fn() 'data' >>> proxyed_data.x 'hinted_x' >>> proxied_data.y # not hinted attributes AttributeError: 'ProxyData' object has no attribute 'y' >>> proxied_data.prop # not a normal method AttributeError: 'ProxyData' object has no attribute 'prop'
- calypso.utils.singleton(cls)
Singleton decorator
Subpackages
Submodules
- calypso.utils.detect_seperator module
- calypso.utils.factory module
- calypso.utils.hash module
- calypso.utils.lazyloader module
- calypso.utils.level_json module
- calypso.utils.log module
- calypso.utils.proxy_attrs module
- calypso.utils.registry module
- calypso.utils.rotate_dir module
- calypso.utils.seed module
- calypso.utils.singleton module
- calypso.utils.str_parser module
- calypso.utils.supercell module
- calypso.utils.to_toml module