1 | import subprocess |
||
2 | |||
3 | _CHECK_ONLY = 'check' in COMMAND_LINE_TARGETS |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
![]() |
|||
4 | _CONTINUE = 'continue' in COMMAND_LINE_TARGETS |
||
5 | _SUBJECT = 'barentsz' |
||
6 | |||
7 | |||
8 | def _exec(cmd: str) -> None: |
||
9 | print(f'>>> {cmd}') |
||
10 | exit_code = subprocess.call(cmd, shell=True) |
||
11 | if exit_code != 0 and not _CONTINUE: |
||
12 | print(f'Exiting with {exit_code}') |
||
13 | Exit(exit_code) |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
14 | |||
15 | |||
16 | # COMBINATIONS: |
||
17 | |||
18 | if 'all' in COMMAND_LINE_TARGETS: |
||
19 | COMMAND_LINE_TARGETS += ['format', 'quality'] |
||
20 | |||
21 | if 'quality' in COMMAND_LINE_TARGETS: |
||
22 | COMMAND_LINE_TARGETS += ['test', 'doctest', 'coverage', 'pycodestyle', 'pylint', 'mypy', 'complexity'] |
||
23 | |||
24 | if 'format' in COMMAND_LINE_TARGETS: |
||
25 | COMMAND_LINE_TARGETS += ['autoflake', 'isort'] |
||
26 | |||
27 | |||
28 | # QUALITY: |
||
29 | |||
30 | if 'test' in COMMAND_LINE_TARGETS: |
||
31 | _exec('python -m unittest discover tests') |
||
32 | |||
33 | if 'doctest' in COMMAND_LINE_TARGETS: |
||
34 | _exec('python -m doctest README.md') |
||
35 | |||
36 | if 'coverage' in COMMAND_LINE_TARGETS: |
||
37 | _exec('coverage run -m unittest discover tests') |
||
38 | _exec('coverage report -m --fail-under=100') |
||
39 | |||
40 | if 'pycodestyle' in COMMAND_LINE_TARGETS: |
||
41 | _exec(f'pycodestyle {_SUBJECT} -v --config=setup.cfg') |
||
42 | |||
43 | if 'pylint' in COMMAND_LINE_TARGETS: |
||
44 | _exec(f'pylint --rcfile=setup.cfg {_SUBJECT}') |
||
45 | |||
46 | if 'mypy' in COMMAND_LINE_TARGETS: |
||
47 | _exec(f'mypy {_SUBJECT} --show-error-codes --disallow-untyped-defs') |
||
48 | |||
49 | if 'complexity' in COMMAND_LINE_TARGETS: |
||
50 | _exec(f'radon cc {_SUBJECT}') |
||
51 | _exec(f'radon cc {_SUBJECT} -nc --total-average') |
||
52 | _exec(f'xenon {_SUBJECT} --max-absolute B --max-modules A --max-average A') |
||
53 | |||
54 | |||
55 | # FORMAT: |
||
56 | |||
57 | if 'autoflake' in COMMAND_LINE_TARGETS: |
||
58 | cmd = f'autoflake {_SUBJECT}/_here.py --recursive --in-place --remove-unused-variables --expand-star-imports' |
||
59 | if _CHECK_ONLY: |
||
60 | cmd += ' --check' |
||
61 | _exec(cmd) |
||
62 | |||
63 | if 'isort' in COMMAND_LINE_TARGETS: |
||
64 | cmd = f'isort {_SUBJECT} --recursive --quiet' |
||
65 | if _CHECK_ONLY: |
||
66 | cmd += ' --check' |
||
67 | _exec(cmd) |
||
68 | |||
69 | Exit(0) |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
70 |