rics.translation.factory#

Factory functions for translation classes.

Module Attributes

FetcherFactory

A callable which creates new AbstractFetcher instances from a dict config.

MapperFactory

A callable which creates new Mapper instances from a dict config.

Functions

default_fetcher_factory(clazz, config)

Create an AbstractFetcher from config.

default_mapper_factory(config, for_fetcher)

Create a Mapper from config.

Classes

TranslatorFactory(file, extra_fetchers)

Create a Translator from TOML inputs.

FetcherFactory#

A callable which creates new AbstractFetcher instances from a dict config.

Config format is described in Section: Fetching.

Parameters
  • clazz – Type of AbstractFetcher to create.

  • config – Keyword arguments for the fetcher class.

Returns

A Fetcher instance.

Raises

alias of Callable[[str, Dict[str, Any]], AbstractFetcher]

MapperFactory#

A callable which creates new Mapper instances from a dict config.

Config format is described in Subsection: Mapping.

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.

alias of Callable[[Dict[str, Any], bool], Optional[Mapper]]

default_fetcher_factory(clazz: str, config: Dict[str, Any]) AbstractFetcher[source]#

Create an AbstractFetcher from config.

default_mapper_factory(config: Dict[str, Any], for_fetcher: bool) Optional[Mapper][source]#

Create a Mapper from config.

class TranslatorFactory(file: Union[str, bytes, PathLike], extra_fetchers: Iterable[Union[str, bytes, PathLike]])[source]#

Bases: Generic[NameType, SourceType, IdType]

Create a Translator from TOML inputs.

FETCHER_FACTORY(config: Dict[str, Any]) AbstractFetcher#

A callable (name, kwargs) -> AbstractFetcher. Overwrite attribute to customize.

MAPPER_FACTORY(for_fetcher: bool) Optional[Mapper]#

A callable (kwargs) -> Mapper. Overwrite attribute to customize.

create() Translator[source]#

Create a Translator from a TOML file.