Added option to preserve GraphViz file

pull/182/head
Jason Stillerman 5 years ago
parent 8a9012fa24
commit 36e07fb5f3

@ -83,6 +83,7 @@ class Diagram:
graph_attr: dict = {}, graph_attr: dict = {},
node_attr: dict = {}, node_attr: dict = {},
edge_attr: dict = {}, edge_attr: dict = {},
preserve_graphviz_file=false
): ):
"""Diagram represents a global diagrams context. """Diagram represents a global diagrams context.
@ -138,7 +139,8 @@ class Diagram:
def __exit__(self, exc_type, exc_value, traceback): def __exit__(self, exc_type, exc_value, traceback):
self.render() self.render()
# Remove the graphviz file leaving only the image. # Remove the graphviz file leaving only the image.
os.remove(self.filename) if (not self.preserve_graphviz_file):
os.remove(self.filename)
setdiagram(None) setdiagram(None)
def _repr_png_(self): def _repr_png_(self):
@ -487,7 +489,8 @@ class Edge:
self._attrs = o.attrs.copy() self._attrs = o.attrs.copy()
result.append(o) result.append(o)
else: else:
result.append(Edge(o, forward=forward, reverse=reverse, **self._attrs)) result.append(
Edge(o, forward=forward, reverse=reverse, **self._attrs))
return result return result
def connect(self, other: Union["Node", "Edge", List["Node"]]): def connect(self, other: Union["Node", "Edge", List["Node"]]):

Loading…
Cancel
Save