Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def depgrf(item, args=""):
return py2dep(item, **empty(args))
# Pass args as a **kw dict since we need to pass it down to functions
# called, but extract locally relevant parameters first to make the
# code prettier (and more fault tolerant).
colors.START_COLOR = kw.get('start_color')
show_cycles = kw.get('show_cycles')
nodot = kw.get('nodot')
no_output = kw.get('no_output')
output = kw.get('output')
fmt = kw['format']
show_svg = kw.get('show')
reverse = kw.get('reverse')
if os.getcwd() != trgt.workdir:
# the tests are calling _pydeps directoy
os.chdir(trgt.workdir)
dep_graph = py2depgraph.py2dep(trgt, **kw)
if kw.get('show_deps'):
cli.verbose("DEPS:")
pprint.pprint(dep_graph)
dotsrc = depgraph_to_dotsrc(trgt, dep_graph, **kw)
if not nodot:
if kw.get('show_dot'):
cli.verbose("DOTSRC:")
print(dotsrc)
if not no_output:
svg = dot.call_graphviz_dot(dotsrc, fmt)
if fmt == 'svg':
svg = svg.replace(b'', b'<style>.edge>path:hover{stroke-width:8}</style>')
def externals(trgt, **kwargs):
"""Return a list of direct external dependencies of ``pkgname``.
Called for the ``pydeps --externals`` command.
"""
kw = dict(
T='svg', config=None, debug=False, display=None, exclude=[], exclude_exact=[],
externals=True, format='svg', max_bacon=2**65, no_config=True, nodot=False,
noise_level=2**65, noshow=True, output=None, pylib=True, pylib_all=True,
show=False, show_cycles=False, show_deps=False, show_dot=False,
show_raw_deps=False, verbose=0, include_missing=True, start_color=0
)
kw.update(kwargs)
depgraph = py2depgraph.py2dep(trgt, **kw)
pkgname = trgt.fname
log.info("DEPGRAPH: %s", depgraph)
pkgname = os.path.splitext(pkgname)[0]
res = {}
ext = set()
for k, src in list(depgraph.sources.items()):
if k.startswith('_'):
continue
if not k.startswith(pkgname):
continue
if src.imports:
imps = [imp for imp in src.imports if not imp.startswith(pkgname)]
if imps:
for imp in imps: