ppqs 2.5.2__tar.gz → 2.6.0__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.
- {ppqs-2.5.2/src/ppqs.egg-info → ppqs-2.6.0}/PKG-INFO +1 -1
- {ppqs-2.5.2 → ppqs-2.6.0/src/ppqs.egg-info}/PKG-INFO +1 -1
- {ppqs-2.5.2 → ppqs-2.6.0}/src/py_proj_quick_scripts/__init__.py +21 -7
- {ppqs-2.5.2 → ppqs-2.6.0}/test/test_cli.py +4 -1
- {ppqs-2.5.2 → ppqs-2.6.0}/LICENSES/CC0-1.0.txt +0 -0
- {ppqs-2.5.2 → ppqs-2.6.0}/LICENSES/MIT.txt +0 -0
- {ppqs-2.5.2 → ppqs-2.6.0}/README.md +0 -0
- {ppqs-2.5.2 → ppqs-2.6.0}/pyproject.toml +0 -0
- {ppqs-2.5.2 → ppqs-2.6.0}/setup.cfg +0 -0
- {ppqs-2.5.2 → ppqs-2.6.0}/src/ppqs.egg-info/SOURCES.txt +0 -0
- {ppqs-2.5.2 → ppqs-2.6.0}/src/ppqs.egg-info/dependency_links.txt +0 -0
- {ppqs-2.5.2 → ppqs-2.6.0}/src/ppqs.egg-info/entry_points.txt +0 -0
- {ppqs-2.5.2 → ppqs-2.6.0}/src/ppqs.egg-info/requires.txt +0 -0
- {ppqs-2.5.2 → ppqs-2.6.0}/src/ppqs.egg-info/top_level.txt +0 -0
- {ppqs-2.5.2 → ppqs-2.6.0}/test/test_find_pyproject.py +0 -0
- {ppqs-2.5.2 → ppqs-2.6.0}/test/test_parse_scripts.py +0 -0
|
@@ -19,14 +19,12 @@ else: # pragma: no cover
|
|
|
19
19
|
import tomli as tomllib
|
|
20
20
|
|
|
21
21
|
__author__ = "Karl Wette"
|
|
22
|
-
__version__ = "2.
|
|
22
|
+
__version__ = "2.6.0"
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
class MissingPyProjectError(Exception):
|
|
26
26
|
"""Raise if 'pyproject.toml' could not be found."""
|
|
27
27
|
|
|
28
|
-
pass
|
|
29
|
-
|
|
30
28
|
|
|
31
29
|
class InvalidScriptError(Exception):
|
|
32
30
|
"""Raise for invalid 'pyproject.toml' script errors."""
|
|
@@ -41,6 +39,10 @@ class InvalidScriptError(Exception):
|
|
|
41
39
|
return f"{self.pyproject_path}: {self.msg}"
|
|
42
40
|
|
|
43
41
|
|
|
42
|
+
class InvalidScriptCallError(InvalidScriptError):
|
|
43
|
+
"""Raise for invalid calls of 'pyproject.toml' scripts."""
|
|
44
|
+
|
|
45
|
+
|
|
44
46
|
def find_pyproject():
|
|
45
47
|
"""Look for pyproject.toml in current/parent directories."""
|
|
46
48
|
|
|
@@ -228,15 +230,25 @@ def print_help(project_name, scripts):
|
|
|
228
230
|
print(help_header + list_of_scripts + f"\n\nppqs version: {__version__}")
|
|
229
231
|
|
|
230
232
|
|
|
231
|
-
def run_script(scripts, script_name, argv, cwd, has_been_run):
|
|
233
|
+
def run_script(pyproject_path, scripts, script_name, argv, cwd, has_been_run):
|
|
232
234
|
"""Run a script."""
|
|
233
235
|
|
|
234
236
|
col_width = shutil.get_terminal_size().columns
|
|
235
237
|
|
|
236
|
-
# Mark script
|
|
238
|
+
# Mark script as having been run
|
|
237
239
|
has_been_run.add(script_name)
|
|
238
240
|
|
|
241
|
+
# Get script
|
|
239
242
|
script = scripts[script_name]
|
|
243
|
+
|
|
244
|
+
# Check that script was correctly passed arguments
|
|
245
|
+
script_takes_argv = any("..." in command for command in script["commands"])
|
|
246
|
+
if not script_takes_argv and len(argv) > 0:
|
|
247
|
+
msg = "script '{}' does not take arguments ('{}')".format(
|
|
248
|
+
script_name, "', '".join(argv)
|
|
249
|
+
)
|
|
250
|
+
raise InvalidScriptCallError(pyproject_path, msg)
|
|
251
|
+
|
|
240
252
|
for command in script["commands"]:
|
|
241
253
|
cmd = []
|
|
242
254
|
|
|
@@ -264,7 +276,9 @@ def run_script(scripts, script_name, argv, cwd, has_been_run):
|
|
|
264
276
|
# - silently ignore scripts which have already been run
|
|
265
277
|
script_name_r = cmd[1]
|
|
266
278
|
if script_name_r not in has_been_run:
|
|
267
|
-
run_script(
|
|
279
|
+
run_script(
|
|
280
|
+
pyproject_path, scripts, script_name_r, cmd[2:], cwd, has_been_run
|
|
281
|
+
)
|
|
268
282
|
continue
|
|
269
283
|
|
|
270
284
|
elif cmd[0] == "python":
|
|
@@ -376,4 +390,4 @@ def cli(*argv):
|
|
|
376
390
|
else:
|
|
377
391
|
cwd = pyproject_path.parent
|
|
378
392
|
has_been_run = set()
|
|
379
|
-
run_script(scripts, argv[0], argv[1:], cwd, has_been_run)
|
|
393
|
+
run_script(pyproject_path, scripts, argv[0], argv[1:], cwd, has_been_run)
|
|
@@ -8,7 +8,7 @@ import os
|
|
|
8
8
|
|
|
9
9
|
import pytest
|
|
10
10
|
|
|
11
|
-
from py_proj_quick_scripts import InvalidScriptError, cli
|
|
11
|
+
from py_proj_quick_scripts import InvalidScriptCallError, InvalidScriptError, cli
|
|
12
12
|
|
|
13
13
|
from . import in_dir, write_file
|
|
14
14
|
|
|
@@ -120,5 +120,8 @@ def test_recursion(pyproject_path, capfd):
|
|
|
120
120
|
assert captured.out == "Hello friend!\nGoodbye\n"
|
|
121
121
|
assert captured.err == ""
|
|
122
122
|
|
|
123
|
+
with pytest.raises(InvalidScriptCallError):
|
|
124
|
+
cli("farewell", "someone")
|
|
125
|
+
|
|
123
126
|
with pytest.raises(InvalidScriptError):
|
|
124
127
|
cli("no-script")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|