id_translation.transform.types#
Classes used for ID and translation transformation.
Module Attributes
A dict |
Classes
|
Transformation API type. |
- class Transformer(*args, **kwargs)[source]#
-
Transformation API type.
Transformers are persistent entities owned by a single
Translatorinstance. See theBitmaskTransformerfor a concrete example.- try_add_missing_key(key, /, *, translations)[source]#
Attempt to create and add a translation for an unknown ID.
Callback function used by
MagicDictwhenever an unknown ID is requested.- Parameters:
key – An ID which is not present in the translations.
translations – A mutable mapping of translations. Typically, the
MagicDictcaller itself.
- update_ids(ids, /)[source]#
Transform a source-to-ids mapping dict.
Called just before IDs are fetched from the source.
Note
Not called when the
Translatoris working offline.- Parameters:
ids – A collection of IDs from the source.
- Transformers#
A dict
{source: transformer}of initializedTransformerinstances.alias of
dict[SourceType,Transformer[IdType]]