import collections import pydot_ng as pydot from fsmPygen import * from fsmClasses import * graph = pydot.graph_from_dot_file('data/graph2.gv') dot_edges = graph.get_edges() def parse_data(edges_p): states = {} edges = [] for e in edges_p: s, d, l = e.get_source(), e.get_destination(), e.get_label() start = states[s] = states.get(s, State(s)) end = states[d] = states.get(d, State(d)) edge = Edge(start, end, l) start.add_edge(edge) edges.append(edge) return states.values(), edges def generate_state_table(states, edges): d = collections.defaultdict(dict) en = set([e.label for e in edges]) for s in states:
def _render_with_pydot(self, filename): g = pydot.graph_from_dot_file(filename) if not isinstance(g, list): g = [g] jpe_data = NULL_SEP.join([_g.create(format='jpe') for _g in g]) return sha256(jpe_data).hexdigest()