-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisualizer.py
50 lines (44 loc) · 2.23 KB
/
visualizer.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
import os
import gvInput
import output
import actionsProcessor
class Visualizer(object):
"""Main class of the program, holds the important data (node and edge lists)."""
def __init__(self, blivet=None, palletePath="assets/pallete.xml"):
self.blivet = blivet
self.node_list = []
self.edge_list = []
self.palletePath = palletePath
def prepare_nodes(self):
""" prepare the nodes in node_list """
for n in self.node_list:
n.prepare()
def create_graph(self, graph_abs_path, graph_name):
""" Function that creates the a visualized graph using data extracted from blivet
:param str graph_name filename of the graph that is being created
:param graph_abs_path absolute path to the directory where the graph should be created
:param object blivet Blivet object from which to take the data
"""
if not os.path.exists(graph_abs_path):
os.mkdir(graph_abs_path)
gv_input = gvInput.GvInput(self.node_list, self.edge_list, self.palletePath, self.blivet)
gv_input.get_data_from_blivet()
self.prepare_nodes()
out = output.Output(self.node_list, self.edge_list)
out.create_svg(graph_abs_path, graph_name)
def create_actions_graph(self, graph_abs_path, graph_name):
""" Function that creates the a visualized graph using data extracted from blivet
:param str graph_name filename of the graph that is being created
:param graph_abs_path absolute path to the directory where the graph should be created
:param object blivet Blivet object from which to take the data
"""
if not os.path.exists(graph_abs_path):
os.mkdir(graph_abs_path)
gv_input = gvInput.GvInput(self.node_list, self.edge_list, self.palletePath, self.blivet)
gv_input.get_data_from_blivet()
print(self.blivet.devicetree.actions.find())
actions_processor = actionsProcessor.ActionsProcessor(self.blivet.devicetree.actions.find(), self.node_list, self.edge_list, self.palletePath)
actions_processor.process_actions()
self.prepare_nodes()
out = output.Output(self.node_list, self.edge_list)
out.create_svg(graph_abs_path, graph_name)