koleo-cli 0.2.137.11__py3-none-any.whl → 0.2.137.12__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of koleo-cli might be problematic. Click here for more details.
- koleo/cli.py +16 -7
- koleo/storage.py +1 -1
- {koleo_cli-0.2.137.11.dist-info → koleo_cli-0.2.137.12.dist-info}/METADATA +1 -1
- koleo_cli-0.2.137.12.dist-info/RECORD +13 -0
- {koleo_cli-0.2.137.11.dist-info → koleo_cli-0.2.137.12.dist-info}/WHEEL +1 -1
- koleo_cli-0.2.137.11.dist-info/RECORD +0 -13
- {koleo_cli-0.2.137.11.dist-info → koleo_cli-0.2.137.12.dist-info}/LICENSE +0 -0
- {koleo_cli-0.2.137.11.dist-info → koleo_cli-0.2.137.12.dist-info}/entry_points.txt +0 -0
- {koleo_cli-0.2.137.11.dist-info → koleo_cli-0.2.137.12.dist-info}/top_level.txt +0 -0
koleo/cli.py
CHANGED
|
@@ -96,14 +96,16 @@ class CLI:
|
|
|
96
96
|
arr_cache_id = f"arr-{st['id']}-{date.strftime("%Y-%m-%d")}"
|
|
97
97
|
dep_cache_id = f"dep-{st['id']}-{date.strftime("%Y-%m-%d")}"
|
|
98
98
|
arrivals = self.storage.get_cache(arr_cache_id) or self.storage.set_cache(
|
|
99
|
-
arr_cache_id, self.client.get_arrivals(st[
|
|
99
|
+
arr_cache_id, self.client.get_arrivals(st["id"], date)
|
|
100
100
|
)
|
|
101
101
|
departures = self.storage.get_cache(dep_cache_id) or self.storage.set_cache(
|
|
102
|
-
dep_cache_id, self.client.get_departures(st[
|
|
102
|
+
dep_cache_id, self.client.get_departures(st["id"], date)
|
|
103
103
|
)
|
|
104
104
|
trains = sorted(
|
|
105
105
|
[(i, 1) for i in departures] + [(i, 2) for i in arrivals],
|
|
106
|
-
key=lambda train: datetime.fromisoformat(
|
|
106
|
+
key=lambda train: datetime.fromisoformat(
|
|
107
|
+
train[0]["departure"] if train[1] == 1 else train[0]["arrival"]
|
|
108
|
+
).timestamp(),
|
|
107
109
|
)
|
|
108
110
|
trains = [
|
|
109
111
|
(i, type)
|
|
@@ -113,7 +115,11 @@ class CLI:
|
|
|
113
115
|
brands = self.storage.get_cache("brands") or self.storage.set_cache("brands", self.client.get_brands())
|
|
114
116
|
parts = []
|
|
115
117
|
for train, type in trains:
|
|
116
|
-
time =
|
|
118
|
+
time = (
|
|
119
|
+
f"[bold green]{train['departure'][11:16]}[/bold green]"
|
|
120
|
+
if type == 1
|
|
121
|
+
else f"[bold yellow]{train['arrival'][11:16]}[/bold yellow]"
|
|
122
|
+
)
|
|
117
123
|
brand = next(iter(i for i in brands if i["id"] == train["brand_id"]), {}).get("logo_text")
|
|
118
124
|
parts.append(
|
|
119
125
|
f"{time} [red]{brand}[/red] {train["train_full_name"]}[purple] {train["stations"][0]["name"]} {self.format_position(train["platform"], train["track"])}[/purple]"
|
|
@@ -164,14 +170,16 @@ class CLI:
|
|
|
164
170
|
brands = self.storage.get_cache("brands") or self.storage.set_cache("brands", self.client.get_brands())
|
|
165
171
|
for calendar in train_calendars:
|
|
166
172
|
brand = next(iter(i for i in brands if i["id"] == calendar["trainBrand"]), {}).get("logo_text", "")
|
|
167
|
-
parts = [
|
|
173
|
+
parts = [
|
|
174
|
+
f"[red]{brand}[/red] [bold blue]{calendar['train_nr']}{" "+ v if (v:=calendar.get("train_name")) else ""}[/bold blue]:"
|
|
175
|
+
]
|
|
168
176
|
for k, v in calendar["date_train_map"].items():
|
|
169
177
|
parts.append(f" [bold green]{k}[/bold green]: [purple]{v}[/purple]")
|
|
170
178
|
self.print("\n".join(parts))
|
|
171
179
|
|
|
172
180
|
def train_info(self, brand: str, name: str, date: datetime):
|
|
173
181
|
train_calendars = self.get_train_calendars(brand, name)
|
|
174
|
-
if not (train_id:=train_calendars[0]["date_train_map"].get(date.strftime("%Y-%m-%d"))):
|
|
182
|
+
if not (train_id := train_calendars[0]["date_train_map"].get(date.strftime("%Y-%m-%d"))):
|
|
175
183
|
self.print(f"[bold red]This train doesn't run on the selected date: {date.strftime("%Y-%m-%d")}[/bold red]")
|
|
176
184
|
exit(2)
|
|
177
185
|
self.train_detail(train_id)
|
|
@@ -182,7 +190,8 @@ class CLI:
|
|
|
182
190
|
brand = next(iter(i for i in brands if i["id"] == train_details["train"]["brand_id"]), {}).get("logo_text", "")
|
|
183
191
|
|
|
184
192
|
parts = [f"[red]{brand}[/red] [bold blue]{train_details["train"]["train_full_name"]}[/bold blue]"]
|
|
185
|
-
|
|
193
|
+
if train_details["train"]["run_desc"]:
|
|
194
|
+
parts.append(f" {train_details["train"]["run_desc"]}")
|
|
186
195
|
|
|
187
196
|
route_start = arr_dep_to_dt(train_details["stops"][0]["departure"])
|
|
188
197
|
route_end = arr_dep_to_dt(train_details["stops"][-1]["arrival"])
|
koleo/storage.py
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
koleo/__init__.py,sha256=N_IkOBZCSPCCw31Hu72CFys707PziGFmXpNVl0CXAz8,47
|
|
2
|
+
koleo/__main__.py,sha256=wu5N2wk8mvBgyvr2ghmQf4prezAe0_i-p123VVreyYc,62
|
|
3
|
+
koleo/api.py,sha256=07PSwLFmirdJ_JhPBJ7rO1nv_v90njIcwmOoxT4P_4M,5708
|
|
4
|
+
koleo/cli.py,sha256=5QmvtqjB7kirt1iEG5SZDzOV6QTHTiJMNRtJoZa2Jik,23678
|
|
5
|
+
koleo/storage.py,sha256=L31IrXxdWiGGOraVBdFeHc1Z-a2fNvyRn-uC7gJWe9E,2305
|
|
6
|
+
koleo/types.py,sha256=pjVCIH39rUNeipazeRKOuTRCWoslLdbGivKiQmfd5Pw,5226
|
|
7
|
+
koleo/utils.py,sha256=CsYWNf3IPhHJln445tzXSA7r2z3NpmqVSmw8Rrb7YT0,1822
|
|
8
|
+
koleo_cli-0.2.137.12.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
9
|
+
koleo_cli-0.2.137.12.dist-info/METADATA,sha256=WAaZyvFSeL7O3M2Ss9YNz2SyyPTW3m7tzU8KKdY-pnY,3096
|
|
10
|
+
koleo_cli-0.2.137.12.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
|
11
|
+
koleo_cli-0.2.137.12.dist-info/entry_points.txt,sha256=LtCidkVDq8Zd7-fxpRbys1Xa9LTHMZwXVbdcQEscdes,41
|
|
12
|
+
koleo_cli-0.2.137.12.dist-info/top_level.txt,sha256=AlWdXotkRYzHpFfOBYi6xOXl1H0zq4-tqtZ2XivoWB4,6
|
|
13
|
+
koleo_cli-0.2.137.12.dist-info/RECORD,,
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
koleo/__init__.py,sha256=N_IkOBZCSPCCw31Hu72CFys707PziGFmXpNVl0CXAz8,47
|
|
2
|
-
koleo/__main__.py,sha256=wu5N2wk8mvBgyvr2ghmQf4prezAe0_i-p123VVreyYc,62
|
|
3
|
-
koleo/api.py,sha256=07PSwLFmirdJ_JhPBJ7rO1nv_v90njIcwmOoxT4P_4M,5708
|
|
4
|
-
koleo/cli.py,sha256=ixTi_44y-j4Yf_cgpZz-9iI5sH1pdyaqHRV-WtqzLbQ,23500
|
|
5
|
-
koleo/storage.py,sha256=U1ydt8AZ3WsiNBOmThD-cxomLzLrpHRG4BZbMg-14Fc,2304
|
|
6
|
-
koleo/types.py,sha256=pjVCIH39rUNeipazeRKOuTRCWoslLdbGivKiQmfd5Pw,5226
|
|
7
|
-
koleo/utils.py,sha256=CsYWNf3IPhHJln445tzXSA7r2z3NpmqVSmw8Rrb7YT0,1822
|
|
8
|
-
koleo_cli-0.2.137.11.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
9
|
-
koleo_cli-0.2.137.11.dist-info/METADATA,sha256=G2q-fowwyDNeu6aY9osXfKDV8vZu9VKJa0CB46NoifY,3096
|
|
10
|
-
koleo_cli-0.2.137.11.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
|
11
|
-
koleo_cli-0.2.137.11.dist-info/entry_points.txt,sha256=LtCidkVDq8Zd7-fxpRbys1Xa9LTHMZwXVbdcQEscdes,41
|
|
12
|
-
koleo_cli-0.2.137.11.dist-info/top_level.txt,sha256=AlWdXotkRYzHpFfOBYi6xOXl1H0zq4-tqtZ2XivoWB4,6
|
|
13
|
-
koleo_cli-0.2.137.11.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|