forked from stratis-storage/stratis-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck.py
More file actions
executable file
·81 lines (68 loc) · 1.92 KB
/
check.py
File metadata and controls
executable file
·81 lines (68 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/python3
"""
Invoke pylint with pre-selected-options.
"""
# isort: STDLIB
import argparse
import subprocess
import sys
ARG_MAP = {
"check.py": [
"--reports=no",
"--disable=I",
"--msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'",
],
"setup.py": [
"--reports=no",
"--disable=I",
"--msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'",
],
"developer_tools": [
"--reports=no",
"--disable=I",
"--msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'",
],
"src/stratis_cli": [
"--reports=no",
"--disable=I",
"--disable=duplicate-code",
# ignore _introspect.py because it will be auto-generated
"--ignore=_introspect.py",
"--msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'",
],
"tests/whitebox": [
"--reports=no",
"--disable=I",
"--disable=duplicate-code",
"--msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'",
],
"bin/stratis": [
"--reports=no",
"--msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'",
],
}
def get_parser():
"""
Generate an appropriate parser.
:returns: an argument parser
:rtype: `ArgumentParser`
"""
parser = argparse.ArgumentParser()
parser.add_argument(
"package", choices=ARG_MAP.keys(), help="designates the package to test"
)
return parser
def get_command(namespace):
"""
Get the pylint command for these arguments.
:param `Namespace` namespace: the namespace
"""
return ["pylint", namespace.package] + ARG_MAP[namespace.package]
def main():
"""
Run the linter on a single directory or file.
"""
args = get_parser().parse_args()
return subprocess.call(get_command(args), stdout=sys.stdout)
if __name__ == "__main__":
sys.exit(main())