kattis-cli 1.2.6__tar.gz → 1.2.7__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.
Files changed (43) hide show
  1. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/PKG-INFO +1 -1
  2. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/pyproject.toml +1 -1
  3. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/.kattis-cli.toml +2 -2
  4. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/main.py +15 -1
  5. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/solution_tester.py +19 -1
  6. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/utils/run_program.py +18 -3
  7. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/LICENSE +0 -0
  8. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/README.md +0 -0
  9. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/__init__.py +0 -0
  10. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/client.py +0 -0
  11. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/download.py +0 -0
  12. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/fireworks.py +0 -0
  13. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis.py +0 -0
  14. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_setup.py +0 -0
  15. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/__init__.py +0 -0
  16. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/main/c.txt +0 -0
  17. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/main/cpp.txt +0 -0
  18. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/main/java.txt +0 -0
  19. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/main/python.txt +0 -0
  20. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/main/python3.txt +0 -0
  21. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/c/Makefile +0 -0
  22. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/c/src/problemid/problemid.c +0 -0
  23. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/c/tests/test_problemid.c +0 -0
  24. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/cpp/Makefile +0 -0
  25. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/cpp/src/problemid.cpp +0 -0
  26. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/cpp/tests/test_problemid.cpp +0 -0
  27. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/java/src/problemid.java +0 -0
  28. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/java/tests/tests_problemid.java +0 -0
  29. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/python/Makefile +0 -0
  30. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/python/src/problemid.py +0 -0
  31. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/python/tests/__init__.py +0 -0
  32. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/python/tests/test_problemid.py +0 -0
  33. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/python3/Makefile +0 -0
  34. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/python3/src/problemid.py +0 -0
  35. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/python3/tests/__init__.py +0 -0
  36. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/kattis_templates/project_structure/python3/tests/test_problemid.py +0 -0
  37. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/settings.py +0 -0
  38. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/template.py +0 -0
  39. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/ui.py +0 -0
  40. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/utils/__init__.py +0 -0
  41. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/utils/config.py +0 -0
  42. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/utils/languages.py +0 -0
  43. {kattis_cli-1.2.6 → kattis_cli-1.2.7}/src/kattis_cli/utils/utility.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kattis-cli
3
- Version: 1.2.6
3
+ Version: 1.2.7
4
4
  Summary: A command-line tool for Kattis
5
5
  License-File: LICENSE
6
6
  Author: Ram Basnet
@@ -2,7 +2,7 @@
2
2
  # PEP 621 metadata table for tools that expect [project].
3
3
  [project]
4
4
  name = "kattis-cli"
5
- version = "1.2.6"
5
+ version = "1.2.7"
6
6
  description = "A command-line tool for Kattis"
7
7
  readme = "README.md"
