koleo-cli 0.2.137.20__tar.gz → 0.2.137.22__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.

Files changed (34) hide show
  1. {koleo_cli-0.2.137.20/koleo_cli.egg-info → koleo_cli-0.2.137.22}/PKG-INFO +1 -1
  2. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo/cli/base.py +14 -0
  3. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo/cli/train_info.py +5 -9
  4. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22/koleo_cli.egg-info}/PKG-INFO +1 -1
  5. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/setup.py +1 -1
  6. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/LICENSE +0 -0
  7. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/MANIFEST.in +0 -0
  8. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/README.md +0 -0
  9. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo/__init__.py +0 -0
  10. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo/__main__.py +0 -0
  11. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo/api/__init__.py +0 -0
  12. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo/api/base.py +0 -0
  13. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo/api/client.py +0 -0
  14. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo/api/errors.py +0 -0
  15. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo/api/logging.py +0 -0
  16. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo/api/types.py +0 -0
  17. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo/args.py +0 -0
  18. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo/cli/__init__.py +0 -0
  19. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo/cli/aliases.py +0 -0
  20. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo/cli/connections.py +0 -0
  21. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo/cli/seats.py +0 -0
  22. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo/cli/station_board.py +0 -0
  23. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo/cli/stations.py +0 -0
  24. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo/cli/utils.py +0 -0
  25. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo/storage.py +0 -0
  26. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo/utils.py +0 -0
  27. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo_cli.egg-info/SOURCES.txt +0 -0
  28. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo_cli.egg-info/dependency_links.txt +0 -0
  29. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo_cli.egg-info/entry_points.txt +0 -0
  30. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo_cli.egg-info/requires.txt +0 -0
  31. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/koleo_cli.egg-info/top_level.txt +0 -0
  32. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/pyproject.toml +0 -0
  33. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/requirements.txt +0 -0
  34. {koleo_cli-0.2.137.20 → koleo_cli-0.2.137.22}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: koleo-cli
3
- Version: 0.2.137.20
3
+ Version: 0.2.137.22
4
4
  Summary: Koleo CLI
5
5
  Home-page: https://github.com/lzgirlcat/koleo-cli
6
6
  Author: Zoey !
@@ -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 = brand.upper().strip()
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
- brands = await self.get_brands()
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(" ", "-", 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/{brand_obj["name"]}/{train_details["train"]["train_full_name"].replace(" ", "-")}"
99
+ f"https://koleo.pl/pociag/{url_brand}/{train_details["train"]["train_full_name"].replace(" ", "-", 1).replace(" ", "%20")}"
104
100
  )
105
101
  if date:
106
102
  link += f"/{date}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: koleo-cli
3
- Version: 0.2.137.20
3
+ Version: 0.2.137.22
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.20",
17
+ version="0.2.137.22",
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