Skip to content

Commit d773f8f

Browse files
authored
Feat(entities): add Entities defined in public documentations (#1)
* chore(repo): add pre-commit configuration for repo * feat(entities): add entities described in the documentation
1 parent e3e3c96 commit d773f8f

9 files changed

+455
-0
lines changed

.pre-commit-config.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v3.2.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-added-large-files
11+
- repo: https://github.com/astral-sh/ruff-pre-commit
12+
rev: v0.3.3
13+
hooks:
14+
- id: ruff
15+
args: [--fix]
16+
- id: ruff-format
17+
- repo: https://github.com/pre-commit/mirrors-mypy
18+
rev: v1.9.0
19+
hooks:
20+
- id: mypy

navitia_client/__init__.py

Whitespace-only changes.

navitia_client/entities/__init__.py

Whitespace-only changes.

navitia_client/entities/base.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from dataclasses import dataclass
2+
3+
4+
@dataclass
5+
class BaseEntity:
6+
id: str
7+
name: str

navitia_client/entities/disruption.py

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
from dataclasses import dataclass
2+
from datetime import datetime
3+
from enum import Enum
4+
from typing import Sequence
5+
6+
from navitia_client.entities.public_transport import PtObject, Route, StopPoint
7+
8+
9+
class DisruptionStatus(Enum):
10+
PAST = "past"
11+
ACTIVE = "active"
12+
FUTURE = "future"
13+
14+
15+
class Effect(Enum):
16+
NO_SERVICE = "no_service"
17+
REDUCED_SERVICE = "reduced_service"
18+
SIGNIFICANT_DELAYS = "significant_delays"
19+
DETOUR = "detour"
20+
ADDITIONAL_SERVICE = "additional_service"
21+
MODIFIED_SERVICE = "modified_service"
22+
OTHER_EFFECT = "other_effect"
23+
UNKNOWN_EFFECT = "unknown_effect"
24+
STOP_MOVED = "stop_moved"
25+
NO_EFFECT = "no_effect"
26+
ACCESSIBILITY_ISSUE = "accessibility_issue"
27+
28+
29+
@dataclass
30+
class Severity:
31+
color: str
32+
priority: int | None
33+
name: str
34+
effect: Effect
35+
36+
37+
@dataclass
38+
class DisruptionPeriod:
39+
begin: datetime
40+
end: datetime
41+
42+
43+
@dataclass
44+
class Channel:
45+
id: str
46+
content_type: str
47+
name: str
48+
49+
50+
@dataclass
51+
class DisruptionMessage:
52+
text: str
53+
channel: Channel
54+
55+
56+
@dataclass
57+
class ImpactedSection:
58+
section_from: PtObject
59+
section_to: PtObject
60+
routes: Route
61+
62+
63+
class StopTimeEffect(Enum):
64+
ADDED = "added"
65+
DELETED = "deleted"
66+
DELAYED = "delayed"
67+
UNCHANGED = "unchanged"
68+
69+
70+
@dataclass
71+
class ImpactedStop:
72+
stop_point: StopPoint
73+
amended_departure_time: str
74+
amended_arrival_time: str
75+
base_departure_time: str
76+
base_arrival_time: str
77+
cause: str
78+
stop_time_effect: StopTimeEffect # written as deprecated in the doc
79+
arrival_status: StopTimeEffect
80+
departure_status: StopTimeEffect
81+
82+
83+
@dataclass
84+
class ImpactedObject:
85+
pt_object: PtObject
86+
impacted_section: ImpactedSection
87+
impacted_stops: Sequence[ImpactedStop]
88+
89+
90+
@dataclass
91+
class Disruption:
92+
id: str
93+
status: DisruptionStatus
94+
disruption_id: str
95+
impact_id: str
96+
severity: Severity
97+
application_periods: Sequence[DisruptionPeriod]
98+
messages: Sequence[DisruptionMessage]
99+
updated_at: datetime
100+
impacted_objects: Sequence[ImpactedObject]
101+
cause: str
102+
category: str
103+
contributor: str

navitia_client/entities/others.py

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
from dataclasses import dataclass
2+
from datetime import datetime
3+
from enum import Enum
4+
from typing import Any, Optional, Sequence
5+
6+
from navitia_client.entities.public_transport import (
7+
CommercialMode,
8+
Line,
9+
Network,
10+
PhysicalMode,
11+
Route,
12+
StopArea,
13+
StopPoint,
14+
Trip,
15+
)
16+
from navitia_client.entities.street_network_object import (
17+
POI,
18+
Address,
19+
AdministrativeRegion,
20+
)
21+
22+
23+
@dataclass
24+
class Context:
25+
timezone: str
26+
current_datetime: datetime
27+
car_direct_path: dict[str, Any]
28+
29+
30+
@dataclass
31+
class PTDatetime:
32+
additional_information: Sequence[str]
33+
departure_date_time: datetime
34+
arrival_date_time: datetime
35+
links: Sequence[dict[str, Any]]
36+
37+
38+
@dataclass
39+
class Note:
40+
id: str
41+
value: str
42+
43+
44+
@dataclass
45+
class StopDateTime:
46+
date_time: PTDatetime
47+
stop_point: StopPoint
48+
49+
50+
@dataclass
51+
class PlaceEmbeddedType:
52+
administrative_region: AdministrativeRegion
53+
stop_area: StopArea
54+
stop_point: StopPoint
55+
address: Address
56+
poi: POI
57+
58+
59+
@dataclass
60+
class PTObjectEmbeddedType:
61+
network: Network
62+
commercial_mode: CommercialMode
63+
line: Line
64+
route: Route
65+
stop_area: StopArea
66+
stop_point: StopPoint
67+
trip: Trip
68+
69+
70+
class Equiment(Enum):
71+
WHEELCHAIR_ACCESSIBILITY = "has_wheelchair_accessibility"
72+
BIKE_ACCEPTED = "has_bike_accepted"
73+
AIR_CONDITIONED = "has_air_conditioned"
74+
VISUAL_ANNOUNCEMENT = "has_visual_announcement"
75+
AUDIBLE_ANNOUNCEMENT = "has_audible_announcement"
76+
APPROPRIATE_ESCORT = "has_appropriate_escort"
77+
APPROPRIATE_SIGNAGE = "has_appropriate_signage"
78+
SCHOOL_VEHICLE = "has_school_vehicle"
79+
WHEELCHAR_BOARDING = "has_wheelchair_boarding"
80+
SHELTERED = "has_sheltered"
81+
ELEVATOR = "has_elevator"
82+
ESCALATOR = "has_escalator"
83+
BIKE_DEPOT = "has_bike_depot"
84+
85+
86+
@dataclass
87+
class DisplayInformation:
88+
network: Network
89+
physical_mode: PhysicalMode
90+
commercial_mode: CommercialMode
91+
code: str
92+
color: str
93+
text_color: str
94+
direction: str
95+
headsign: str
96+
label: str
97+
name: str
98+
trip_short_name: str
99+
equipments: Sequence[Equiment]
100+
description: Optional[str]
+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
from enum import Enum
2+
from dataclasses import dataclass
3+
from typing import Sequence
4+
5+
from navitia_client.entities.base import BaseEntity
6+
from navitia_client.entities.standard import Coord
7+
from navitia_client.entities.street_network_object import (
8+
AdministrativeRegion,
9+
Address,
10+
POI,
11+
StopAreaEquipments,
12+
)
13+
from navitia_client.entities.others import PlaceEmbeddedType
14+
15+
16+
@dataclass
17+
class Network(BaseEntity):
18+
pass
19+
20+
21+
@dataclass
22+
class CommercialMode(BaseEntity):
23+
physical_mode: Sequence["PhysicalMode"]
24+
25+
26+
class PhysicalModeId(Enum):
27+
AIR = "physical_mode:Air"
28+
BOAT = "physical_mode:Boat"
29+
BUS = "physical_mode:Bus"
30+
BUS_RAPID_TRANSIT = "physical_mode:BusRapidTransit"
31+
COACH = "physical_mode:Coach"
32+
FERRY = "physical_mode:Ferry"
33+
FUNICULAR = "physical_mode:Funicular"
34+
LOCAL_TRAIN = "physical_mode:LocalTrain"
35+
LONG_DISTANCE_TRAIN = "physical_mode:LongDistanceTrain"
36+
METRO = "physical_mode:Metro"
37+
RAIL_SHUTTLE = "physical_mode:RailShuttle"
38+
RAPID_TRANSIT = "physical_mode:RapidTransit"
39+
SHUTTLE = "physical_mode:Shuttle"
40+
SUSPENDED_CAR_CABLE = "physical_mode:SuspendedCableCar"
41+
TAXI = "physical_mode:Taxi"
42+
TRAIN = "physical_mode:Train"
43+
TRAMWAY = "physical_mode:Tramway"
44+
45+
46+
@dataclass
47+
class PhysicalMode:
48+
id: PhysicalModeId
49+
name: str
50+
commercial_modes: Sequence[CommercialMode]
51+
52+
53+
@dataclass
54+
class Place(BaseEntity):
55+
quality: int
56+
embedded_type: PlaceEmbeddedType
57+
administrative_region: AdministrativeRegion
58+
stop_area: StopAreaEquipments
59+
poi: POI
60+
address: Address
61+
stop_point: "StopPoint"
62+
63+
64+
@dataclass
65+
class Route(BaseEntity):
66+
is_frequence: bool
67+
line: "Line"
68+
direction: Place
69+
70+
71+
@dataclass
72+
class Line(BaseEntity):
73+
code: str
74+
color: str
75+
opening_time: str
76+
closing_time: str
77+
routes: Sequence[Route]
78+
commercial_mode: CommercialMode
79+
physical_modes: Sequence[PhysicalMode]
80+
81+
82+
@dataclass
83+
class StopArea(BaseEntity):
84+
label: str
85+
coord: Coord
86+
administrative_regions: Sequence[AdministrativeRegion]
87+
stop_points: Sequence["StopPoint"]
88+
89+
90+
@dataclass
91+
class StopPoint(BaseEntity):
92+
coord: Coord
93+
administrative_regions: Sequence[AdministrativeRegion]
94+
equipments: Sequence[str]
95+
stop_area: StopArea
96+
97+
98+
@dataclass
99+
class Company(BaseEntity):
100+
pass
101+
102+
103+
@dataclass
104+
class Trip(BaseEntity):
105+
pass
106+
107+
108+
@dataclass
109+
class PTObjectEmbeddedType:
110+
network: Network
111+
commercial_mode: CommercialMode
112+
line: Line
113+
route: Route
114+
stop_area: StopArea
115+
stop_point: StopPoint
116+
trip: Trip
117+
118+
119+
@dataclass
120+
class PtObject(BaseEntity):
121+
quality: int
122+
embedded_type: PTObjectEmbeddedType
123+
stop_area: StopArea
124+
stop_point: StopPoint
125+
network: Network
126+
commercial_mode: CommercialMode
127+
line: Line
128+
route: Route
129+
trip: Trip

navitia_client/entities/standard.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from dataclasses import dataclass
2+
3+
4+
@dataclass
5+
class Coord:
6+
lon: float
7+
lat: float

0 commit comments

Comments
 (0)