nskit.common
nskit.common.configuration
Base configuration class.
Includes
- properties in model dumps
- file based config loading (json/toml/yaml)
- model dumping to toml & yaml
BaseConfiguration
Bases: PropertyDumpMixin
, BaseSettings
A Pydantic BaseSettings type object with Properties included in model dump, and yaml and toml integrations.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/configuration/__init__.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
model_dump_toml(*, indent=None, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False, round_trip=False, warnings=True)
Dump model to TOML.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/configuration/__init__.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
model_dump_yaml(*, indent=None, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False, round_trip=False, warnings=True)
Dump model to YAML.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/configuration/__init__.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
settings_customise_sources(settings_cls, init_settings, env_settings, dotenv_settings, file_secret_settings)
Create settings loading, including the FileConfigSettingsSource.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/configuration/__init__.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
SettingsConfigDict
Bases: SettingsConfigDict
Customised Settings Config Dict.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/configuration/__init__.py
31 32 33 34 35 |
|
nskit.common.contextmanagers
Reusable context managers.
ChDir
Bases: ContextDecorator
Context manager for running in a specified (or temporary) directory.
The optional argument is a path to a specified target directory, if this isn't provided, a temporary directory is created
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/contextmanagers/chdir.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
__enter__()
Change to the target directory.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/contextmanagers/chdir.py
33 34 35 36 37 38 39 40 41 |
|
__exit__(exc_type, exc_val, exc_tb)
Reset to the original directory.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/contextmanagers/chdir.py
43 44 45 46 47 48 49 50 51 52 |
|
__init__(target_dir=None)
Initialise the context manager.
Other Parameters:
Name | Type | Description |
---|---|---|
target_dir |
Optional[Path]
|
the target directory |
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/contextmanagers/chdir.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
Env
Bases: ContextDecorator
Context manager for managing environment variables.
The optional arguments can provide either an exhaustive set of environment values, values to override or values to remove.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/contextmanagers/env.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|
__enter__()
Change to the target environment variables.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/contextmanagers/env.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
__exit__(*args, **kwargs)
Reset to the original environment variables.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/contextmanagers/env.py
61 62 63 64 65 |
|
__init__(environ=None, override=None, remove=None)
Initialise the context manager.
The parameters are applied in the following order (so can be combined): 1st - environ, 2nd - override, 3rd - remove
Other Parameters:
Name | Type | Description |
---|---|---|
environ |
Optional[Dict[str, str]]
|
an exhaustive set of environment values to set (replaces overall os.environ contents) |
override |
Optional[Dict[str, str]]
|
a set of environment values to either override or set (replaces values in existing os.environ) |
remove |
Optional[List[str]]
|
a set of environment values to remove (removes values if found in os.environ ) |
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/contextmanagers/env.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
TestExtension
Bases: ContextDecorator
Context manager for running a test of an entrypoint.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/contextmanagers/test_extensions.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
__enter__()
Add the extension so it can be loaded.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/contextmanagers/test_extensions.py
98 99 100 101 |
|
__exit__(*args, **kwargs)
Remove the extension and return to the original.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/contextmanagers/test_extensions.py
103 104 105 106 |
|
__init__(name, group, entrypoint, *, solo=False)
Initialise the context manager.
Other Parameters:
Name | Type | Description |
---|---|---|
name |
str
|
the extension name |
group |
str
|
the extension group |
entrypoint |
type
|
the object/type to load in the entrypoint |
solo |
bool
|
set so only that entrypoint will be found (can cause side-effects) |
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/contextmanagers/test_extensions.py
86 87 88 89 90 91 92 93 94 95 96 |
|
nskit.common.extensions
Common extension helpers.
ExtensionsEnum
Bases: Enum
Enum created from available extensions on an entrypoint.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/extensions.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
extension
property
Load the extension.
from_entrypoint(name, entrypoint)
classmethod
Create the enum with name, from entrypoint options.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/extensions.py
43 44 45 46 47 48 49 |
|
get_extension_names(entrypoint)
Get all installed extension names for a given entrypoint.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/extensions.py
15 16 17 18 19 20 21 |
|
get_extensions(entrypoint)
Load all extensions for a given entrypoint.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/extensions.py
31 32 33 34 35 36 37 |
|
load_extension(entrypoint, extension)
Load a given extension for a given entrypoint.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/extensions.py
24 25 26 27 28 |
|
nskit.common.io
nskit.common.io.json
Provide a JSON Load/Dump API consistent with stdlib JSON.
dump(data, f, /, default=None, option=None, **kwargs)
Dump JSON to file.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/io/json.py
24 25 26 |
|
dumps(data, /, default=None, option=None, **kwargs)
Dump JSON to string.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/io/json.py
14 15 16 |
|
load(fp, **kwargs)
Load JSON from file.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/io/json.py
19 20 21 |
|
loads(s, **kwargs)
Load JSON from string.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/io/json.py
9 10 11 |
|
nskit.common.io.toml
Provide a TOML Load/Dump API consistent with JSON.
dump(data, fp, sort_keys=False, **kwargs)
Load TOML to file/stream.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/io/toml.py
24 25 26 |
|
dumps(data, sort_keys=False, **kwargs)
Dump TOML to string.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/io/toml.py
14 15 16 |
|
load(fp, **kwargs)
Load TOML from file/stream.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/io/toml.py
19 20 21 |
|
loads(s, **kwargs)
Load TOML from string.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/io/toml.py
9 10 11 |
|
nskit.common.io.yaml
Provide a YAML 1.2 Load/Dump API consistent with JSON.
dump(data, stream, *, typ='rt', **kwargs)
Dump YAML to file/stream.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/io/yaml.py
29 30 31 |
|
dumps(data, *, typ='rt', **kwargs)
Dump YAML to string.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/io/yaml.py
17 18 19 20 21 |
|
load(stream, *, typ='rt', **kwargs)
Load YAML from file/stream.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/io/yaml.py
24 25 26 |
|
loads(s, *, typ='rt', **kwargs)
Load YAML from string.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/io/yaml.py
12 13 14 |
|
nskit.common.logging
Common logging helpers.
LoggingConfig
Bases: BaseConfiguration
This is a basic config for logging.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/logging/config.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
formatter
property
Return the logging formatter for the format string.
LibraryLoggerFactory
A factory for creating multiple library loggers.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/logging/library.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
library
property
Return the library name.
version
property
Return the version name.
__init__(library, version, base_config=None)
Initialise the logger factory.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/logging/library.py
29 30 31 32 33 |
|
get(name, config=None, **kwargs)
Alias for the get_logger method.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/logging/library.py
41 42 43 |
|
getLogger(name, config=None, **kwargs)
Alias for the get_logger method to provide parity with the standard logging API.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/logging/library.py
45 46 47 |
|
get_logger(name, config=None, **kwargs)
Get the library logger.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/logging/library.py
35 36 37 38 39 |
|
getLogger(name, config=None, **kwargs)
Get the logger object.
wraps get_logger.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/logging/__init__.py
9 10 11 12 13 14 15 |
|
get_library_logger(library, version, name, config=None, **kwargs)
Get a (sub)logger for a library component, which includes the library and version.
Source code in .venv-docs/lib/python3.12/site-packages/nskit/common/logging/library.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|