kattis-cli 1.2.0__py3-none-any.whl → 1.2.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.
@@ -0,0 +1,5 @@
1
+ import sys
2
+ import os
3
+
4
+ sys.path.insert(0, os.path.abspath(
5
+ os.path.join(os.path.dirname(__file__), '../src')))
@@ -0,0 +1,5 @@
1
+ import sys
2
+ import os
3
+
4
+ sys.path.insert(0, os.path.abspath(
5
+ os.path.join(os.path.dirname(__file__), '../src')))
kattis_cli/main.py CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Change the __version__ to match in pyproject.toml
4
4
  """
5
- __version__ = '1.2.0'
5
+ __version__ = '1.2.2'
6
6
 
7
7
  from math import inf
8
8
  import os
kattis_cli/template.py CHANGED
@@ -69,8 +69,8 @@ def create_template(
69
69
  shutil.copytree(str(src), home_templates)
70
70
  except Exception as e:
71
71
  console.print(
72
- f"[bold red]❌ Error:[/bold red] Could not \
73
- copy templates: {e}")
72
+ f"[bold red]❌ Could not \
73
+ copy templates: [/bold red] {e} ")
74
74
  return False
75
75
  return True
76
76
 
@@ -85,8 +85,8 @@ copy templates: {e}")
85
85
  console = Console()
86
86
  if not _check_kattis_templates():
87
87
  console.print(
88
- f"[bold red]❌ Error:[/bold red] Templates '{language}' \
89
- not found in {home_templates}!")
88
+ f"[bold red]❌ Templates '{language}' \
89
+ not found in [/bold red] {home_templates}! ")
90
90
  return
91
91
 
92
92
  def _copytree_with_problemid(src: str,
@@ -94,14 +94,18 @@ not found in {home_templates}!")
94
94
  problemid: str) -> None:
95
95
  for root, _, files in os.walk(src):
96
96
  rel = os.path.relpath(root, src)
97
- rel = rel.replace('problemid', problemid)
98
97
  target_root = os.path.join(dst, rel) if rel != '.' else dst
99
98
  os.makedirs(target_root, exist_ok=True)
100
99
  for f in files:
101
100
  src_file = os.path.join(root, f)
102
101
  dst_file = os.path.join(
103
102
  target_root, f.replace('problemid', problemid))
104
- shutil.copy2(src_file, dst_file)
103
+ if os.path.exists(dst_file):
104
+ console.print(
105
+ f"[bold yellow]⚠️ File \
106
+ '{dst_file}' exists. Skipping copy. [/bold yellow]")
107
+ else:
108
+ shutil.copy2(src_file, dst_file)
105
109
 
106
110
  # If src_layout, copy the project structure for the language
107
111
  if src_layout:
@@ -111,9 +115,9 @@ not found in {home_templates}!")
111
115
  _copytree_with_problemid(
112
116
  str(lang_src_struct), os.getcwd(), problemid)
113
117
  console.print(
114
- f"[bold blue]✅ [/bold blue] Created project \
115
- structure for {language}.")
116
- target_dir = os.path.join("src", problemid)
118
+ f"[bold green]✅ Created project \
119
+ structure for {language}. [/bold green]")
120
+ target_dir = os.path.join("src")
117
121
  else:
118
122
  target_dir = "."
119
123
 
@@ -125,8 +129,8 @@ structure for {language}.")
125
129
  template_content = tf.read()
126
130
  except OSError:
127
131
  console.print(
128
- f"[bold red] ❌ [/bold red] Could not read \
129
- template file: {main_template}")
132
+ f"[bold red] ❌ Could not read \
133
+ template file: {main_template} [/bold red]")
130
134
  return
131
135
 
132
136
  if not main_template:
@@ -141,21 +145,21 @@ template file: {main_template}")
141
145
  filename = f"{problemid}{extension}"
142
146
  content = template_content
143
147
 
144
- filepath = os.path.join(target_dir, filename)
148
+ dest_path = os.path.join(target_dir, filename)
145
149
 
146
- if os.path.exists(filepath) and os.path.getsize(filepath) > 0:
150
+ if os.path.exists(dest_path) and os.path.getsize(dest_path) > 0:
147
151
  console.print(
148
- f"[bold yellow]Warning:[/bold yellow] File '{filepath}' \
149
- exists with content. Skipping.")
152
+ f"[bold yellow]⚠️ File '{dest_path}' exists \
153
+ with content. Skipping. [/bold yellow]")
150
154
  return
151
155
 
152
156
  try:
153
- with open(filepath, 'w', encoding='utf-8') as f:
157
+ with open(dest_path, 'w', encoding='utf-8') as f:
154
158
  f.write(content)
155
159
  console.print(
156
- f"[bold green]✅ [/bold green] Created template \
157
- '{filepath}' for {language}.")
160
+ f"[bold green]✅ Created template \
161
+ '{dest_path}' for {language}.[/bold green]")
158
162
  except OSError as e:
159
163
  console.print(
160
- f"[bold red]❌ [/bold red] Failed to create template \
161
- '{filepath}': {e}")
164
+ f"[bold red]❌ Failed to create template \
165
+ '{dest_path}': {e} [/bold red]")
@@ -154,7 +154,7 @@ def guess_mainfile(
154
154
  str: main file
155
155
  """
156
156
  if len(files) == 1:
157
- return files[0]
157
+ return Path(files[0]).name
158
158
  # check .kattis-cli.toml file
159
159
  if 'mainfile' in lang_config:
160
160
  return lang_config['mainfile'].replace(('{problemid}'), problemid)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kattis-cli
