-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.py
executable file
·94 lines (85 loc) · 2.4 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/python
import argparse
import subprocess
import sys
arg_map = {
"src/catdev" : [
"--reports=no",
"--disable=I",
"--disable=bad-continuation",
"--msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'"
],
"src/cmpdev" : [
"--reports=no",
"--disable=I",
"--disable=bad-continuation",
"--msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'"
],
"src/diffdev" : [
"--reports=no",
"--disable=I",
"--disable=bad-continuation",
"--msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'"
],
"src/journaldev" : [
"--reports=no",
"--disable=I",
"--disable=bad-continuation",
"--msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'"
],
"src/lsdev" : [
"--reports=no",
"--disable=I",
"--disable=bad-continuation",
"--msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'"
],
"src/pyblk" : [
"--reports=no",
"--disable=I",
"--disable=bad-continuation",
"--disable=duplicate-code",
"--msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'"
],
"src/showdev" : [
"--reports=no",
"--disable=I",
"--disable=bad-continuation",
"--msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'"
],
"tests" : [
"--reports=no",
"--disable=I",
"--disable=bad-continuation",
"--disable=duplicate-code",
"--disable=no-self-use",
"--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())