rbx.cp 0.5.6__py3-none-any.whl → 0.5.9__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.
rbx/box/contest/main.py CHANGED
@@ -3,6 +3,7 @@ import shutil
3
3
  import subprocess
4
4
  from typing import Annotated, Optional
5
5
 
6
+ import rich.prompt
6
7
  import typer
7
8
 
8
9
  from rbx import annotations, console, utils
@@ -38,7 +39,7 @@ app.add_typer(
38
39
 
39
40
  @app.command('create, c', help='Create a new contest package.')
40
41
  def create(
41
- name: str,
42
+ path: str,
42
43
  preset: Annotated[
43
44
  str,
44
45
  typer.Option(
@@ -54,7 +55,7 @@ def create(
54
55
  help='Whether to inline the installed preset within the contest folder.',
55
56
  ),
56
57
  ):
57
- console.console.print(f'Creating new contest [item]{name}[/item]...')
58
+ console.console.print(f'Creating new contest at [item]{path}[/item]...')
58
59
 
59
60
  fetch_info = get_preset_fetch_info(preset)
60
61
  if fetch_info is None:
@@ -85,17 +86,24 @@ def create(
85
86
  )
86
87
  raise typer.Exit(1)
87
88
 
88
- dest_path = pathlib.Path(name)
89
+ dest_path = pathlib.Path(path)
89
90
 
90
91
  if dest_path.exists():
91
- console.console.print(
92
- f'[error]Directory [item]{dest_path}[/item] already exists.[/error]'
93
- )
94
- raise typer.Exit(1)
95
-
96
- shutil.copytree(str(contest_path), str(dest_path))
92
+ if not rich.prompt.Confirm.ask(
93
+ f'Directory [item]{dest_path}[/item] already exists. Create contest in it? This might be destructive.',
94
+ show_default=False,
95
+ console=console.console,
96
+ ):
97
+ console.console.print(
98
+ f'[error]Directory [item]{dest_path}[/item] already exists.[/error]'
99
+ )
100
+ raise typer.Exit(1)
101
+
102
+ dest_path.mkdir(parents=True, exist_ok=True)
103
+ shutil.copytree(str(contest_path), str(dest_path), dirs_exist_ok=True)
97
104
  shutil.rmtree(str(dest_path / 'build'), ignore_errors=True)
98
105
  shutil.rmtree(str(dest_path / '.box'), ignore_errors=True)
106
+ shutil.rmtree(str(dest_path / '.local.rbx'), ignore_errors=True)
99
107
  # TODO: consider clearing build and .box recursively for nested problem directories
100
108
  for lock in dest_path.rglob('.preset-lock.yml'):
101
109
  lock.unlink(missing_ok=True)
@@ -120,7 +128,8 @@ def edit():
120
128
 
121
129
  @app.command('add, a', help='Add new problem to contest.')
122
130
  @within_contest
123
- def add(name: str, short_name: str, preset: Optional[str] = None):
131
+ def add(path: str, short_name: str, preset: Optional[str] = None):
132
+ name = pathlib.Path(path).stem
124
133
  utils.validate_field(ContestProblem, 'short_name', short_name)
125
134
  utils.validate_field(Package, 'name', name)
126
135
 
@@ -133,21 +142,21 @@ def add(name: str, short_name: str, preset: Optional[str] = None):
133
142
  preset_lock = presets.get_preset_lock()
134
143
  if preset is None and preset_lock is not None:
135
144
  preset = preset_lock.preset_name
136
- creation.create(name, preset=preset, path=pathlib.Path(name))
145
+ creation.create(name, preset=preset, path=pathlib.Path(path))
137
146
 
138
147
  contest = find_contest_package_or_die()
139
148
  # Reassign mutable object before saving.
140
149
  contest.problems = sorted(
141
150
  [
142
151
  *contest.problems,
143
- ContestProblem(short_name=short_name, path=pathlib.Path(name)),
152
+ ContestProblem(short_name=short_name, path=pathlib.Path(path)),
144
153
  ],
145
154
  key=lambda p: p.short_name,
146
155
  )
147
156
 
148
157
  save_contest(contest)
149
158
  console.console.print(
150
- f'Problem [item]{name} ({short_name})[/item] added to contest.'
159
+ f'Problem [item]{name} ({short_name})[/item] added to contest at [item]{path}[/item].'
151
160
  )
152
161
 
153
162
 
rbx/box/creation.py CHANGED
@@ -61,6 +61,7 @@ def create(
61
61
  )
62
62
  raise typer.Exit(1)
63
63
 
64
+ dest_path.mkdir(parents=True, exist_ok=True)
64
65
  shutil.copytree(str(problem_path), str(dest_path))
65
66
 
66
67
  # Remove a few left overs.
@@ -334,6 +334,8 @@ def _install(root: pathlib.Path = pathlib.Path(), force: bool = False):
334
334
  shutil.copytree(str(root), str(installation_path))
335
335
  shutil.rmtree(str(installation_path / 'build'), ignore_errors=True)
336
336
  shutil.rmtree(str(installation_path / '.box'), ignore_errors=True)
337
+ shutil.rmtree(str(installation_path / '.local.rbx'), ignore_errors=True)
338
+ shutil.rmtree(str(installation_path / '.git'), ignore_errors=True)
337
339
 
338
340
 
339
341
  def install_from_remote(fetch_info: PresetFetchInfo, force: bool = False) -> str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rbx.cp
3
- Version: 0.5.6
3
+ Version: 0.5.9
4
4
  Summary:
5
5
  Author: Roberto Sales
6
6
  Requires-Python: >=3.9,<4.0
@@ -12,10 +12,10 @@ rbx/box/contest/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  rbx/box/contest/build_contest_statements.py,sha256=qar6h5u1xAlOKHl3P7-A1d0aYtaqu4PspGw_DYUGOLY,11260
13
13
  rbx/box/contest/contest_package.py,sha256=-eHk6CfJ083jZptWCjR0F4x_r9qsmKeSOUvK0QnDyA4,2393
14
14
  rbx/box/contest/contest_utils.py,sha256=vWv4iNWdJT5motAznfdNzl8o-tEoCU4xmdyaPTPJZuY,490
15
- rbx/box/contest/main.py,sha256=ERMon3vpayMfpJfAPGp51dsNox38R8orqi1v1rKhAMg,5701
15
+ rbx/box/contest/main.py,sha256=BKq_n60BstfSHakvNDUP9lu5LNptx38EN8fYPduS8pU,6171
16
16
  rbx/box/contest/schema.py,sha256=rxzjJasMWPKKhvSJs4eW4A2oCiA4gXgfF-MzqsbPslQ,4914
17
17
  rbx/box/contest/statements.py,sha256=iG_E4bqhc7hof4LlAliw4m9VO8HcDzvnhsWmxzVRQM4,2690
18
- rbx/box/creation.py,sha256=mZ7kEt1F-0scwDBc6oWsJxFRW69AccZlKuJfN1QyDd4,2203
18
+ rbx/box/creation.py,sha256=vnAZnpv-YAXnhKAd0jIDJVaFU61UrM702qzMW6XxqA0,2252
19
19
  rbx/box/download.py,sha256=MFP-R26JiYGAP89I0TK-0fYc69Fsd20tsBqgtRCy5AE,2234
20
20
  rbx/box/environment.py,sha256=i-IGHDyFDaYF1fyr0QHdGZ3z4NWp5sj6nxsbnxhAYq4,10924
21
21
  rbx/box/extensions.py,sha256=p0iLaU28KswOBDX2HGVO_dR2gk-JSAWb6sXC6GZ1d0w,738
@@ -31,7 +31,7 @@ rbx/box/packaging/packager.py,sha256=suCT_SLnWa915rV2j8VFqzH43HGKRTr9mGGlrvj45aw
31
31
  rbx/box/packaging/polygon/packager.py,sha256=CcjHzDr4MwSyp270gsPY6RWoz8bUJeykDqXPvQ3XZ1U,10773
32
32
  rbx/box/packaging/polygon/test.py,sha256=bgEju5PwudgyfwxXJagm8fM6CJVlWM6l_-2q1V-oKaQ,3069
33
33
  rbx/box/packaging/polygon/xml_schema.py,sha256=-r24bCeRMGLrGGoT9FIgmqr87xHL-JzrFaR6bztbYtw,2703
34
- rbx/box/presets/__init__.py,sha256=bDmaBWnwh71lkn2pfGIREN-xlo3HpMZBN9ucodbxscc,16573
34
+ rbx/box/presets/__init__.py,sha256=6IHzqczfiuCdvuXWInimYd9sVMYUQR12BlFaxdr39hI,16721
35
35
  rbx/box/presets/fetch.py,sha256=F-BCOlvEBEyDqtOhiDuGPn4EDtA4Bwm-fqHJ7zZGlW8,1975
36
36
  rbx/box/presets/lock_schema.py,sha256=6sRPnyePOC8yy-5WcD5JRZdDJHf8loqbvpQ1IPiOU9s,349
37
37
  rbx/box/presets/schema.py,sha256=mZmSPkQsw7eQM0lQN6er1MO_LiW1ObwwAZFDK0F5fxE,1962
@@ -157,8 +157,8 @@ rbx/testdata/caching/executable.py,sha256=WKRHNf_fprFJd1Fq1ubmQtR3mZzTYVNwKPLWuZ
157
157
  rbx/testdata/compatible,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
158
158
  rbx/testing_utils.py,sha256=ZZLKMUHlZ4HwsuNY50jqSBJ9HhpnFdba7opjDsvXE1U,2084
159
159
  rbx/utils.py,sha256=wy8zQRb97n3lptilK7UxM4A44KjXb1W5Z1tD61a-K4A,4173
160
- rbx_cp-0.5.6.dist-info/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
161
- rbx_cp-0.5.6.dist-info/METADATA,sha256=5QbCa-cpPi4KRJi29okpTAY3BUk68RsqtGygzZn4zhs,3253
162
- rbx_cp-0.5.6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
163
- rbx_cp-0.5.6.dist-info/entry_points.txt,sha256=qBTLBOeifT1F00LWaEewRRE_jQPgvH7BUdJfZ-dYsFU,57
164
- rbx_cp-0.5.6.dist-info/RECORD,,
160
+ rbx_cp-0.5.9.dist-info/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
161
+ rbx_cp-0.5.9.dist-info/METADATA,sha256=B1Ngy-A57NJJNpHHDw7rCVeOuiUlVCIm9yYf_R9mbvM,3253
162
+ rbx_cp-0.5.9.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
163
+ rbx_cp-0.5.9.dist-info/entry_points.txt,sha256=qBTLBOeifT1F00LWaEewRRE_jQPgvH7BUdJfZ-dYsFU,57
164
+ rbx_cp-0.5.9.dist-info/RECORD,,
File without changes