kattis-cli 1.1.0__py3-none-any.whl → 1.1.2__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.
- kattis_cli/client.py +2 -4
- kattis_cli/download.py +5 -6
- kattis_cli/fireworks.py +2 -11
- kattis_cli/main.py +7 -8
- kattis_cli/utils/languages.py +11 -5
- kattis_cli/utils/utility.py +2 -0
- {kattis_cli-1.1.0.dist-info → kattis_cli-1.1.2.dist-info}/METADATA +1 -1
- {kattis_cli-1.1.0.dist-info → kattis_cli-1.1.2.dist-info}/RECORD +11 -11
- {kattis_cli-1.1.0.dist-info → kattis_cli-1.1.2.dist-info}/WHEEL +0 -0
- {kattis_cli-1.1.0.dist-info → kattis_cli-1.1.2.dist-info}/entry_points.txt +0 -0
- {kattis_cli-1.1.0.dist-info → kattis_cli-1.1.2.dist-info}/licenses/LICENSE +0 -0
kattis_cli/client.py
CHANGED
|
@@ -5,8 +5,8 @@ Object-oriented Kattis API client.
|
|
|
5
5
|
This class wraps login, submit and status-checking functionality previously
|
|
6
6
|
implemented as module-level functions in `kattis.py`.
|
|
7
7
|
"""
|
|
8
|
-
|
|
9
|
-
from typing import List, Any
|
|
8
|
+
|
|
9
|
+
from typing import List, Any
|
|
10
10
|
import sys
|
|
11
11
|
import os
|
|
12
12
|
import re
|
|
@@ -20,8 +20,6 @@ from rich.console import Console
|
|
|
20
20
|
from rich.align import Align
|
|
21
21
|
from rich.live import Live
|
|
22
22
|
from rich.prompt import Confirm
|
|
23
|
-
import subprocess
|
|
24
|
-
from pathlib import Path
|
|
25
23
|
|
|
26
24
|
from kattis_cli.utils import languages
|
|
27
25
|
from kattis_cli.utils import config
|
kattis_cli/download.py
CHANGED
|
@@ -42,7 +42,7 @@ class DownloadManager:
|
|
|
42
42
|
|
|
43
43
|
return root_problem_folder
|
|
44
44
|
|
|
45
|
-
def download_html(self, problemid: str) ->
|
|
45
|
+
def download_html(self, problemid: str) -> Any:
|
|
46
46
|
"""Download the problem HTML page for a given problem id.
|
|
47
47
|
|
|
48
48
|
Returns the HTML body as a stripped string when successful or
|
|
@@ -167,12 +167,11 @@ class DownloadManager:
|
|
|
167
167
|
uri = f'{settings.KATTIS_PROBLEM_URL}{problemid}'
|
|
168
168
|
uri += '/file/statement/samples.zip'
|
|
169
169
|
|
|
170
|
-
root_problem_folder = self.create_problem_folder(problemid)
|
|
171
|
-
|
|
172
|
-
data_folder = root_problem_folder.joinpath('data')
|
|
173
|
-
data_folder.mkdir(exist_ok=True)
|
|
174
170
|
response = requests.get(uri, allow_redirects=True, timeout=10)
|
|
175
171
|
if response.status_code == 200:
|
|
172
|
+
root_problem_folder = self.create_problem_folder(problemid)
|
|
173
|
+
data_folder = root_problem_folder.joinpath('data')
|
|
174
|
+
data_folder.mkdir(exist_ok=True)
|
|
176
175
|
zip_path = data_folder.joinpath('samples.zip')
|
|
177
176
|
with open(data_folder.joinpath('samples.zip'), 'wb') as f:
|
|
178
177
|
f.write(response.content)
|
|
@@ -197,7 +196,7 @@ def create_problem_folder(problemid: str) -> Path:
|
|
|
197
196
|
return _manager.create_problem_folder(problemid)
|
|
198
197
|
|
|
199
198
|
|
|
200
|
-
def download_html(problemid: str) ->
|
|
199
|
+
def download_html(problemid: str) -> Any:
|
|
201
200
|
"""Download problem HTML using the module-level manager."""
|
|
202
201
|
|
|
203
202
|
return _manager.download_html(problemid)
|
kattis_cli/fireworks.py
CHANGED
|
@@ -11,8 +11,6 @@ import sys
|
|
|
11
11
|
import locale
|
|
12
12
|
import time
|
|
13
13
|
from random import randint, choice
|
|
14
|
-
import subprocess
|
|
15
|
-
from pathlib import Path
|
|
16
14
|
|
|
17
15
|
|
|
18
16
|
def run_fireworks() -> None:
|
|
@@ -21,10 +19,9 @@ def run_fireworks() -> None:
|
|
|
21
19
|
Draws random bursts in the terminal using ANSI colors. Works in CI/Docker
|
|
22
20
|
and avoids external dependencies.
|
|
23
21
|
"""
|
|
24
|
-
frames =
|
|
22
|
+
frames = 5
|
|
25
23
|
width = 60
|
|
26
24
|
height = 20
|
|
27
|
-
message = None
|
|
28
25
|
symbols = ['*', '•', '✶', '✸']
|
|
29
26
|
colors = [
|
|
30
27
|
'\x1b[37m', # white
|
|
@@ -61,12 +58,6 @@ def run_fireworks() -> None:
|
|
|
61
58
|
# Simple ASCII fallback symbols
|
|
62
59
|
symbols = ['*', '+', 'o', '.']
|
|
63
60
|
# Replace message with ASCII-only fallback if necessary
|
|
64
|
-
if message:
|
|
65
|
-
try:
|
|
66
|
-
message.encode('ascii')
|
|
67
|
-
except (UnicodeEncodeError, TypeError):
|
|
68
|
-
message = (message.encode('ascii', 'replace')
|
|
69
|
-
.decode('ascii'))
|
|
70
61
|
# Inform interactive users why we fell back (but avoid noisy logs
|
|
71
62
|
# in captured/non-interactive runs).
|
|
72
63
|
if sys.stdout.isatty():
|
|
@@ -108,7 +99,7 @@ def run_fireworks() -> None:
|
|
|
108
99
|
time.sleep(0.12)
|
|
109
100
|
|
|
110
101
|
# final message
|
|
111
|
-
msg =
|
|
102
|
+
msg = '🎉 Congratulations — Accepted! 🎉'
|
|
112
103
|
sys.stdout.write('\n')
|
|
113
104
|
if use_color:
|
|
114
105
|
sys.stdout.write('\x1b[1;33m')
|
kattis_cli/main.py
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
""" Main module for the kattis_cli package.
|
|
2
2
|
This is the main.py file for the kattis_cli package.
|
|
3
3
|
|
|
4
|
-
Change the contents
|
|
4
|
+
Change the contents in dev.py instead of in main.py.
|
|
5
5
|
build.sh script copies the contents of this file to main.py.
|
|
6
6
|
|
|
7
7
|
Change the __version__ to match in pyproject.toml
|
|
8
8
|
Has to be higher than the pypi version.
|
|
9
9
|
"""
|
|
10
|
-
__version__ = '1.1.
|
|
10
|
+
__version__ = '1.1.2'
|
|
11
11
|
|
|
12
12
|
from math import inf
|
|
13
13
|
from typing import Tuple
|
|
@@ -45,12 +45,11 @@ def get(problemid: str) -> None:
|
|
|
45
45
|
download.download_sample_data(problemid)
|
|
46
46
|
except requests.exceptions.InvalidURL:
|
|
47
47
|
console.print(
|
|
48
|
-
f"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
download.load_problem_metadata(problemid)
|
|
48
|
+
f"Problem ID: [bold red]{problemid}[/bold red] not found.")
|
|
49
|
+
else:
|
|
50
|
+
console.print(
|
|
51
|
+
f"Downloading metadata: [bold blue]{problemid}[/bold blue]")
|
|
52
|
+
download.load_problem_metadata(problemid)
|
|
54
53
|
|
|
55
54
|
|
|
56
55
|
@main.command(help='Show problem metadata.')
|
kattis_cli/utils/languages.py
CHANGED
|
@@ -13,6 +13,8 @@ from kattis_cli.utils.utility import find_problem_root_folder
|
|
|
13
13
|
|
|
14
14
|
LANGUAGE_GUESS = {
|
|
15
15
|
'.c': 'c',
|
|
16
|
+
'.h': 'c',
|
|
17
|
+
'.hpp': 'cpp',
|
|
16
18
|
'.c++': 'cpp',
|
|
17
19
|
'.cc': 'cpp',
|
|
18
20
|
'.c#': 'csharp',
|
|
@@ -129,6 +131,8 @@ def guess_language(ext: str, files: List[str]) -> str:
|
|
|
129
131
|
return "c"
|
|
130
132
|
else:
|
|
131
133
|
return "cpp"
|
|
134
|
+
if ext == '.hpp':
|
|
135
|
+
return "cpp"
|
|
132
136
|
if ext == ".py":
|
|
133
137
|
return "python3"
|
|
134
138
|
return LANGUAGE_GUESS.get(ext, '')
|
|
@@ -314,19 +318,21 @@ filename extension "{ext}"''')
|
|
|
314
318
|
return problemid, loc_language, mainclass, files, root_folder, lang_config
|
|
315
319
|
|
|
316
320
|
|
|
317
|
-
def get_coding_files() -> List[str]:
|
|
321
|
+
def get_coding_files(base_path: Path = Path.cwd()) -> List[str]:
|
|
318
322
|
"""Get coding files from current directory.
|
|
319
323
|
|
|
320
324
|
Returns:
|
|
321
325
|
List[str]: List of coding files.
|
|
322
326
|
"""
|
|
323
|
-
|
|
327
|
+
|
|
328
|
+
if Path(base_path / "src").is_dir():
|
|
329
|
+
base_path = base_path / "src"
|
|
324
330
|
console = Console()
|
|
325
|
-
files = [
|
|
326
|
-
|
|
331
|
+
files = [str(f) for f in base_path.rglob(
|
|
332
|
+
'*') if f.is_file() and valid_extension(str(f))]
|
|
327
333
|
if not files:
|
|
328
334
|
console.print(
|
|
329
|
-
'No source file(s) found in
|
|
335
|
+
f'No source file(s) found in {base_path}!',
|
|
330
336
|
style='bold red')
|
|
331
337
|
exit(1)
|
|
332
338
|
return files
|
kattis_cli/utils/utility.py
CHANGED
|
@@ -34,6 +34,8 @@ def find_problem_root_folder(
|
|
|
34
34
|
Returns:
|
|
35
35
|
bool: True if path exists, False otherwise
|
|
36
36
|
"""
|
|
37
|
+
if filename.startswith('/'):
|
|
38
|
+
filename = Path(filename).name
|
|
37
39
|
for file in path.glob(filename):
|
|
38
40
|
name, ext = os.path.splitext(file.name)
|
|
39
41
|
folder_name = path.parts[-1]
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
kattis_cli/.kattis-cli.toml,sha256=kGh0gmpFAnivyUC9hR8Y1ZqYJeTBWNyBQ9zOg4AInZ0,898
|
|
2
2
|
kattis_cli/__init__.py,sha256=afN92pog2fGyicY6KNBofYbCBYbYj4Fpi_INUSpsc-E,402
|
|
3
|
-
kattis_cli/client.py,sha256=
|
|
4
|
-
kattis_cli/download.py,sha256=
|
|
5
|
-
kattis_cli/fireworks.py,sha256=
|
|
3
|
+
kattis_cli/client.py,sha256=5ef-pq737q-VBBxY1F-bEbP9Mf8145YppL4m9NlVCVY,16938
|
|
4
|
+
kattis_cli/download.py,sha256=BATQskOUFyc286vDYY7S4nmBWPBrYsgHwCE1VBsltx0,8662
|
|
5
|
+
kattis_cli/fireworks.py,sha256=yKFXIvDDdNrzBhpEt2Pdy5zgfYjJffoOEf2yUFlu2TQ,4134
|
|
6
6
|
kattis_cli/kattis.py,sha256=wpnM6sC0a32kJYzEux27izug59bicexNnOFxcx0qWM8,2621
|
|
7
7
|
kattis_cli/kattis_setup.py,sha256=mic79GjOI_rC6Lfl5D5ORDMWdrcxR71ksYUM51yezu8,5659
|
|
8
|
-
kattis_cli/main.py,sha256=
|
|
8
|
+
kattis_cli/main.py,sha256=jRANFixHzJdnACp1Mzi5p5wxFrSF6FXFrPxLhn8olSc,4491
|
|
9
9
|
kattis_cli/settings.py,sha256=d5q4dYj9VqDSqPalleh2oZWtND-1bPB0T2IwdajFrBg,591
|
|
10
10
|
kattis_cli/solution_tester.py,sha256=hTXtryYs8lkO9CkSPtQNjhrAPPLaC4au5ueCQ3ioZWQ,7577
|
|
11
11
|
kattis_cli/ui.py,sha256=2qFWz9QB7cgjLfZKHrWUrKFVYLRLwl0c37ZTNljwmAI,4580
|
|
12
12
|
kattis_cli/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
13
|
kattis_cli/utils/config.py,sha256=6SIuiXA9sFADo8RZUj8A6rXb3uqmrWrmmArfZrqNQdw,2293
|
|
14
|
-
kattis_cli/utils/languages.py,sha256=
|
|
14
|
+
kattis_cli/utils/languages.py,sha256=gcJJJwkPS1Zpg76atwoo2O2Vd7ETKBQV-KD_cwclrmE,8928
|
|
15
15
|
kattis_cli/utils/run_program.py,sha256=NWQ6vtTeWgkaW75r91FIHGXR5cAbeu8yMb5hwzpYFsg,2613
|
|
16
|
-
kattis_cli/utils/utility.py,sha256=
|
|
17
|
-
kattis_cli-1.1.
|
|
18
|
-
kattis_cli-1.1.
|
|
19
|
-
kattis_cli-1.1.
|
|
20
|
-
kattis_cli-1.1.
|
|
21
|
-
kattis_cli-1.1.
|
|
16
|
+
kattis_cli/utils/utility.py,sha256=oUbydPbcC2wXvfku21YAWpaJjuBKaBRVybMAWCSfM9Y,2987
|
|
17
|
+
kattis_cli-1.1.2.dist-info/METADATA,sha256=SM1Ah1m_9WvKo-glbw1Xx-BnEwUSFFhxU6oCViGjUxc,6962
|
|
18
|
+
kattis_cli-1.1.2.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
19
|
+
kattis_cli-1.1.2.dist-info/entry_points.txt,sha256=kyzGN20VqUPR_H0J_jJUKT-10-cAMFLVegQ6C7tbHss,47
|
|
20
|
+
kattis_cli-1.1.2.dist-info/licenses/LICENSE,sha256=JmBa4SEKBCDWEgiOZcISU4tUCpli6xSpVlSYgkBXSNQ,1067
|
|
21
|
+
kattis_cli-1.1.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|