iduedu.TransportRegistry

class iduedu.TransportRegistry(specs=None)[source]

Registry of available public-transport modes and their specifications.

The registry stores TransportSpec objects indexed by normalized transport type names (lowercase). It provides utilities for validating transport types, updating parameters, and ensuring that unknown types encountered during parsing are assigned reasonable defaults.

The registry is used throughout graph construction to compute per-edge travel times consistently across different transport modes.

Methods

add

Add a transport specification to the registry.

ensure

Return an existing spec or create one from defaults.

get

Return a transport specification by name.

list_types

Return registered transport type names.

remove

Remove a transport specification by name.

try_get

Return a transport specification, or None if it is unknown.

update

Update fields of an existing transport specification.

Parameters:

specs (dict[str, TransportSpec] | None)

get(name)[source]

Return a transport specification by name.

Parameters:

name (str) – Transport type name. Matching is case-insensitive and ignores surrounding whitespace.

Raises:

KeyError – If the transport type is unknown.

Return type:

TransportSpec

try_get(name)[source]

Return a transport specification, or None if it is unknown.

Return type:

TransportSpec | None

Parameters:

name (str)

add(spec, *, overwrite=False)[source]

Add a transport specification to the registry.

Parameters:
  • spec (TransportSpec) – Specification to add.

  • overwrite (bool) – If true, replace an existing specification with the same normalized name.

Raises:

ValueError – If spec is invalid or already exists.

Return type:

None

update(transport_type, **fields)[source]

Update fields of an existing transport specification.

Parameters:
  • transport_type (str) – Existing transport type name.

  • **fields – Dataclass fields to update.

Return type:

TransportSpec

Returns:

Updated transport specification.

Raises:
  • KeyError – If transport_type is unknown.

  • ValueError – If updated fields are invalid or rename conflicts.

remove(name)[source]

Remove a transport specification by name.

Return type:

None

Parameters:

name (str)

ensure(name, *, defaults=None)[source]

Return an existing spec or create one from defaults.

Parameters:
  • name (str) – Transport type name.

  • defaults (TransportSpec | None) – Optional specification used when the name is missing.

Return type:

TransportSpec

Returns:

Existing or newly registered transport specification.

list_types()[source]

Return registered transport type names.