8
8
  authors = [
@@ -15,12 +15,12 @@ execute = "python3 {mainfile}"
15
15
  mainfile = "{problemid}.py"
16
16
 
17
17
  [cpp]
18
- compile = "g++ -g -O2 -std=c++17 -Wall"
18
+ compile = "g++ -g -O2 -std=gnu++23 -static -lrt -Wl,--whole-archive -lpthread -Wl,--no-whole-archive"
19
19
  execute = "./a.out"
20
20
  mainfile = "{problemid}.cpp"
21
21
 
22
22
  [c]
23
- compile = "gcc -g -O2 -std=gnu11 -Wall"
23
+ compile = "gcc -g -O2 -std=gnu23 -static -lm"
24
24
  execute = "./a.out"
25
25
  mainfile = "{problemid}.c"
26
26
 
@@ -2,10 +2,11 @@
2
2
 
3
3
  Change the __version__ to match in pyproject.toml
4
4
  """
5
- __version__ = '1.2.6'
5
+ __version__ = '1.2.7'
6
6
 
7
7
  from math import inf
8
8
  import os
9
+ from urllib.parse import urlparse
9
10
  from typing import Tuple
10
11
  from rich.console import Console
11
12
  import click
@@ -30,11 +31,24 @@ def main() -> None:
30
31
  pass
31
32
 
32
33
 
34
+ def _normalize_problemid(problemid: str) -> str:
35
+ """Return a raw Kattis problem id from an id or full problem URL."""
36
+ parsed = urlparse(problemid)
37
+ if not parsed.scheme or not parsed.netloc:
38
+ return problemid
39
+
40
+ path_parts = [part for part in parsed.path.split('/') if part]
41
+ if not path_parts:
42
+ return problemid
43
+ return path_parts[-1]
44
+
45
+
33
46
  @main.command(help='Download sample data & metadata.')
34
47
  @click.argument('problemid')
35
48
  def get(problemid: str) -> None:
36
49
  """Command Line Interface for Kattis.
37
50
  """
51
+ problemid = _normalize_problemid(problemid)
38
52
  console = Console()
39
53
  console.print(
40
54
  f"Downloading metadata: [bold blue]{problemid}[/bold blue]")
@@ -7,6 +7,7 @@ delegator for backward compatibility with the previous procedural API.
7
7
  from typing import Any, List, Dict, Optional
8
8
  from math import inf
9
9
  import glob
10
+ import shlex
10
11
  import time
11
12
  import os
12
13
  from pathlib import Path
@@ -77,15 +78,22 @@ class SolutionTester:
77
78
  console.print("No sample input files found!", style="bold red")
78
79
  exit(1)
79
80
  in_files.sort()
81
+ compile_command = None
80
82
  if lang_config['compile']:
83
+ compile_command = run_program.build_compile_command(
84
+ lang_config,
85
+ files,
86
+ )
81
87
  ex_code, ans, error = run_program.compile_program(
82
88
  lang_config,
83
89
  files,
84
90
  )
85
91
  if ex_code != 0: # compilation error; exit code
92
+ console.print(
93
+ f"Compile command: {shlex.join(compile_command)}",
94
+ style='bold blue')
86
95
  console.print(escape(error), style='bold red')
87
96
  exit(1)
88
- console.print('Compiled successfully!', style='bold green')
89
97
 
90
98
  count = 0
91
99
  total = len(in_files)
@@ -94,6 +102,16 @@ class SolutionTester:
94
102
  main_src_file = next((f for f in files if f.endswith(mainclass)), None)
95
103
  if not main_src_file:
96
104
  main_src_file = mainclass
105
+ run_command = run_program.build_run_command(lang_config, main_src_file)
106
+
107
+ if compile_command:
108
+ console.print(
109
+ f"Compile command: {shlex.join(compile_command)}",
110
+ style='bold blue')
111
+ console.print('Compiled successfully!', style='bold green')
112
+ console.print(
113
+ f"Run command: {shlex.join(run_command)}",
114
+ style='bold blue')
97
115
 
98
116
  title += f" using {loc_language} 👷‍[/]"
99
117
  table.title = title
@@ -1,10 +1,26 @@
1
1
  """Run the program with the given input file and return the output.
2
2
  """
3
3
 
4
+ import shlex
4
5
  import subprocess
5
6
  from typing import Tuple, List, Dict, Any
6
7
 
7
8
 
9
+ def build_compile_command(
10
+ lang_config: Dict[Any, Any], files: List[str]) -> List[str]:
11
+ """Build the compile command for the configured language."""
12
+ command = shlex.split(lang_config['compile'])
13
+ command.extend(files)
14
+ return command
15
+
16
+
17
+ def build_run_command(
18
+ lang_config: Dict[Any, Any], mainclass: str) -> List[str]:
19
+ """Build the run command for the configured language."""
20
+ return shlex.split(
21
+ lang_config['execute'].replace("{mainfile}", mainclass))
22
+
23
+
8
24
  def compile_program(
9
25
  lang_config: Dict[Any, Any], files: List[str]) -> Tuple[int, str, str]:
10
26
  """Compile Program.
@@ -13,8 +29,7 @@ def compile_program(
13
29
  lang_config (Dict[Any, Any]): language config
14
30
  files (List[str]): List of files
15
31
  """
16
- command = lang_config['compile'].split()
17
- command.extend(files)
32
+ command = build_compile_command(lang_config, files)
18
33
  # print(f'{command=}')
19
34
  # print(f'{files}')
20
35
  # Set the g++ command and its arguments in a list
@@ -48,7 +63,7 @@ def run(lang_config: Dict[Any, Any],
48
63
  Tuple[str, str]: program output and error
49
64
  """
50
65
 
51
- program = lang_config['execute'].replace("{mainfile}", mainclass).split()
66
+ program = build_run_command(lang_config, mainclass)
52
67
  # print(f'{program=}')
53
68
  code, ans, error = execute(program, input_file)
54
69
  return code, ans, error
File without changes
File without changes