IORegistry#

class eclypse.io.registry.IORegistry[source]#

Bases: object

Immutable registry of importer and exporter classes.

Parameters:
  • importers (Mapping[tuple[GraphKind, str], type[GraphImporter]]) – Importer classes keyed by (kind, format).

  • exporters (Mapping[tuple[GraphKind, str], type[GraphExporter]]) – Exporter classes keyed by (kind, format).

Methods

__init__([importers, exporters])

formats(kind, *[, direction])

Return registered formats for a graph kind.

get_exporter(kind, format)

Return the exporter class registered for a graph kind and format.

get_importer(kind, format)

Return the importer class registered for a graph kind and format.

with_exporter(kind, format, exporter)

Return a copy of the registry with an additional exporter.

with_importer(kind, format, importer)

Return a copy of the registry with an additional importer.

Attributes

importers: Mapping[tuple[GraphKind, str], type[GraphImporter]]#
exporters: Mapping[tuple[GraphKind, str], type[GraphExporter]]#
get_importer(kind, format)[source]#

Return the importer class registered for a graph kind and format.

Parameters:
  • kind (GraphKind) – The graph kind, such as "infrastructure".

  • format (str) – The IO format, such as "gml".

Returns:

The registered importer class.

Return type:

type[GraphImporter]

Raises:

ValueError – If no importer is registered for the pair.

get_exporter(kind, format)[source]#

Return the exporter class registered for a graph kind and format.

Parameters:
  • kind (GraphKind) – The graph kind, such as "application".

  • format (str) – The IO format, such as "graphml".

Returns:

The registered exporter class.

Return type:

type[GraphExporter]

Raises:

ValueError – If no exporter is registered for the pair.

with_importer(kind, format, importer)[source]#

Return a copy of the registry with an additional importer.

Parameters:
  • kind (GraphKind) – The graph kind.

  • format (str) – The IO format.

  • importer (type[GraphImporter]) – The importer class to register.

Returns:

A new registry containing the additional importer.

Return type:

IORegistry

with_exporter(kind, format, exporter)[source]#

Return a copy of the registry with an additional exporter.

Parameters:
  • kind (GraphKind) – The graph kind.

  • format (str) – The IO format.

  • exporter (type[GraphExporter]) – The exporter class to register.

Returns:

A new registry containing the additional exporter.

Return type:

IORegistry

formats(kind, *, direction='export')[source]#

Return registered formats for a graph kind.

Parameters:
  • kind (GraphKind) – The graph kind.

  • direction (str) – Either "export" or "import".

Returns:

The registered format names sorted alphabetically.

Return type:

list[str]

Raises:

ValueError – If direction is not supported.

__init__(importers=<factory>, exporters=<factory>)#
Parameters:
Return type:

None