ppqs 1.0.2__tar.gz → 2.0.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ppqs
3
- Version: 1.0.2
3
+ Version: 2.0.0
4
4
  Summary: Python project quick scripts
5
5
  Author-email: Karl Wette <karl.wette@anu.edu.au>
6
6
  License-Expression: MIT
@@ -117,14 +117,12 @@ Scripts may also be defined in their own section, which permit a few options:
117
117
  ```toml
118
118
  [tool.ppqs.scripts.init]
119
119
  description = "Initialise project"
120
- print_header = true
120
+ print-header = true
121
121
  script = """
122
122
  command
123
123
  """
124
124
 
125
125
  [tool.ppqs.scripts.build]
126
- # default description = "Run build script"
127
- # default print_header = false
128
126
  script = [
129
127
  ["command1", "-v"],
130
128
  ["command2", "-q"],
@@ -133,12 +131,20 @@ script = [
133
131
 
134
132
  where:
135
133
 
136
- * `description` [optional]: description of the script which appears in `ppqs
134
+ * `description` *(optional)*: description of the script which appears in `ppqs
137
135
  --help`. Default is `Run {name} script` where `name` is the script name.
138
136
 
139
- * `print_header` [optional]: If true, print a header before running each command
140
- in the script. The header consists of the command to be run, centred on the
141
- console and padded with `*`s. Default is false.
137
+ * `print-header` *(optional)*: If true, print a header before running each
138
+ command in the script. The header consists of the command to be run, centred
139
+ on the console and padded with `*`s. Default is false.
140
+
141
+ The default value of some options may be overridden in the
142
+ `[tool.ppqs.defaults]` section, e.g.
143
+
144
+ ```
145
+ [tool.ppqs.defaults]
146
+ print-header = true
147
+ ```
142
148
 
143
149
  Note that commands are *not* passed to the shell, so shell features
144
150
  (e.g. wildcards, conditional statements) are not available. The recommended
@@ -159,6 +165,6 @@ your `~/.bashrc` file:
159
165
  complete -C "ppqs --bash-completion" ppqs
160
166
  ```
161
167
 
162
- Typing `ppdq ` and hitting `TAB` will then show scripts available for the
168
+ Typing `ppqs ` and hitting `TAB` will then show scripts available for the
163
169
  current project. Typing part of a script name and hitting `TAB` will show
164
170
  matching script name(s), or else complete the full name if unambiguous.
@@ -101,14 +101,12 @@ Scripts may also be defined in their own section, which permit a few options:
101
101
  ```toml
102
102
  [tool.ppqs.scripts.init]
103
103
  description = "Initialise project"
104
- print_header = true
104
+ print-header = true
105
105
  script = """
106
106
  command
107
107
  """
108
108
 
109
109
  [tool.ppqs.scripts.build]
