Skip to content

Commit 0a3f6e2

Browse files
authored
Merge pull request #8 from boltronics/helper_script_fixes
Helper script fixes
2 parents 2d03f75 + 40e061f commit 0a3f6e2

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

{{cookiecutter.package_name}}/examples/quickstart.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Quickstart example
22
3-
This example script imports the {{cookiecutter.package_name}} package and prints out
4-
the version.
3+
This example script imports our package and prints out the version.
54
"""
65

76
import logging

{{cookiecutter.package_name}}/scripts/cleanup_docs.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,28 @@
33
import shutil
44
from pathlib import Path
55

6-
paths = [
7-
"docs/build",
8-
"docs/source/api/modules.rst",
9-
"docs/source/api/{{cookiecutter.package_name}}*.rst",
6+
_LITERAL_PATHS = [
7+
Path("docs/build"),
8+
Path("docs/source/api/modules.rst"),
109
]
10+
_GLOB_PATTERNS = [
11+
("docs/source/api", "reposcan*.rst"),
12+
]
13+
14+
15+
def clean() -> None:
16+
"""Delete build artefacts and generated API documentation files."""
17+
for path in _LITERAL_PATHS:
18+
if path.exists():
19+
if path.is_dir():
20+
shutil.rmtree(path)
21+
else:
22+
path.unlink()
23+
24+
for parent_str, pattern in _GLOB_PATTERNS:
25+
for match in Path(parent_str).glob(pattern):
26+
match.unlink()
27+
1128

12-
for path in paths:
13-
p = Path(path)
14-
if p.exists():
15-
if p.is_dir():
16-
shutil.rmtree(p)
17-
else:
18-
p.unlink()
29+
if __name__ == "__main__":
30+
clean()

{{cookiecutter.package_name}}/tests/test_examples.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ def run_in_venv(
5050
else:
5151
# Unix-like systems
5252
activate_cmd = f". {VENV_DIR}/bin/activate"
53-
args = shlex.split(
54-
f'sh -c "{activate_cmd} && python {filename}"'
55-
)
53+
args = shlex.split(f'sh -c "{activate_cmd} && python {filename}"')
5654

5755
env: dict[str, str] = {}
5856
if os.environ.get("PATH"):

0 commit comments

Comments
 (0)