-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstyle.py
92 lines (83 loc) · 2.65 KB
/
style.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
import sys
from os import walk
from os.path import join
from glob import glob
from subprocess import Popen, PIPE
def main():
proc = Popen([
"pycodestyle", "--ignore=W503", "--show-source", "--statistics",
"--count", "--max-line-length=79", "--indent-size=4", "."
])
proc.communicate()
if proc.returncode:
sys.exit(proc.returncode)
proc = Popen([
"pylint", "--jobs=0",
"--exit-zero",
"--max-line-length=79",
"--single-line-if-stmt=n",
"--single-line-class-stmt=n",
"--indent-after-paren=4",
"--expected-line-ending-format=LF",
"--logging-format-style=old",
"--init-import=yes",
"--indent-string=' '",
"--check-str-concat-over-line-jumps=n",
"--check-quote-consistency=y",
"--import-graph=imports.gv",
"--analyse-fallback-blocks=y",
"--allow-wildcard-with-all=n",
"--good-names=""",
"--include-naming-hint=y",
"--argument-naming-style=snake_case",
"--attr-naming-style=snake_case",
"--class-naming-style=PascalCase",
"--class-attribute-naming-style=snake_case",
"--class-const-naming-style=UPPER_CASE",
"--const-naming-style=UPPER_CASE",
"--function-naming-style=snake_case",
"--inlinevar-naming-style=snake_case",
"--method-naming-style=snake_case",
"--module-naming-style=snake_case",
"--variable-naming-style=snake_case",
*glob("capython/*.py")
])
proc.communicate()
if proc.returncode:
sys.exit(proc.returncode)
proc = Popen([
"flake8",
"--inline-quotes=double",
"--inline-quotes=double",
"--multiline-quotes", '"""',
"--docstring-quotes", '"',
"--avoid-escape",
"--ignore", ",".join([
"C812", "WPS421", "WPS326", "I005", "I004", "WPS336", "WPS305",
"WPS306", "WPS327", "WPS323", "C815"
]),
"--max-module-members=10",
"."
], stdout=PIPE)
stdout, _ = proc.communicate()
lines = [
line for line in stdout.decode("utf-8").splitlines()
if "WPS412" not in line
]
count = 0
for line in lines:
print(line, file=sys.stderr)
count += 1
total = 0
for root, _, files in walk('.'):
for file in files:
if not file.endswith('.py'):
continue
with open(join(root, file)) as fdes:
total += len(fdes.readlines())
perc = count / total * 100
print(f"{count} / {total} ({perc:.02f}%)")
if proc.returncode:
sys.exit(proc.returncode)
if __name__ == "__main__":
main()