-
Notifications
You must be signed in to change notification settings - Fork 10
Restore compliance with the crusty "pydot" API #59
Description
README.rst
boldly claims that:
This library is API compatible with original pydot so you can use it like this:
import pydot_ng as pydot
Of course, this hasn't been true for over three years; pydot-ng
only adheres to the old pydot
API. The new pydot
API is considerably different. Downstream consumers that actually try to import pydot_ng as pydot
are gonna have a Bad Time™.
Just Shoot Me Now
Notably, most top-level pydot
functions and methods (e.g., pydot.graph_from_dot_data()
) now unconditionally return a list
of one or more Graph
objects rather than conditionally returning either a single Graph
object or a list
of two or more Graph
objects. To quote @johnyf in an ancient pydot
issue:
An earlier version of the API used to return a graph object when the dot file defined one graph, and a
list
of graphs otherwise (in the case of more graphs). However, I found that the inhomogeneous behavior is more complex (simple is better than complex, PEP 20), so I changed it to return alist
in all cases (e.g., a list containing one graph). This simplifies also user code, because there no case distinction needs to be made.
These are useful changes – but they do break backward compatibility. For conformance with the modern pydot
API, it's critical that the pydot-ng
API be refactored to behave similarly.
But... Can It Be Done?
It can! With perseverance and hideous suffering, anything is possible.
Since these API changes are largely undocumented, the simplest solution might be to:
- Integrate the most recent
pydot
test suite into the existingpydot-ng
test suite. - Manually fix each broken test – one by one.
For these purposes, test/pydot_unittest.py
is the only useful file. Relevant unit tests include:
test_attribute_with_implicit_value
.test_unicode_ids
.test_graph_with_shapefiles
.test_multiple_graphs
.
Godspeed You Intrepid Coder!
Best of luck, @prmtl. I'd submit a pull request resolving this, but we have our hands full just trying to survive the oncoming Canadian winter. Because in Canada, winter is always coming.
Perpetual snow and unyielding darkness. It isn't easy, folks. ❄️ ☃️ 🏔️