iduedu.TransportRegistry¶
- class iduedu.TransportRegistry(specs=None)[source]¶
Registry of public-transport specifications for modes and service variants.
The registry stores
TransportSpecobjects under lowercase mode names and optional"<mode>:<service>"keys.list_types()returns both kinds of keys, andlist_modes()returns the names that can be requested when building an OSM graph.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 mode names that can be requested as OSM route types.
Return registered mode and service variant keys.
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 mode or service variant key.**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) – Mode or service variant key.defaults (
TransportSpec|None) – Optional specification used when the name is missing.
- Return type:
- Returns:
Existing or newly registered transport specification.