110
- # default description = "Run build script"
111
- # default print_header = false
112
110
  script = [
113
111
  ["command1", "-v"],
114
112
  ["command2", "-q"],
@@ -117,12 +115,20 @@ script = [
117
115
 
118
116
  where:
119
117
 
120
- * `description` [optional]: description of the script which appears in `ppqs
118
+ * `description` *(optional)*: description of the script which appears in `ppqs
121
119
  --help`. Default is `Run {name} script` where `name` is the script name.
122
120
 
123
- * `print_header` [optional]: If true, print a header before running each command
124
- in the script. The header consists of the command to be run, centred on the
125
- console and padded with `*`s. Default is false.
121
+ * `print-header` *(optional)*: If true, print a header before running each
122
+ command in the script. The header consists of the command to be run, centred
123
+ on the console and padded with `*`s. Default is false.
124
+
125
+ The default value of some options may be overridden in the
126
+ `[tool.ppqs.defaults]` section, e.g.
127
+
128
+ ```
129
+ [tool.ppqs.defaults]
130
+ print-header = true
131
+ ```
126
132
 
127
133
  Note that commands are *not* passed to the shell, so shell features
128
134
  (e.g. wildcards, conditional statements) are not available. The recommended
@@ -143,6 +149,6 @@ your `~/.bashrc` file:
143
149
  complete -C "ppqs --bash-completion" ppqs
144
150
  ```
145
151
 
146
- Typing `ppdq ` and hitting `TAB` will then show scripts available for the
152
+ Typing `ppqs ` and hitting `TAB` will then show scripts available for the
147
153
  current project. Typing part of a script name and hitting `TAB` will show
148
154
  matching script name(s), or else complete the full name if unambiguous.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ppqs"
7
- version = "1.0.2"
7
+ version = "2.0.0"
8
8
  description = "Python project quick scripts"
9
9
  authors = [
10
10
  { name = "Karl Wette", email = "karl.wette@anu.edu.au" },
@@ -33,9 +33,11 @@ minversion = "6.0"
33
33
  addopts = "--cov=py_proj_quick_scripts --cov-report=term-missing --cov-fail-under=100"
34
34
  testpaths = ["test"]
35
35
 
36
+ [tool.ppqs.defaults]
37
+ print-header = true
38
+
36
39
  [tool.ppqs.scripts.init]
37
40
  description = "Initialise project"
38
- print_header = true
39
41
  script = """
40
42
  python -m pip install -r requirements-dev.txt
41
43
  pre-commit install
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ppqs
3
- Version: 1.0.2
3
+ Version: 2.0.0
4
4
  Summary: Python project quick scripts
5
5
  Author-email: Karl Wette <karl.wette@anu.edu.au>
6
6
  License-Expression: MIT
@@ -117,14 +117,12 @@ Scripts may also be defined in their own section, which permit a few options:
117
117
  ```toml
118
118
  [tool.ppqs.scripts.init]
119
119
  description = "Initialise project"
120
- print_header = true
120
+ print-header = true
121
121
  script = """
122
122
  command
123
123
  """
124
124
 
125
125
  [tool.ppqs.scripts.build]
126
- # default description = "Run build script"
127
- # default print_header = false
128
126
  script = [
129
127
  ["command1", "-v"],
130
128
  ["command2", "-q"],
@@ -133,12 +131,20 @@ script = [
133
131
 
134
132
  where:
135
133
 
136
- * `description` [optional]: description of the script which appears in `ppqs
134
+ * `description` *(optional)*: description of the script which appears in `ppqs
137
135
  --help`. Default is `Run {name} script` where `name` is the script name.
138
136
 
139
- * `print_header` [optional]: If true, print a header before running each command
140
- in the script. The header consists of the command to be run, centred on the
141
- console and padded with `*`s. Default is false.
137
+ * `print-header` *(optional)*: If true, print a header before running each
138
+ command in the script. The header consists of the command to be run, centred
139
+ on the console and padded with `*`s. Default is false.
140
+
141
+ The default value of some options may be overridden in the
142
+ `[tool.ppqs.defaults]` section, e.g.
143
+
144
+ ```
145
+ [tool.ppqs.defaults]
146
+ print-header = true
147
+ ```
142
148
 
143
149
  Note that commands are *not* passed to the shell, so shell features
144
150
  (e.g. wildcards, conditional statements) are not available. The recommended
@@ -159,6 +165,6 @@ your `~/.bashrc` file:
159
165
  complete -C "ppqs --bash-completion" ppqs
160
166
  ```
161
167
 
162
- Typing `ppdq ` and hitting `TAB` will then show scripts available for the
168
+ Typing `ppqs ` and hitting `TAB` will then show scripts available for the
163
169
  current project. Typing part of a script name and hitting `TAB` will show
164
170
  matching script name(s), or else complete the full name if unambiguous.
@@ -12,7 +12,7 @@ else: # pragma: no cover
12
12
  import tomli as tomllib
13
13
 
14
14
  __author__ = "Karl Wette"
15
- __version__ = "1.0.2"
15
+ __version__ = "2.0.0"
16
16
 
17
17
 
18
18
  class MissingPyProjectError(Exception):
@@ -81,6 +81,14 @@ def parse_scripts(pyproject_path):
81
81
  msg = "does not contain a non-empty '[tool.ppqs.scripts]' section"
82
82
  raise InvalidScriptError(pyproject_path, msg)
83
83
 
84
+ # Get defaults
85
+ try:
86
+ default_script_print_header = bool(
87
+ pyproject_toml["tool"]["ppqs"]["defaults"]["print-header"]
88
+ )
89
+ except KeyError:
90
+ default_script_print_header = False
91
+
84
92
  # Parse scripts
85
93
  scripts = {}
86
94
  for script_name, script_toml in scripts_toml.items():
@@ -96,7 +104,7 @@ def parse_scripts(pyproject_path):
96
104
 
97
105
  # Create default description
98
106
  script_description = f"Run {script_name} script"
99
- script_print_header = False
107
+ script_print_header = default_script_print_header
100
108
  script_commands_toml = script_toml
101
109
 
102
110
  if isinstance(script_toml, dict):
@@ -105,7 +113,7 @@ def parse_scripts(pyproject_path):
105
113
  invalid_keys = [
106
114
  k
107
115
  for k in script_toml.keys()
108
- if k not in ("description", "print_header", "script")
116
+ if k not in ("description", "print-header", "script")
109
117
  ]
110
118
  if len(invalid_keys) > 0:
111
119
  invalid_keys_str = "', '".join(invalid_keys)
@@ -116,7 +124,7 @@ def parse_scripts(pyproject_path):
116
124
 
117
125
  script_description = str(script_toml.get("description", script_description))
118
126
  script_print_header = bool(
119
- script_toml.get("print_header", script_print_header)
127
+ script_toml.get("print-header", script_print_header)
120
128
  )
121
129
  script_commands_toml = script_toml["script"]
122
130
 
@@ -159,7 +167,7 @@ def parse_scripts(pyproject_path):
159
167
 
160
168
  scripts[script_name] = {
161
169
  "description": script_description,
162
- "print_header": script_print_header,
170
+ "print-header": script_print_header,
163
171
  "commands": script_commands,
164
172
  }
165
173
 
@@ -210,9 +218,9 @@ def run_script(script, argv, cwd):
210
218
  cmd.append(arg)
211
219
 
212
220
  # Print header
213
- if script["print_header"]:
221
+ if script["print-header"]:
214
222
  cmd_str = " ".join(cmd)
215
- print(f" {cmd_str} ".center(col_width, "*"))
223
+ print(f" ppqs: {cmd_str} ".center(col_width, "*"))
216
224
 
217
225
  # Run command
218
226
  retn = subprocess.run(cmd, stdin=subprocess.DEVNULL, shell=False, cwd=cwd)
@@ -17,7 +17,7 @@ def pyproject_path(tmp_path):
17
17
  name = "test"
18
18
  [tool.ppqs.scripts.exit]
19
19
  description = "Exits"
20
- print_header = true
20
+ print-header = true
21
21
  script = "python -c 'import sys; sys.exit(1)'"
22
22
  [tool.ppqs.scripts.echo]
23
23
  description = "Echoes"
@@ -51,7 +51,7 @@ from . import in_dir, write_file
51
51
  {
52
52
  "init": {
53
53
  "description": "Run init script",
54
- "print_header": False,
54
+ "print-header": False,
55
55
  "commands": [["pip", "install", "-r", "requirements.txt"]],
56
56
  }
57
57
  }
@@ -70,7 +70,7 @@ from . import in_dir, write_file
70
70
  {
71
71
  "init": {
72
72
  "description": "Run init script",
73
- "print_header": False,
73
+ "print-header": False,
74
74
  "commands": [
75
75
  ["pip", "install", "-r", "requirements.txt"],
76
76
  ["pre-commit", "install"],
@@ -116,7 +116,7 @@ from . import in_dir, write_file
116
116
  {
117
117
  "init": {
118
118
  "description": "Initialise project",
119
- "print_header": False,
119
+ "print-header": False,
120
120
  "commands": [["pip", "install", "-r", "requirements.txt"]],
121
121
  }
122
122
  }
@@ -147,7 +147,7 @@ from . import in_dir, write_file
147
147
  {
148
148
  "init": {
149
149
  "description": "Run init script",
150
- "print_header": False,
150
+ "print-header": False,
151
151
  "commands": [["pip", "install", "-r", "requirements.txt"]],
152
152
  }
153
153
  }
@@ -158,7 +158,7 @@ from . import in_dir, write_file
158
158
  """
159
159
  [tool.ppqs.scripts.init]
160
160
  description = "Initialise project"
161
- print_header = true
161
+ print-header = true
162
162
  script = [
163
163
  ["pip", "install", "-r", "requirements.txt"],
164
164
  ]
@@ -167,7 +167,7 @@ from . import in_dir, write_file
167
167
  {
168
168
  "init": {
169
169
  "description": "Initialise project",
170
- "print_header": True,
170
+ "print-header": True,
171
171
  "commands": [["pip", "install", "-r", "requirements.txt"]],
172
172
  }
173
173
  }
@@ -187,7 +187,7 @@ from . import in_dir, write_file
187
187
  {
188
188
  "init": {
189
189
  "description": "Initialise project",
190
- "print_header": False,
190
+ "print-header": False,
191
191
  "commands": [
192
192
  ["pip", "install", "-r", "requirements.txt"],
193
193
  ["pre-commit", "install"],
@@ -218,7 +218,7 @@ from . import in_dir, write_file
218
218
  {
219
219
  "paths": {
220
220
  "description": "Run paths script",
221
- "print_header": False,
221
+ "print-header": False,
222
222
  "commands": [["echo", str(Path("a", "b"))]],
223
223
  }
224
224
  }
File without changes
File without changes
File without changes
File without changes