Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to preserve dot file #182

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Stillerman
Copy link

Diagram("Label", outformat="png", preserve_graphviz_file=True)

will preserve the dot file generated for later use.

I could also refactor this so that dot file is preserved when outformat="dot"

This is a non-breaking change because preserve_graphviz_file is False by default.

@@ -487,7 +490,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(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this line changed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto formatter must have done that. It doesn't improve readability much though, I will revert it.

@@ -83,6 +83,7 @@ def __init__(
graph_attr: dict = {},
node_attr: dict = {},
edge_attr: dict = {},
preserve_graphviz_file: bool = False
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about preserve_dot_file?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that better

@@ -138,7 +140,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):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parentheses are not needed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's my javascript coming out... I'll put it back

@mingrammer mingrammer added the kind/feature New feature or request label May 31, 2020
@mingrammer
Copy link
Owner

mingrammer commented May 31, 2020

Does outformat="dot" generate only a dot file?

@Stillerman
Copy link
Author

No, but I can arrange for that.

@Stillerman
Copy link
Author

How about when preserve_dot_file is true, the dot file is kept, and if outformat=dot then the file is produced regardless of preserve_dot_file.

@mingrammer
Copy link
Owner

mingrammer commented Jun 9, 2020

IMO, outformat=dot may make users confused a bit due to it has different purposes other than the other image format options. preserve_dot_file option would be enough.

@steschuser
Copy link

Any changes this gets merged soonish?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants