id_translation.toml#
Backend for the Translator.from_config() method.
Functions
|
Load a TOML file. |
Classes
|
Create a |
- class TranslatorFactory(file, fetchers, clazz=None, suppress_optional_fetcher_init_errors=None)[source]#
Bases:
Generic[NameType,SourceType,IdType]Create a
Translatorfrom TOML inputs.- static CACHE_ACCESS_FACTORY(clazz, config)#
A callable
(clazz, config) -> CacheAccess.Overwrite attribute with your own
CacheAccessFactoryimplementation to customize.- Parameters:
clazz – Type of
CacheAccessto create.config – Keyword arguments for the cache class.
- Returns:
A
CacheAccessinstance.- Raises:
ConfigurationError – If config is invalid.
- CacheAccessFactory#
Signature for
CACHE_ACCESS_FACTORY.alias of
Callable[[str,dict[str,Any]],CacheAccess[Any,Any]]
- static FETCHER_FACTORY(clazz, config)#
A callable
(clazz, config) -> AbstractFetcher.Overwrite attribute with your own
FetcherFactoryimplementation to customize.- Parameters:
clazz – Type of
AbstractFetcherto create.config – Keyword arguments for the fetcher class.
- Returns:
An
AbstractFetcherinstance.- Raises:
exceptions.ConfigurationError – If config is invalid.
TypeError – If clazz is not an
AbstractFetchersubtype.
See also
- FetcherFactory#
Signature for
FETCHER_FACTORY.alias of
Callable[[str,dict[str,Any]],AbstractFetcher[Any,Any]]
- static MAPPER_FACTORY(config, for_fetcher)#
A callable
(config, for_fetcher) -> Mapper | None.Overwrite attribute with your own
MapperFactoryimplementation to customize.If
Noneis returned, a suitable default is used instead.- Parameters:
config – Keyword arguments for the
Mapper.for_fetcher – Flag indicating that the
Mapperreturned will be used by anAbstractFetcherinstance.
- Returns:
A
Mapperinstance orNone.- Raises:
ConfigurationError – If config is invalid.
See also
- MapperFactory#
Signature for
MAPPER_FACTORY.alias of
Callable[[dict[str,Any],bool],Mapper[Any,Any,Any] |None]
- TOP_LEVEL_KEYS = ('translator', 'mapping', 'fetching', 'unknown_ids', 'transform')#
Top-level keys allowed in the main configuration file.
- static TRANSFORMER_FACTORY(clazz, config)#
A callable
(clazz, config) -> Transformer.Overwrite attribute with your own
TransformerFactoryimplementation to customize.- Parameters:
clazz – Type of
Transformerto create.config – Keyword arguments for the transformer class.
- Returns:
A
Transformerinstance.- Raises:
ConfigurationError – If config is invalid.
See also
- TransformerFactory#
Signature for
TRANSFORMER_FACTORY.
- create()[source]#
Create
Translatorinstance.
- load_toml_file(path)[source]#
Read a TOML file from path with the current
Metaconf.envsettings.- Parameters:
path – Path to file.
- Returns:
A dict parsed from path.
See also
- load_toml_file(path, *, allow_interpolation=False, allow_nested=False, allow_blank=False)[source]#
Load a TOML file.
This function reads a TOML file with forced UTF-8 encoding (as per the standard). It will optionally perform environment variable value interpolation as well and replace matching names in the file (in-memory, the file will not be changed or read more than once).
For details about the interpolation, see
rics.misc.interpolate_environment_variables().- Parameters:
path – Path to file.
allow_interpolation – If
True, perform env var value interpolation.allow_blank – If
False, blank values are considered missing.allow_nested – If
False, raise an error if variables are defined within the default value of other variables.
- Returns:
A dict parsed from path.
Modules