forked from stratis-storage/stratis-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.py
executable file
·78 lines (66 loc) · 1.98 KB
/
check.py
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
#!/usr/bin/python
# isort: STDLIB
import argparse
import subprocess
import sys
arg_map = {
"src/stratis_cli": [
"--reports=no",
"--disable=I",
"--disable=duplicate-code",
"--disable=invalid-name",
"--msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'",
],
"tests/blackbox/stratisd_cert.py": [
"--reports=no",
"--disable=I",
"--msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'",
],
"tests/blackbox/stratis_cli_cert.py": [
"--reports=no",
"--disable=I",
"--msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'",
],
"tests/blackbox/testlib": [
"--reports=no",
"--disable=I",
"--msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'",
],
"tests/whitebox": [
"--reports=no",
"--disable=I",
"--disable=duplicate-code",
"--disable=invalid-name",
"--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"
)
parser.add_argument("--ignore", help="ignore these files")
return parser
def get_command(namespace):
"""
Get the pylint command for these arguments.
:param `Namespace` namespace: the namespace
"""
cmd = ["pylint", namespace.package] + arg_map[namespace.package]
if namespace.ignore:
cmd.append("--ignore=%s" % namespace.ignore)
return cmd
def main():
args = get_parser().parse_args()
return subprocess.call(get_command(args), stdout=sys.stdout)
if __name__ == "__main__":
sys.exit(main())