-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathlint.py
62 lines (45 loc) · 1.17 KB
/
lint.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
""" runs lint on the project sources"""
import argparse
import logging
import sys
from pylint.lint import Run
sys.path.append("./dot")
logging.getLogger().setLevel(logging.INFO)
parser = argparse.ArgumentParser(prog="LINT")
parser.add_argument(
"-p",
"--path",
help="path to directory you want to run pylint | "
"Default: %(default)s | "
"Type: %(type)s ",
default="./src",
type=str,
)
parser.add_argument(
"-t",
"--threshold",
help="score threshold to fail pylint runner | "
"Default: %(default)s | "
"Type: %(type)s ",
default=7,
type=float,
)
args = parser.parse_args()
PATH = str(args.path)
threshold = float(args.threshold)
logging.info(f"PyLint Starting | " "Path: {PATH} | " "Threshold: {threshold}")
results = Run([PATH], do_exit=False)
final_score = results.linter.stats.global_note
if final_score < threshold:
MESSAGE = (
"PyLint Failed | "
"Score: {} | "
"Threshold: {} ".format(final_score, threshold)
)
logging.error(MESSAGE)
sys.exit(1)
MESSAGE = (
"PyLint Passed | " "Score: {} | " "Threshold: {} ".format(final_score, threshold)
)
logging.info(MESSAGE)
sys.exit(0)