-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck.py
executable file
·59 lines (50 loc) · 1.38 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
#!/usr/bin/python
import argparse
import subprocess
import sys
arg_map = {
"src/pydevDAG" : [
"--reports=no",
"--disable=I",
"--disable=bad-continuation",
"--disable=duplicate-code",
"--good-names=pydevDAG,_",
"--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())