iduedu.TransportRegistry¶
- class iduedu.TransportRegistry(specs=None)[source]¶
Registry of available public-transport modes and their specifications.
The registry stores
TransportSpecobjects 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 a transport specification to the registry.
Return an existing spec or create one from defaults.
Return a transport specification by name.
Return registered transport type names.
Remove a transport specification by name.
Return a transport specification, or
Noneif it is unknown.Update fields of an existing transport specification.
- Parameters:
specs (dict[str, TransportSpec] | None)
- get(name)[source]¶
Return a transport specification by name.
- try_get(name)[source]¶
Return a transport specification, or
Noneif it is unknown.- Return type:
- 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
specis invalid or already exists.- Return type:
- 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:
- Returns:
Updated transport specification.
- Raises:
KeyError – If
transport_typeis unknown.ValueError – If updated fields are invalid or rename conflicts.
- 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:
- Returns:
Existing or newly registered transport specification.