3
- Version: 1.2.0
3
+ Version: 1.2.2
4
4
  Summary: A command-line tool for Kattis
5
5
  License-File: LICENSE
6
6
  Author: Ram Basnet
@@ -15,24 +15,30 @@ kattis_cli/kattis_templates/project_structure/c/Makefile,sha256=47DEQpj8HBSa-_TI
15
15
  kattis_cli/kattis_templates/project_structure/c/src/problemid/problemid.c,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  kattis_cli/kattis_templates/project_structure/c/tests/test_problemid.c,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  kattis_cli/kattis_templates/project_structure/cpp/Makefile,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
- kattis_cli/kattis_templates/project_structure/cpp/src/problemid/problemid.cpp,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
+ kattis_cli/kattis_templates/project_structure/cpp/src/problemid.cpp,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  kattis_cli/kattis_templates/project_structure/cpp/tests/test_problemid.cpp,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
+ kattis_cli/kattis_templates/project_structure/java/src/problemid.java,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
+ kattis_cli/kattis_templates/project_structure/java/tests/tests_problemid.java,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
+ kattis_cli/kattis_templates/project_structure/python/Makefile,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
+ kattis_cli/kattis_templates/project_structure/python/src/problemid.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
+ kattis_cli/kattis_templates/project_structure/python/tests/__init__.py,sha256=AMhJu7wP66tZlvKEDwSrdDdQDQ6ZmMQFWjKTPjCPNAg,114
25
+ kattis_cli/kattis_templates/project_structure/python/tests/test_problemid.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
26
  kattis_cli/kattis_templates/project_structure/python3/Makefile,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
- kattis_cli/kattis_templates/project_structure/python3/src/problemid/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
- kattis_cli/kattis_templates/project_structure/python3/src/problemid/problemid.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
+ kattis_cli/kattis_templates/project_structure/python3/src/problemid.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
+ kattis_cli/kattis_templates/project_structure/python3/tests/__init__.py,sha256=AMhJu7wP66tZlvKEDwSrdDdQDQ6ZmMQFWjKTPjCPNAg,114
23
29
  kattis_cli/kattis_templates/project_structure/python3/tests/test_problemid.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
- kattis_cli/main.py,sha256=d8-2R4r1_kHb52nfpydS_5dWgf32MVUiJwVAjljk8TA,4996
30
+ kattis_cli/main.py,sha256=ttBcYJd5atnsWf9VlJ-eMyjNVntnynQRteFQNFT7Zno,4996
25
31
  kattis_cli/settings.py,sha256=d5q4dYj9VqDSqPalleh2oZWtND-1bPB0T2IwdajFrBg,591
26
32
  kattis_cli/solution_tester.py,sha256=SQUq1Da06-_b9tTi0-CiTogscWje1Ur7KuaiK1Bxsgs,7860
27
- kattis_cli/template.py,sha256=QAbaQt9H9lPh8aOUMdl0B_vf2tZKL3mh9qdw7G-kw3g,5274
33
+ kattis_cli/template.py,sha256=63KdxOnDcv7vFFD11zVDvdc_2vKJB_MT5ynI9_jc0Tg,5421
28
34
  kattis_cli/ui.py,sha256=2qFWz9QB7cgjLfZKHrWUrKFVYLRLwl0c37ZTNljwmAI,4580
29
35
  kattis_cli/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
36
  kattis_cli/utils/config.py,sha256=sR6lbRl9KiXRKIV1zRP5s6KJ9jed0znilsHSBS-_G2k,2278
31
- kattis_cli/utils/languages.py,sha256=GQjos4VKkyEBySPaOK1SFsWTqIIWdld0O_VHG-YEgi4,8977
37
+ kattis_cli/utils/languages.py,sha256=6Oc1RgYs7CWFzMO_VzahG3J0vixz40hlnxx3pFP2T24,8988
32
38
  kattis_cli/utils/run_program.py,sha256=NWQ6vtTeWgkaW75r91FIHGXR5cAbeu8yMb5hwzpYFsg,2613
33
39
  kattis_cli/utils/utility.py,sha256=oUbydPbcC2wXvfku21YAWpaJjuBKaBRVybMAWCSfM9Y,2987
34
- kattis_cli-1.2.0.dist-info/METADATA,sha256=EuWgm_1VbuCG0OCUR2qzd9xbBEuGNcWBOrmEGwCqHtI,7206
35
- kattis_cli-1.2.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
36
- kattis_cli-1.2.0.dist-info/entry_points.txt,sha256=kyzGN20VqUPR_H0J_jJUKT-10-cAMFLVegQ6C7tbHss,47
37
- kattis_cli-1.2.0.dist-info/licenses/LICENSE,sha256=JmBa4SEKBCDWEgiOZcISU4tUCpli6xSpVlSYgkBXSNQ,1067
38
- kattis_cli-1.2.0.dist-info/RECORD,,
40
+ kattis_cli-1.2.2.dist-info/METADATA,sha256=-2CjIC_6xg5YJ6P82I2YiqXdvShrQGy8ny2cdzN9SBw,7206
41
+ kattis_cli-1.2.2.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
42
+ kattis_cli-1.2.2.dist-info/entry_points.txt,sha256=kyzGN20VqUPR_H0J_jJUKT-10-cAMFLVegQ6C7tbHss,47
43
+ kattis_cli-1.2.2.dist-info/licenses/LICENSE,sha256=JmBa4SEKBCDWEgiOZcISU4tUCpli6xSpVlSYgkBXSNQ,1067
44
+ kattis_cli-1.2.2.dist-info/RECORD,,