rics.translation.dio#

Integration for insertion and extraction of IDs and translations to and from various data structures.

Functions

resolve_io(arg)

Get an IO instance for arg.

Classes

DataStructureIO()

Insertion and extraction of IDs and translations.

class DataStructureIO[source]#

Bases: object

Insertion and extraction of IDs and translations.

static handles_type(arg: Any) bool[source]#

Return True if the implementation handles data for the type of arg.

abstract static extract(c: Any, names: List[NameType]) Dict[NameType, Sequence[IdType]][source]#

Extract IDs from c.

Parameters
  • c – A collection to extract IDs from.

  • names – List of names to extract IDs for.

Returns

A dict {name, ids}.

abstract static insert(c: Any, names: List[NameType], tmap: TranslationMap, copy: bool) Optional[Any][source]#

Insert translations into c.

Parameters
  • c – A collection apply translations for. Modified iff copy=False.

  • names – Names in t to translate..

  • tmap – Translations for IDs in c.

  • copy – If True, modify contents of the original collection c. Otherwise, return a copy.

Returns

A copy of c if copy=True. None otherwise.

Raises

NotInplaceTranslatableError – If copy=False for a type which is not translatable in-place.

resolve_io(arg: Translatable) Type[DataStructureIO][source]#

Get an IO instance for arg.

Parameters

arg – An argument to get IO for.

Returns

A data structure IO instance for arg.

Raises

UntranslatableTypeError – If not IO could be found.

Modules

rics.translation.dio.exceptions

Data structure I exceptions.