/
metric_pep8.py
88 lines (67 loc) · 2.44 KB
/
metric_pep8.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
"""
Script to check PEP8 complience for OpenPlatform - Enablers
"""
#!/usr/bin/python
import sys
STR_CHECKING = "checking "
STR_DIRECTORY = "directory "
EXCLUDED = [
"D:\\WS_OpenPlat\\gvp-openplat\\src\\gvp_openplat\\grant_manager\\sync_services\\gal_connector\\schemas.py",
"D:\\WS_OpenPlat\\gvp-openplat\\src\\gvp_openplat\\grant_manager\\sync_services\\gal_connector\\validators.py",
"D:\\WS_OpenPlat\\gvp-openplat\\src\\gvp_openplat\\message_manager\\server\\schemas.py",
"D:\\WS_OpenPlat\\gvp-openplat\\src\\gvp_openplat\\task_manager\\api\\schemas.py",
"D:\\WS_OpenPlat\\gvp-openplat\\src\\gvp_openplat\\utils\\adm_client",
"D:\\WS_OpenPlat\\gvp-openplat\\src\\gvp_openplat\\utils\\rmg_client",
"D:\\WS_OpenPlat\\gvp-openplat\\src\\gvp_openplat\\utils\\ims_dim_client",
"D:\\WS_OpenPlat\\gvp-openplat\\src\\gvp_openplat\\utils\\ims_topology_client",
"D:\\WS_OpenPlat\\gvp-openplat\\src\\gvp_openplat\\utils\\mib_api_client\\opus_client",
]
def check_excluded(filename):
for name in EXCLUDED:
if name in filename:
return True
return False
def print_report(text, list_files):
print("---------------------")
print(" {} FILES ({})".format(text, len(list_files)))
print("---------------------")
count = 1
for filename in list_files:
print("{} - {}".format(count, filename))
count += 1
print("")
if len(sys.argv) <= 1:
sys.exit(-1)
FILENAME = str(sys.argv[1])
with open(FILENAME) as fhandler:
all_lines = fhandler.readlines()
error_files = []
ok_files=[]
excluded_files=[]
in_error = False
current_file = None
for line in all_lines:
line = line.rstrip('\n')
if not line.startswith(STR_CHECKING) and not line.startswith(STR_DIRECTORY):
in_error = True
else:
if in_error and current_file:
if check_excluded(current_file):
excluded_files.append(current_file)
else:
error_files.append(current_file)
elif current_file is not None:
ok_files.append(current_file)
if line.startswith(STR_CHECKING):
current_file = line[len(STR_CHECKING):]
else:
current_file = None
in_error = False
if in_error and current_file:
error_files.append(current_file)
elif current_file is not None:
ok_files.append(current_file)
print_report("OK", ok_files)
print_report("EXCLUDED", excluded_files)
print_report("ERROR", error_files)
pass