|
1
|
|
|
from datetime import datetime |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
class SR: |
|
5
|
|
|
# TODO: break down the member variables into smaller classes |
|
6
|
|
|
def __init__( |
|
7
|
|
|
self, |
|
8
|
|
|
country_code_iso: str, |
|
9
|
|
|
company_code_uic: int, |
|
10
|
|
|
internal_id: str | None, |
|
11
|
|
|
decision_id: str | None, |
|
12
|
|
|
in_timetable: bool, |
|
13
|
|
|
due_to_railway_features: bool, |
|
14
|
|
|
line: str, |
|
15
|
|
|
metre_post_from: int, |
|
16
|
|
|
metre_post_to: int, |
|
17
|
|
|
station_from: str, |
|
18
|
|
|
station_to: str | None, |
|
19
|
|
|
on_main_track: bool, |
|
20
|
|
|
main_track_side: str | None, |
|
21
|
|
|
station_track_switch_source_text: str | None, |
|
22
|
|
|
station_track_from: str | None, |
|
23
|
|
|
station_switch_from: str | None, |
|
24
|
|
|
station_switch_to: str | None, |
|
25
|
|
|
operating_speed: int, |
|
26
|
|
|
reduced_speed: int, |
|
27
|
|
|
reduced_speed_for_mus: int, |
|
28
|
|
|
not_signalled_from_start_point: bool | None, |
|
29
|
|
|
not_signalled_from_end_point: bool | None, |
|
30
|
|
|
cause_source_text: str | None, |
|
31
|
|
|
cause_categories: str | None, |
|
32
|
|
|
time_from: datetime, |
|
33
|
|
|
work_to_be_done: str | None, |
|
34
|
|
|
time_to: datetime | None, |
|
35
|
|
|
comment: str | None, |
|
36
|
|
|
sr_id: str | None = None, |
|
37
|
|
|
): |
|
38
|
|
|
self.id = sr_id |
|
39
|
|
|
self.country_code_iso = country_code_iso |
|
40
|
|
|
self.company_code_uic = company_code_uic |
|
41
|
|
|
self.internal_id = internal_id |
|
42
|
|
|
self.decision_id = decision_id |
|
43
|
|
|
self.in_timetable = in_timetable |
|
44
|
|
|
self.due_to_railway_features = ( |
|
45
|
|
|
due_to_railway_features if not NotImplemented else None |
|
46
|
|
|
) |
|
47
|
|
|
self.line = line |
|
48
|
|
|
self.metre_post_from = metre_post_from |
|
49
|
|
|
self.metre_post_to = metre_post_to |
|
50
|
|
|
self.station_from = station_from |
|
51
|
|
|
self.station_to = station_to |
|
52
|
|
|
self.on_main_track = on_main_track |
|
53
|
|
|
self.main_track_side = main_track_side |
|
54
|
|
|
self.station_track_switch_source_text = station_track_switch_source_text |
|
55
|
|
|
self.station_track_from = station_track_from |
|
56
|
|
|
self.station_switch_from = station_switch_from if not NotImplemented else None |
|
57
|
|
|
self.station_switch_to = station_switch_to if not NotImplemented else None |
|
58
|
|
|
self.operating_speed = operating_speed |
|
59
|
|
|
self.reduced_speed = reduced_speed |
|
60
|
|
|
self.reduced_speed_for_mus = reduced_speed_for_mus |
|
61
|
|
|
self.not_signalled_from_start_point = ( |
|
62
|
|
|
not_signalled_from_start_point if not NotImplemented else None |
|
63
|
|
|
) |
|
64
|
|
|
self.not_signalled_from_end_point = ( |
|
65
|
|
|
not_signalled_from_end_point if not NotImplemented else None |
|
66
|
|
|
) |
|
67
|
|
|
self.cause_source_text = cause_source_text |
|
68
|
|
|
self.cause_categories = cause_categories |
|
69
|
|
|
self.time_from = time_from |
|
70
|
|
|
self.work_to_be_done = work_to_be_done |
|
71
|
|
|
self.time_to = time_to |
|
72
|
|
|
self.comment = comment |
|
73
|
|
|
|
|
74
|
|
|
def __str__(self) -> str: |
|
75
|
|
|
return ( |
|
76
|
|
|
f"{self.operating_speed} → {self.reduced_speed} km/h speed restriction {'(#' + self.id[-8:] + ') ' if self.id else ''}" |
|
77
|
|
|
f"on {'the ' + self.main_track_side + ' track of ' if self.main_track_side else ''} line {self.line} " |
|
78
|
|
|
f"between metre posts {self.metre_post_from} and {self.metre_post_to} " |
|
79
|
|
|
f"({'track ' + self.station_track_from + ' at ' if self.station_track_from else ''}" |
|
80
|
|
|
f"{self.station_from}{' and ' + self.station_to if self.station_to else ''}) " |
|
81
|
|
|
f"{'due to «' + self.cause_source_text + '»' if self.cause_source_text else ''} " |
|
82
|
|
|
f"since {self.time_from.isoformat()}{' until ' + self.time_to.isoformat() if self.time_to else ''}" |
|
83
|
|
|
f"{'; comment: ' + self.comment if self.comment else ''}" |
|
84
|
|
|
) |
|
85
|
|
|
|