koleo-cli 0.2.137.10__tar.gz → 0.2.137.12__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: koleo-cli
3
- Version: 0.2.137.10
3
+ Version: 0.2.137.12
4
4
  Summary: Koleo CLI
5
5
  Home-page: https://github.com/lzgirlcat/koleo-cli
6
6
  Author: Zoey !
@@ -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['id'], date)
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['id'], date)
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(train[0]["departure"] if train[1] == 1 else train[0]["arrival"]).timestamp()
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 = f"[bold green]{train['departure'][11:16]}[/bold green]" if type == 1 else f"[bold yellow]{train['arrival'][11:16]}[/bold yellow]"
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 = [f"[red]{brand}[/red] [bold blue]{calendar['train_nr']}{" "+ v if (v:=calendar.get("train_name")) else ""}[/bold blue]:"]
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
- parts.append(f" {train_details["train"]["run_desc"]}")
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"])
@@ -241,11 +250,8 @@ class CLI:
241
250
  dep = arr_dep_to_dt(i["departure"])
242
251
  travel_time = (arr - dep).seconds
243
252
  parts.append(
244
- f"[bold green][link=https://koleo.pl/travel-options/{i["id"]}]{dep.strftime("%H:%M")} - {arr.strftime("%H:%M")}[/bold green] {travel_time//3600}h{(travel_time % 3600)/60:.0f}m {i['distance']}km: [/link]"
253
+ f"[bold green][link=https://koleo.pl/travel-options/{i["id"]}]{dep.strftime("%H:%M")} - {arr.strftime("%H:%M")}[/bold green] {travel_time//3600}h{(travel_time % 3600)/60:.0f}m {i['distance']}km:[/link]"
245
254
  )
246
- if i["constriction_info"]:
247
- for constriction in i["constriction_info"]:
248
- parts.append(f" [bold red]- {constriction} [/bold red]")
249
255
  if len(i["trains"]) == 1:
250
256
  train = i["trains"][0]
251
257
  stop = next(iter(i for i in train["stops"] if i["station_id"] == train["start_station_id"]), {})
@@ -258,10 +264,15 @@ class CLI:
258
264
  )
259
265
  )
260
266
  brand = next(iter(i for i in api_brands if i["id"] == train["brand_id"]), {}).get("logo_text")
267
+ s = f" [red]{brand}[/red] {train["train_full_name"]}[purple] {stop_station['name']} {self.format_position(stop["platform"], stop["track"])}[/purple]"
261
268
  parts[-1] += (
262
269
  f" [red]{brand}[/red] {train["train_full_name"]}[purple] {stop_station['name']} {self.format_position(stop["platform"], stop["track"])}[/purple]"
263
270
  )
271
+ for constriction in i["constriction_info"]:
272
+ parts.append(f" [bold red]- {constriction}[/bold red]")
264
273
  else:
274
+ for constriction in i["constriction_info"]:
275
+ parts.append(f" [bold red]- {constriction}[/bold red]")
265
276
  previous_arrival: datetime | None = None
266
277
  for train in i["trains"]:
267
278
  brand = next(iter(i for i in api_brands if i["id"] == train["brand_id"]), {}).get("logo_text")
@@ -81,4 +81,4 @@ class Storage:
81
81
  copy = self.cache.copy()
82
82
  self.cache = {k: data for k, data in copy.items() if data[0] > now}
83
83
  if copy != self.cache:
84
- self._dirty = True
84
+ self._dirty = True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: koleo-cli
3
- Version: 0.2.137.10
3
+ Version: 0.2.137.12
4
4
  Summary: Koleo CLI
5
5
  Home-page: https://github.com/lzgirlcat/koleo-cli
6
6
  Author: Zoey !
@@ -14,7 +14,7 @@ def parse_requirements_file(path):
14
14
 
15
15
  setuptools.setup(
16
16
  name="koleo-cli",
17
- version="0.2.137.10",
17
+ version="0.2.137.12",
18
18
  description="Koleo CLI",
19
19
  long_description=long_description(),
20
20
  long_description_content_type="text/markdown",
File without changes
File without changes
File without changes