forked from MarioGith/log680
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lint.py
61 lines (47 loc) · 1.16 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
import argparse
import logging
from pylint.lint import Run
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(
"PyLint Starting | " "Path: {} | " "Threshold: {} ".format(path, 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)
raise Exception(message)
else:
message = (
"PyLint Passed | "
"Score: {} | "
"Threshold: {} ".format(final_score, threshold)
)
logging.info(message)
exit(0)