forked from morten1982/crossCobra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pycodechecker.py
40 lines (26 loc) · 906 Bytes
/
pycodechecker.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
import io
from pycodestyle import Checker
from contextlib import redirect_stdout
class PyCodeChecker():
def __init__(self, filename):
self.checker = Checker(filename)
def getString(self):
with io.StringIO() as buf, redirect_stdout(buf):
self.checker.check_all()
output = buf.getvalue()
return output
def getListFromString(self, text):
rawList = []
rawList = text.split("\n")
parseList = []
for line in rawList:
obj = line.split(':')
parseList.append(obj)
lineList = []
cursorList = []
textList = []
for obj in parseList[:-1]: # last element is ''
lineList.append(obj[1])
cursorList.append(obj[2])
textList.append(obj[3])
return lineList, cursorList, textList