Get list of supported image formats from dot
instead of hardcoding
#830
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR replaces a list of image formats supported by graphviz that is hardcoded in rustworkx/visualization/graphviz.py with a list that is taken dynamically from the executable
dot
. With the version ofdot
that I tested, this list had 50 entries, while the hardcoded list had 35.The immediate reason for this PR is due to a failure in the test suite despite having a working
dot
on the PATH. Apparentlydot
can be compiled with varying support for image formats. In addition on some linux distributions, including some Ubuntu and some Fedora, the packagegraphviz
does not support jpeg. But, installing the additional packagegraphviz-devel
does add jpeg support. Before this PR, this would cause an untrapped error and a failure in the test suite, because only the presence ofdot
is checked, not which images it supports. With this PR, if yourdot
does not supportjpeg
then the test for writing ajpeg
will be skipped.This PR also implements an error message that if both pillow and graphviz are missing says both are missing. Before, an error would be thrown with one message, then after installing the dependency, an error would be thrown with the second.
Fixes #811
I won't write the following tests until it's clear this will be merged.
TODO
pillow
,dot
and support for image formats.Potential issues
I read quite a bit of the fine documentation and forum posts trying to find how to get a list of formats. What I do here is ask for a bogus format and then parse the resulting error message, which contains a list of valid formats.