-
Notifications
You must be signed in to change notification settings - Fork 20
/
quality.py
executable file
·44 lines (35 loc) · 1.33 KB
/
quality.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
#! /usr/bin/env python
import argparse
import os
from glob import glob
import subprocess
FUNAPPS_DIR = os.path.dirname(__file__)
def main():
args = parse_args()
paths = find_module_and_packages(args.root_path)
run(paths, args.pylint, args.output_format)
def parse_args():
parser = argparse.ArgumentParser(description="Run quality tests on fun-apps")
parser.add_argument("--pylint", default='pylint', help="Path to pylint")
parser.add_argument("-i", "--input", dest='root_path', default='.',
help="Path to module or package")
parser.add_argument("-f", "--format", dest='output_format', default='colorized',
choices=('colorized', 'parseable', 'colorized', 'msvs', 'html'),
help="Pylint output format")
return parser.parse_args()
def find_module_and_packages(root_path):
if os.path.isdir(root_path):
package_glob = os.path.join(root_path, "*/__init__.py")
return [os.path.dirname(path) for path in glob(package_glob)]
else:
return [root_path]
def run(paths, pylint, output_format):
pylintrc_path = os.path.join(FUNAPPS_DIR, "pylint.cfg")
cmd = [
pylint,
'-f', output_format,
'--rcfile={}'.format(pylintrc_path),
] + paths
subprocess.call(cmd)
if __name__ == "__main__":
main()