koleo-cli 0.2.137.4__py3-none-any.whl → 0.2.137.5__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 +14 -11
- {koleo_cli-0.2.137.4.dist-info → koleo_cli-0.2.137.5.dist-info}/METADATA +1 -1
- {koleo_cli-0.2.137.4.dist-info → koleo_cli-0.2.137.5.dist-info}/RECORD +6 -6
- {koleo_cli-0.2.137.4.dist-info → koleo_cli-0.2.137.5.dist-info}/WHEEL +0 -0
- {koleo_cli-0.2.137.4.dist-info → koleo_cli-0.2.137.5.dist-info}/entry_points.txt +0 -0
- {koleo_cli-0.2.137.4.dist-info → koleo_cli-0.2.137.5.dist-info}/top_level.txt +0 -0
koleo/cli.py
CHANGED
|
@@ -106,15 +106,14 @@ class CLI:
|
|
|
106
106
|
for st in stations:
|
|
107
107
|
self.print(f"[bold blue][link=https://koleo.pl/dworzec-pkp/{st["name_slug"]}]{st["name"]}[/bold blue] ID: {st["id"]}[/link]")
|
|
108
108
|
|
|
109
|
-
def train_info(self, brand: str, name: str, date: datetime):
|
|
109
|
+
def train_info(self, brand: str, name: list[str], date: datetime):
|
|
110
110
|
brand = brand.upper().strip()
|
|
111
|
-
name
|
|
112
|
-
|
|
113
|
-
number = int(name)
|
|
111
|
+
if len(name) == 1 and name[0].isnumeric():
|
|
112
|
+
number = int(name[0])
|
|
114
113
|
train_name = ""
|
|
115
|
-
elif len(
|
|
116
|
-
number
|
|
117
|
-
|
|
114
|
+
elif len(name) > 1:
|
|
115
|
+
number = int(name.pop(0))
|
|
116
|
+
train_name = " ".join(name)
|
|
118
117
|
else:
|
|
119
118
|
raise ValueError("Invalid train name!")
|
|
120
119
|
brands = self.storage.get_cache("brands") or self.storage.set_cache("brands", self.client.get_brands())
|
|
@@ -124,9 +123,13 @@ class CLI:
|
|
|
124
123
|
raise ValueError("Invalid brand name!")
|
|
125
124
|
brand = res
|
|
126
125
|
cache_id = f"tc-{brand}-{number}-{name}"
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
try:
|
|
127
|
+
train_calendars = self.storage.get_cache(cache_id) or self.storage.set_cache(
|
|
128
|
+
cache_id, self.client.get_train_calendars(brand, number, train_name)
|
|
129
|
+
)
|
|
130
|
+
except self.client.errors.KoleoNotFound:
|
|
131
|
+
self.print(f'[bold red]Train not found: nr={number}, name="{train_name}"[/bold red]')
|
|
132
|
+
exit(2)
|
|
130
133
|
train_id = train_calendars["train_calendars"][0]["date_train_map"][date.strftime("%Y-%m-%d")]
|
|
131
134
|
train_details = self.client.get_train(train_id)
|
|
132
135
|
brand = next(iter(i for i in brands if i["id"] == train_details["train"]["brand_id"]), {}).get("logo_text", "")
|
|
@@ -311,7 +314,7 @@ def main():
|
|
|
311
314
|
help="Allows you to show the train's route",
|
|
312
315
|
)
|
|
313
316
|
train_route.add_argument("brand", help="The brand name", type=str)
|
|
314
|
-
train_route.add_argument("name", help="The train name", type=str)
|
|
317
|
+
train_route.add_argument("name", help="The train name", type=str, nargs="+")
|
|
315
318
|
train_route.add_argument(
|
|
316
319
|
"-d",
|
|
317
320
|
"--date",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
koleo/__init__.py,sha256=N_IkOBZCSPCCw31Hu72CFys707PziGFmXpNVl0CXAz8,47
|
|
2
2
|
koleo/__main__.py,sha256=wu5N2wk8mvBgyvr2ghmQf4prezAe0_i-p123VVreyYc,62
|
|
3
3
|
koleo/api.py,sha256=3pVcAMnCzaDIgakxagmKOZpph8JU5p6agXKGw550rkw,5710
|
|
4
|
-
koleo/cli.py,sha256=
|
|
4
|
+
koleo/cli.py,sha256=pnKtWnD7DPre5tVQJ9Okp3_OWqaRDPCL7hh3SVxo9bg,18247
|
|
5
5
|
koleo/storage.py,sha256=l48A8zsP3t77nFZA23dDncoeyV_VlhJ1RvM3xjWug2Q,2001
|
|
6
6
|
koleo/types.py,sha256=PQDDaTF9Q6ZylcOupWrOWg0qWMqRrNhMOE5m_bl8fVo,5219
|
|
7
7
|
koleo/utils.py,sha256=ejJpHnFYDPbxa3Wd_q92cTkwbkXhGvwFGKoGITBSrdY,1615
|
|
8
|
-
koleo_cli-0.2.137.
|
|
9
|
-
koleo_cli-0.2.137.
|
|
10
|
-
koleo_cli-0.2.137.
|
|
11
|
-
koleo_cli-0.2.137.
|
|
12
|
-
koleo_cli-0.2.137.
|
|
8
|
+
koleo_cli-0.2.137.5.dist-info/METADATA,sha256=9lGPhSlMhq-6eFzafIu_CH2LF1jOVyhbgb5yDWdM7O4,626
|
|
9
|
+
koleo_cli-0.2.137.5.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
10
|
+
koleo_cli-0.2.137.5.dist-info/entry_points.txt,sha256=LtCidkVDq8Zd7-fxpRbys1Xa9LTHMZwXVbdcQEscdes,41
|
|
11
|
+
koleo_cli-0.2.137.5.dist-info/top_level.txt,sha256=AlWdXotkRYzHpFfOBYi6xOXl1H0zq4-tqtZ2XivoWB4,6
|
|
12
|
+
koleo_cli-0.2.137.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|