id_translation.toml.meta#
TOML configuration metadata types.
Classes
|
Base implementation for Metadata types. |
|
Metadata pertaining to how a |
|
Control environment-variable interpolation. |
|
Determines how equivalence between configuration files is determined. |
|
Python representation of |
- class BaseMetadata(versions=None, created=None)[source]#
Bases:
ABCBase implementation for Metadata types.
- Parameters:
versions – Versions, e.g.
{'python': '3.11.11'`, 'your-package': '1.0.0'}.created – The time at which the metadata was originally created.
- classmethod get_package_versions(extra_packages)[source]#
Extract package versions using
importlib.metadata.
- is_equivalent(other)[source]#
Compute equivalency with other.
- Parameters:
other – Another metadata instance.
- Returns:
A string reason_not_equivalent or an empty string.
- use_cached(metadata_path, max_age)[source]#
Check status of stored metadata config based a desired configuration
self.- Parameters:
metadata_path – Path of stored metadata.
max_age – Maximum age of stored metadata. Pass zero to force recreation. Smaller than zero = never expire.
- Returns:
A tuple
(True, expires_at, None)or(False, reason, reason_type).
- class ConfigMetadata(main, extra_fetchers, clazz, metaconf, **kwargs)[source]#
Bases:
BaseMetadataMetadata pertaining to how a
Translatorinstance was initialized from TOML configuration.- Equivalence:
Configs are equivalent if and only if…
They have the same top-level dependency versions, and
Use the same fully qualified class name, and
The main configuration is equal after parsing, and
They have the same number of auxiliary (“extra”) fetcher configurations, and
All auxiliary fetcher configurations are equal after parsing.
The
Metaconfis not explicitly included in the equivalence check, but changing it will invalidate cached instances. Environment variable changes may also invalidate the cache ifEnvConf.allow_interpolationis set and interpolations such as${VAR}are present.- Parameters:
main – Absolute path and fingerprint of the main translation configuration.”
extra_fetchers – Absolute path and fingerprint of configuration files for auxiliary fetchers.
clazz – String representation of the class type.
metaconf – A
Metaconfinstance that determines, among other things, how other config paths are processed.kwargs – Forwarded to base class.
- class EnvConf(allow_interpolation=True, allow_blank=False, allow_nested=False)[source]#
Bases:
objectControl environment-variable interpolation.
All keys are forwarded to
load_toml_file().- allow_blank = False#
- allow_interpolation = True#
- allow_nested = False#
- class EquivalenceConf(python_version='{v.major}.{v.minor}.{v.micro}', extra_packages=<factory>)[source]#
Bases:
objectDetermines how equivalence between configuration files is determined.
- extra_packages#
Additional package whose versions are used to determine
ConfigMetadataequivalence.
- classmethod from_dict(config)[source]#
Construct equivalence configuration object from a dict.
- Parameters:
config – Dict representation of an
EquivalenceConfto consume.- Returns:
A new
EquivalenceConfinstance.
- python_version = '{v.major}.{v.minor}.{v.micro}'#
Used to format the
'python_version'version usingv=sys.version_info.
- class Metaconf(env=<factory>, equivalence=<factory>)[source]#
Bases:
objectPython representation of
metaconf.tomlfile.The
metaconf.tomlfile always lives next to the main configuration file. It determines how other configuration files are read and validated.[env] allow_interpolation = true allow_nested = true allow_blank = false [equivalence] # python_version = "{v.major}.{v.minor}" # Uncomment to allow any patch version extra_packages = ["bci-id-translation"]
The sample above comes from the rsundqvist/id-translation-project demo.
- equivalence#
Controls how equivalence checks are performed. See
EquivalenceConf.