From 36e07fb5f347f0e33f1d381f51a8c6618550377d Mon Sep 17 00:00:00 2001 From: Jason Stillerman Date: Sat, 30 May 2020 13:11:38 -0400 Subject: [PATCH 1/3] Added option to preserve GraphViz file --- diagrams/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/diagrams/__init__.py b/diagrams/__init__.py index d65bf379b..3d7521fdf 100644 --- a/diagrams/__init__.py +++ b/diagrams/__init__.py @@ -83,6 +83,7 @@ def __init__( graph_attr: dict = {}, node_attr: dict = {}, edge_attr: dict = {}, + preserve_graphviz_file=false ): """Diagram represents a global diagrams context. @@ -138,7 +139,8 @@ def __enter__(self): def __exit__(self, exc_type, exc_value, traceback): self.render() # Remove the graphviz file leaving only the image. - os.remove(self.filename) + if (not self.preserve_graphviz_file): + os.remove(self.filename) setdiagram(None) def _repr_png_(self): @@ -487,7 +489,8 @@ def append(self, other: Union[List["Node"], List["Edge"]], forward=None, reverse self._attrs = o.attrs.copy() result.append(o) else: - result.append(Edge(o, forward=forward, reverse=reverse, **self._attrs)) + result.append( + Edge(o, forward=forward, reverse=reverse, **self._attrs)) return result def connect(self, other: Union["Node", "Edge", List["Node"]]): From 2fd6ee7cd9282d6dead2d70032705544004adb10 Mon Sep 17 00:00:00 2001 From: Jason Stillerman Date: Sat, 30 May 2020 13:33:05 -0400 Subject: [PATCH 2/3] false -> False --- diagrams/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diagrams/__init__.py b/diagrams/__init__.py index 3d7521fdf..a5d546852 100644 --- a/diagrams/__init__.py +++ b/diagrams/__init__.py @@ -83,7 +83,7 @@ def __init__( graph_attr: dict = {}, node_attr: dict = {}, edge_attr: dict = {}, - preserve_graphviz_file=false + preserve_graphviz_file=False ): """Diagram represents a global diagrams context. From e4e725f2db8e821d5c63d64e1c2d20b69fb6506b Mon Sep 17 00:00:00 2001 From: Jason Stillerman Date: Sat, 30 May 2020 13:49:17 -0400 Subject: [PATCH 3/3] Assign new diagram property to self --- diagrams/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/diagrams/__init__.py b/diagrams/__init__.py index a5d546852..ab7e21806 100644 --- a/diagrams/__init__.py +++ b/diagrams/__init__.py @@ -83,7 +83,7 @@ def __init__( graph_attr: dict = {}, node_attr: dict = {}, edge_attr: dict = {}, - preserve_graphviz_file=False + preserve_graphviz_file: bool = False ): """Diagram represents a global diagrams context. @@ -128,6 +128,7 @@ def __init__( self.dot.edge_attr.update(edge_attr) self.show = show + self.preserve_graphviz_file = preserve_graphviz_file def __str__(self) -> str: return str(self.dot)