koleo-cli 0.2.137.20__tar.gz → 0.2.137.21__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.
Potentially problematic release.
This version of koleo-cli might be problematic. Click here for more details.
- {koleo_cli-0.2.137.20/koleo_cli.egg-info → koleo_cli-0.2.137.21}/PKG-INFO +1 -1
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo/cli/base.py +14 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo/cli/train_info.py +5 -9
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21/koleo_cli.egg-info}/PKG-INFO +1 -1
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/setup.py +1 -1
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/LICENSE +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/MANIFEST.in +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/README.md +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo/__init__.py +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo/__main__.py +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo/api/__init__.py +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo/api/base.py +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo/api/client.py +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo/api/errors.py +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo/api/logging.py +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo/api/types.py +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo/args.py +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo/cli/__init__.py +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo/cli/aliases.py +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo/cli/connections.py +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo/cli/seats.py +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo/cli/station_board.py +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo/cli/stations.py +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo/cli/utils.py +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo/storage.py +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo/utils.py +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo_cli.egg-info/SOURCES.txt +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo_cli.egg-info/dependency_links.txt +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo_cli.egg-info/entry_points.txt +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo_cli.egg-info/requires.txt +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/koleo_cli.egg-info/top_level.txt +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/pyproject.toml +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/requirements.txt +0 -0
- {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.21}/setup.cfg +0 -0
|
@@ -104,3 +104,17 @@ class BaseCli:
|
|
|
104
104
|
async def get_station_by_id(self, id: int):
|
|
105
105
|
key = f"st-{id}"
|
|
106
106
|
return self.storage.get_cache(key) or self.storage.set_cache(key, await self.client.get_station_by_id(id))
|
|
107
|
+
|
|
108
|
+
async def get_brand_by_shortcut(self, s: str, *, name: str | None = None):
|
|
109
|
+
brands = await self.get_brands()
|
|
110
|
+
s = s.upper()
|
|
111
|
+
if name and "SŁONECZNY" in name and s == "KM":
|
|
112
|
+
return "SLONECZNY" # OH MY FUCKING GOD
|
|
113
|
+
if s == "AR":
|
|
114
|
+
return "ARRIVARP"
|
|
115
|
+
if s not in [i["name"] for i in brands]:
|
|
116
|
+
res = {i["logo_text"]: i["name"] for i in brands}.get(s)
|
|
117
|
+
if not res:
|
|
118
|
+
await self.error_and_exit(f"Invalid brand name not found: [underline]{s},[/underline]")
|
|
119
|
+
return res
|
|
120
|
+
return s
|
|
@@ -8,7 +8,7 @@ from koleo.utils import koleo_time_to_dt
|
|
|
8
8
|
|
|
9
9
|
class TrainInfo(BaseCli):
|
|
10
10
|
async def get_train_calendars(self, brand: str, name: str) -> list[TrainCalendar]:
|
|
11
|
-
brand =
|
|
11
|
+
brand = await self.get_brand_by_shortcut(brand, name=name)
|
|
12
12
|
name_parts = name.split(" ")
|
|
13
13
|
if len(name_parts) == 1 and name_parts[0].isnumeric():
|
|
14
14
|
number = int(name_parts[0])
|
|
@@ -18,12 +18,7 @@ class TrainInfo(BaseCli):
|
|
|
18
18
|
train_name = " ".join(name_parts)
|
|
19
19
|
else:
|
|
20
20
|
raise ValueError("Invalid train name!")
|
|
21
|
-
|
|
22
|
-
if brand not in [i["name"] for i in brands]:
|
|
23
|
-
res = {i["logo_text"]: i["name"] for i in brands}.get(brand)
|
|
24
|
-
if not res:
|
|
25
|
-
raise ValueError("Invalid brand name!")
|
|
26
|
-
brand = res
|
|
21
|
+
|
|
27
22
|
cache_id = f"tc-{brand}-{number}-{name}"
|
|
28
23
|
try:
|
|
29
24
|
train_calendars = self.storage.get_cache(cache_id) or self.storage.set_cache(
|
|
@@ -38,7 +33,7 @@ class TrainInfo(BaseCli):
|
|
|
38
33
|
brands = await self.get_brands()
|
|
39
34
|
for calendar in train_calendars:
|
|
40
35
|
brand_obj = next(iter(i for i in brands if i["id"] == calendar["trainBrand"]), {})
|
|
41
|
-
link = f"https://koleo.pl/pociag/{brand_obj["name"]}/{name.replace(" ", "-")}"
|
|
36
|
+
link = f"https://koleo.pl/pociag/{brand_obj["name"]}/{name.replace(" ", "-", count=1).replace(" ", "%20")}"
|
|
42
37
|
brand = brand_obj.get("logo_text", "")
|
|
43
38
|
self.print(
|
|
44
39
|
f"[red][link={link}]{brand}[/red] [bold blue]{calendar['train_nr']}{" "+ v if (v:=calendar.get("train_name")) else ""}[/bold blue]:[/link]"
|
|
@@ -98,9 +93,10 @@ class TrainInfo(BaseCli):
|
|
|
98
93
|
brands = await self.get_brands()
|
|
99
94
|
brand_obj = next(iter(i for i in brands if i["id"] == train_details["train"]["brand_id"]), {})
|
|
100
95
|
brand = brand_obj.get("logo_text", "")
|
|
96
|
+
url_brand = await self.get_brand_by_shortcut(brand, name=train_details["train"]["train_full_name"])
|
|
101
97
|
|
|
102
98
|
link = (
|
|
103
|
-
f"https://koleo.pl/pociag/{
|
|
99
|
+
f"https://koleo.pl/pociag/{url_brand}/{train_details["train"]["train_full_name"].replace(" ", "-", count=1).replace(" ", "%20")}"
|
|
104
100
|
)
|
|
105
101
|
if date:
|
|
106
102
|
link += f"/{date}"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|