-
Notifications
You must be signed in to change notification settings - Fork 4
/
PylintRunner.py
43 lines (38 loc) · 1.15 KB
/
PylintRunner.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
from pylint import epylint as elint
import os
import sys
import json
if len(sys.argv) < 2:
print("not enough arguments")
exit()
basedir = sys.argv[1]
if basedir[-1] != '/':
basedir += '/'
outputDir = basedir+'../pylint_data'
if not os.path.exists(outputDir):
os.makedirs(outputDir)
print("directory \'" + outputDir + "\' created.")
totalCount = 0
result = []
for (root, dirs, file) in os.walk(basedir):
for f in file:
# print(f)
try:
pylint_stdout, pylint_stderr = elint.py_run(
root+'/'+f + ' --output-format=json', return_std=True)
# print(pylint_stdout.getvalue())
result.append(json.loads(pylint_stdout.getvalue()))
except:
print('error in file: ' + f)
totalCount += 1
if totalCount % 100 == 0:
print(totalCount)
with open(outputDir+'/'+str(totalCount)+'.json', 'w') as f:
f.write(json.dumps(result))
f.close()
result = []
if len(result) > 0:
with open(outputDir+'/'+str(totalCount)+'.json', 'w') as f:
f.write(json.dumps(result))
f.close()
result = []