-
Notifications
You must be signed in to change notification settings - Fork 129
Description
I'm trying to use pydeps as a library, to get the SVG as text, and not output it in a file.
The examples in #50 do not allow to do that.
What I'm doing instead is this:
from pydeps import py2depgraph, dot
from pydeps.pydeps import depgraph_to_dotsrc
from pydeps.target import Target
target = Target("src/mkdocstrings")
with target.chdir_work():
dep_graph = py2depgraph.py2dep(target)
dot_src = depgraph_to_dotsrc(target, dep_graph)
svg = dot.call_graphviz_dot(dot_src, "svg")The problem is that this code reaches cli.verbose(...) while cli.verbose is not initialized, and is still None, resulting in a not callable exception. This forces me to do this:
from pydeps import cli
cli.verbose = cli._not_verbose...which is a bit cumbersome 😅
Then I ran into other errors because of missing arguments, and it's very hard to know which one I need since they are hidden along a good part of the call chain in **kwargs dicts, and otherwise are not set to default values. I had to run back and forth debugging inspection to get the first options:
options = {"exclude_exact": [], "exclude": [], "only": ["mkdocstrings"], "show_cycles": False, "show_raw_deps": False}...then stopped and decided to actually use the argument parser:
options = cli.parse_args(["src/mkdocstrings", "--noshow", "--only", "mkdocstrings"])
target = Target(options["fname"])
with target.chdir_work():
dep_graph = py2depgraph.py2dep(target, **options)
dot_src = depgraph_to_dotsrc(target, dep_graph, **options)Anyway, I got it to work, so it's fine, this is just some feedback on using pydeps as a library 😅
Hope this can help others 🙂