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 = 'jsons' |
||
6 | |||
7 | |||
8 | def _exec(cmd: str) -> None: |
||
9 | print('>>> {}'.format(cmd)) |
||
10 | exit_code = subprocess.call(cmd, shell=True) |
||
11 | if exit_code != 0 and not _CONTINUE: |
||
12 | print('Exiting with {}'.format(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=95') |
||
39 | |||
40 | if 'pycodestyle' in COMMAND_LINE_TARGETS: |
||
41 | _exec('pycodestyle {} -v --config=setup.cfg'.format(_SUBJECT)) |
||
42 | |||
43 | if 'pylint' in COMMAND_LINE_TARGETS: |
||
44 | _exec('pylint --rcfile=setup.cfg {}'.format(_SUBJECT)) |
||
45 | |||
46 | if 'mypy' in COMMAND_LINE_TARGETS: |
||
47 | _exec('mypy {} --show-error-codes --disallow-untyped-defs'.format(_SUBJECT)) |
||
48 | |||
49 | if 'complexity' in COMMAND_LINE_TARGETS: |
||
50 | _exec('radon cc {}'.format(_SUBJECT)) |
||
51 | _exec('radon cc {} -nc --total-average'.format(_SUBJECT)) |
||
52 | _exec('xenon {} --max-absolute B --max-modules A --max-average A'.format(_SUBJECT)) |
||
53 | |||
54 | |||
55 | # FORMAT: |
||
56 | |||
57 | if 'autoflake' in COMMAND_LINE_TARGETS: |
||
58 | cmd = 'autoflake {}/_here.py --recursive --in-place --remove-unused-variables --expand-star-imports'.format(_SUBJECT) |
||
59 | if _CHECK_ONLY: |
||
60 | cmd += ' --check' |
||
61 | _exec(cmd) |
||
62 | |||
63 | if 'isort' in COMMAND_LINE_TARGETS: |
||
64 | cmd = 'isort {} --recursive --quiet'.format(_SUBJECT) |
||
65 | if _CHECK_ONLY: |
||
66 | cmd += ' --check' |
||
67 | _exec(cmd) |
||
68 | |||
69 | Exit(0) |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
70 |