forked from PaoloGit99/sherlock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtable.py
70 lines (52 loc) · 1.41 KB
/
table.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
from tabulate import tabulate
import json
import os
def print_table(data):
table_in = []
table_out = []
for k, v in data.items():
print(k)
for key, value in v.items():
if isinstance(value, dict):
print("\t"+key)
for keyy, valuee in value.items():
if isinstance(valuee, dict):
for keyyy, valueee in valuee.items():
if keyyy == "Hop-By-Hop":
continue
if isinstance(valueee, dict):
print(f"\t\t{keyy}\t{keyyy}")
for keyyyy, valueeee in valueee.items():
if keyyyy == "Experiments":
continue
print(f"\t\t\t{keyyyy}\t{valueeee}\n")
else:
print(f"\t\t{keyy}\t\t{keyyy}\t{valueee}")
continue
print("\t\t"+keyy+"\t\t"+str(valuee))
table_in.append([keyy, str(valuee)])
else:
print("\t"+key+"\t\t"+str(value))
table_out.append([key, str(value)])
print("\n")
names = {}
ID = 0
files = os.listdir("./output")
print("\nShowing \'./output\' directory:\n")
for f in files:
if f[0]==".":
continue
ID += 1
names[ID] = f
print(f"\t{ID} - {f}")
print("")
if ID == 0:
print("Output folder is empty, please run \"python3 start.py\"")
else:
fileid = int(input("Please insert the desired output ID: "))
if fileid not in names.keys():
print("ID not valid\nReturn None")
else:
with open("./output/"+names[fileid]) as file:
data = json.load(file)
print_table(data)