randex 0.2.0__py3-none-any.whl → 0.2.1__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.
- randex/cli.py +56 -0
- randex/exam.py +8 -2
- {randex-0.2.0.dist-info → randex-0.2.1.dist-info}/METADATA +1 -1
- randex-0.2.1.dist-info/RECORD +12 -0
- scripts/exams.py +2 -0
- scripts/validate.py +2 -0
- randex-0.2.0.dist-info/RECORD +0 -11
- {randex-0.2.0.dist-info → randex-0.2.1.dist-info}/LICENSE +0 -0
- {randex-0.2.0.dist-info → randex-0.2.1.dist-info}/WHEEL +0 -0
- {randex-0.2.0.dist-info → randex-0.2.1.dist-info}/entry_points.txt +0 -0
randex/cli.py
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
"""Shared CLI utilities for randex scripts."""
|
2
|
+
|
3
|
+
import click
|
4
|
+
|
5
|
+
|
6
|
+
class CustomCommand(click.Command):
|
7
|
+
"""Custom Click command that provides better error messages."""
|
8
|
+
|
9
|
+
def parse_args(
|
10
|
+
self,
|
11
|
+
ctx: click.Context,
|
12
|
+
args: list[str],
|
13
|
+
) -> list[str]:
|
14
|
+
"""
|
15
|
+
Override parse_args to catch parameter parsing errors.
|
16
|
+
|
17
|
+
This is a workaround to catch the error when the user passes multiple
|
18
|
+
folder arguments to the command.
|
19
|
+
|
20
|
+
Parameters
|
21
|
+
----------
|
22
|
+
ctx : click.Context
|
23
|
+
The click context.
|
24
|
+
args : list[str]
|
25
|
+
The arguments passed to the command.
|
26
|
+
|
27
|
+
Returns
|
28
|
+
-------
|
29
|
+
list[str]:
|
30
|
+
The remaining unparsed arguments.
|
31
|
+
|
32
|
+
Examples
|
33
|
+
--------
|
34
|
+
```bash
|
35
|
+
exams examples/en/folder_* -t template.yaml -n 2
|
36
|
+
```
|
37
|
+
"""
|
38
|
+
try:
|
39
|
+
return super().parse_args(ctx, args)
|
40
|
+
except click.UsageError as e:
|
41
|
+
if "Got unexpected extra arguments" in str(e):
|
42
|
+
# Extract the extra arguments from the error message
|
43
|
+
error_msg = str(e)
|
44
|
+
if "(" in error_msg and ")" in error_msg:
|
45
|
+
extra_args = error_msg.split("(")[1].split(")")[0]
|
46
|
+
|
47
|
+
raise click.UsageError(
|
48
|
+
f"❌ Multiple folder arguments detected: {extra_args}\n\n"
|
49
|
+
f"💡 This usually happens when your shell expands a glob pattern like 'examples/en/folder_*'\n" # noqa: E501
|
50
|
+
f" into multiple folder names before passing them to the command.\n\n" # noqa: E501
|
51
|
+
f"🔧 Solutions:\n"
|
52
|
+
f' • Put quotes around your glob pattern: "examples/en/folder_*"\n' # noqa: E501
|
53
|
+
f" • Or specify a single folder path instead of a glob pattern\n\n" # noqa: E501
|
54
|
+
f'Example: exams "examples/en/folder_*" -t template.yaml -n 2'
|
55
|
+
) from e
|
56
|
+
raise
|
randex/exam.py
CHANGED
@@ -202,8 +202,14 @@ class Pool:
|
|
202
202
|
matched = [p.resolve() for p in Path().glob(folder_input) if p.is_dir()]
|
203
203
|
if not matched:
|
204
204
|
raise ValueError(
|
205
|
-
f"
|
206
|
-
"
|
205
|
+
f"❌ No folders found matching the pattern: '{folder_input}'\n\n"
|
206
|
+
f"💡 Suggestions:\n"
|
207
|
+
f" • Check if the path exists and contains folders\n"
|
208
|
+
f" • Verify the spelling (common mistake: 'example' vs 'examples')\n" # noqa: E501
|
209
|
+
f" • Use quotes around the pattern to prevent shell expansion\n"
|
210
|
+
f" • Try listing the directory to see available folders\n\n"
|
211
|
+
f"🔍 If '{folder_input}' is meant to be a literal folder name (not a pattern), " # noqa: E501
|
212
|
+
f"remove the special characters or use a Path object instead."
|
207
213
|
)
|
208
214
|
return matched
|
209
215
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
randex/__init__.py,sha256=6bBAISO6MqVCSCvqLcK3SGUnDODuwobLWouO3GY8SRU,187
|
2
|
+
randex/cli.py,sha256=hwLgZIfBkAeFXlbveywmQlKBGz9GsD_P6Q89YSDOe2M,2039
|
3
|
+
randex/exam.py,sha256=sYBQhYjmZDNyTicSD6nOOTo_7c_rst5rhyjCJhCbVtk,26975
|
4
|
+
scripts/__init__.py,sha256=F8pjiW8AlL0IhnvVh1TEfgiD--YdFE_PggtSevHp5y4,38
|
5
|
+
scripts/exams.py,sha256=D4ky-3J4yx7R3_-UgpGT7C9nQWFqNvdn-fhvzt9Jkbg,3401
|
6
|
+
scripts/randex_download_examples.py,sha256=fj88XkZV8bpHPCeXu1f3nVNws_hbcJ_3Zso7XOPB0RQ,1682
|
7
|
+
scripts/validate.py,sha256=MnJqfSs8n6qSuxMUT4W0P4ePGyDtRUIXKakWVy20eVo,2659
|
8
|
+
randex-0.2.1.dist-info/LICENSE,sha256=NxH5Y8BdC-gNU-WSMwim3uMbID2iNDXJz7fHtuTdXhk,19346
|
9
|
+
randex-0.2.1.dist-info/METADATA,sha256=18RJ4FY6RmVK4C9OxDWM8Qe8kY0SClXtbnXT8VrRYP8,6551
|
10
|
+
randex-0.2.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
11
|
+
randex-0.2.1.dist-info/entry_points.txt,sha256=RayNUArGNT0MLZi7uh1MHjnd1L1V4X6C4sBdMLbvAfc,138
|
12
|
+
randex-0.2.1.dist-info/RECORD,,
|
scripts/exams.py
CHANGED
@@ -6,10 +6,12 @@ from pathlib import Path
|
|
6
6
|
|
7
7
|
import click
|
8
8
|
|
9
|
+
from randex.cli import CustomCommand
|
9
10
|
from randex.exam import ExamBatch, ExamTemplate, Pool, QuestionSet
|
10
11
|
|
11
12
|
|
12
13
|
@click.command(
|
14
|
+
cls=CustomCommand,
|
13
15
|
context_settings={"help_option_names": ["--help"]},
|
14
16
|
)
|
15
17
|
@click.argument(
|
scripts/validate.py
CHANGED
@@ -6,10 +6,12 @@ from pathlib import Path
|
|
6
6
|
|
7
7
|
import click
|
8
8
|
|
9
|
+
from randex.cli import CustomCommand
|
9
10
|
from randex.exam import Exam, ExamTemplate, Pool, QuestionSet
|
10
11
|
|
11
12
|
|
12
13
|
@click.command(
|
14
|
+
cls=CustomCommand,
|
13
15
|
context_settings={"help_option_names": ["--help"]},
|
14
16
|
)
|
15
17
|
@click.argument(
|
randex-0.2.0.dist-info/RECORD
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
randex/__init__.py,sha256=6bBAISO6MqVCSCvqLcK3SGUnDODuwobLWouO3GY8SRU,187
|
2
|
-
randex/exam.py,sha256=l-_6GnrstLgVMORXNEIKzgW9k6h_YbXndZd8YmEGKBI,26450
|
3
|
-
scripts/__init__.py,sha256=F8pjiW8AlL0IhnvVh1TEfgiD--YdFE_PggtSevHp5y4,38
|
4
|
-
scripts/exams.py,sha256=L4QSOZpU8Hw5QkW_2x5s8NESQAwlEmZTSaT6ZZ8-c04,3341
|
5
|
-
scripts/randex_download_examples.py,sha256=fj88XkZV8bpHPCeXu1f3nVNws_hbcJ_3Zso7XOPB0RQ,1682
|
6
|
-
scripts/validate.py,sha256=xruN1P1rgJnc0MTklLgSrsx9TcFC2SY1a9eksNT_-KM,2599
|
7
|
-
randex-0.2.0.dist-info/LICENSE,sha256=NxH5Y8BdC-gNU-WSMwim3uMbID2iNDXJz7fHtuTdXhk,19346
|
8
|
-
randex-0.2.0.dist-info/METADATA,sha256=1KJfVvoQSFmykT68kvqLkq2YAiu6AxC5hdUSY15Fks0,6551
|
9
|
-
randex-0.2.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
10
|
-
randex-0.2.0.dist-info/entry_points.txt,sha256=RayNUArGNT0MLZi7uh1MHjnd1L1V4X6C4sBdMLbvAfc,138
|
11
|
-
randex-0.2.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|