id_translation.toml#

Backend for the Translator.from_config() method.

Functions

load_toml_file(path, *[, ...])

Load a TOML file.

Classes

TranslatorFactory(file, fetchers[, clazz, ...])

Create a Translator from TOML inputs.

class TranslatorFactory(file, fetchers, clazz=None, suppress_optional_fetcher_init_errors=None)[source]#

Bases: Generic[NameType, SourceType, IdType]

Create a Translator from TOML inputs.

static CACHE_ACCESS_FACTORY(clazz, config)#

A callable (clazz, config) -> CacheAccess.

Overwrite attribute with your own CacheAccessFactory implementation to customize.

Parameters:
  • clazz – Type of CacheAccess to create.

  • config – Keyword arguments for the cache class.

Returns:

A CacheAccess instance.

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 FetcherFactory implementation to customize.

Parameters:
  • clazz – Type of AbstractFetcher to create.

  • config – Keyword arguments for the fetcher class.

Returns:

An AbstractFetcher instance.

Raises:
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 MapperFactory implementation to customize.

If None is returned, a suitable default is used instead.

Parameters:
  • config – Keyword arguments for the Mapper.

  • for_fetcher – Flag indicating that the Mapper returned will be used by an AbstractFetcher instance.

Returns:

A Mapper instance or None.

Raises:

ConfigurationError – If config is invalid.

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 TransformerFactory implementation to customize.

Parameters:
  • clazz – Type of Transformer to create.

  • config – Keyword arguments for the transformer class.

Returns:

A Transformer instance.

Raises:

ConfigurationError – If config is invalid.

TransformerFactory#

Signature for TRANSFORMER_FACTORY.

alias of Callable[[str, dict[str, Any]], Transformer[Any]]

create()[source]#

Create Translator instance.

load_toml_file(path)[source]#

Read a TOML file from path with the current Metaconf.env settings.

Parameters:

path – Path to file.

Returns:

A dict parsed from path.

See also

load_toml_file()

property metaconf#

Returns the Metaconf used by this factory.

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

factories

Default factory implementations.

meta

TOML configuration metadata types.