-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
66 lines (56 loc) · 1.84 KB
/
setup.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
from os import error
import subprocess
import pandas as pd
import time
def get_error_list() -> list:
error_list = []
# Get path path
path = input('Please enter path. Press Enter for default. ')
while len(path) == 0:
path = '../../bearcat-gui'
print('Path accepted, processing errors...')
# Run terminal command to print ESLint errors
terminal = subprocess.Popen(
'tslint --config ./tslint.json --project .',
shell=True,
cwd= path,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
# Reads/decodes/appends each terminal line to a list
for line in terminal.stdout.readlines():
line = line.decode('UTF-8')
error_list.append(line)
retval = terminal.wait()
path = path.split('/', 2)
directory = str(path[2])
print(type(directory))
return error_list, directory
def format_errors(error_list: list, directory: str) -> dict:
dictionary = dict()
key = ''
d_values = []
print(f'In formater. Directory: { directory }')
df = pd.DataFrame(error_list, columns=['Console Output'])
print('Data frame created')
# print(df)
for index, row in df.iterrows():
# If no filepath has been found yet
if key != '':
if directory in row.values[0]:
key = row.values[0]
if 'ERROR' in row.values[0]:
d_values.append(row.values[0])
print('Value appended!')
if str(row.values[0]).isspace():
print('This is an empty string.')
dictionary[key] = d_values
key = ''
d_values = []
# If filepath is defined
else:
if directory in row.values[0]:
print('KEY FOUND!')
key = row.values[0]
print(key)
return dictionary