Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_colors(self, src, colorspace=None):
if colorspace is None:
if src.basename not in self.colors:
h = self.curhue
# self.curhue += 7 # relative prime with 360
self.curhue += 37 # relative prime with 360
self.curhue %= 360
# print "NAME:", src.name, "BASENAME:", src.basename
bg = colors.name2rgb(h)
black = (0, 0, 0)
white = (255, 255, 255)
fg = colors.foreground(bg, black, white)
self.colors[src.basename] = bg, fg
return self.colors[src.basename]
else:
return colorspace.color(src)
visited.add(a)
visited.add(b)
space = colors.ColorSpace(visited)
for src in sorted(visited):
bg, fg = depgraph.get_colors(src, space)
kwargs = {}
if src.name in depgraph.cyclenodes:
kwargs['shape'] = 'octagon'
ctx.write_node(
src.name,
label=src.get_label(splitlength=14,
rmprefix=self.kw.get('rmprefix')),
fillcolor=colors.rgb2css(bg),
fontcolor=colors.rgb2css(fg),
**kwargs
)
return ctx.text()
def _pydeps(trgt, **kw):
# 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)
# b imports a
aname = a.name
bname = b.name
if (bname, aname) in drawn:
continue
drawn.add((bname, aname))
ctx.write_rule(
aname, bname,
weight=depgraph.proximity_metric(a, b),
minlen=depgraph.dissimilarity_metric(a, b))
visited.add(a)
visited.add(b)
space = colors.ColorSpace(visited)
for src in sorted(visited):
bg, fg = depgraph.get_colors(src, space)
kwargs = {}
if src.name in depgraph.cyclenodes:
kwargs['shape'] = 'octagon'
ctx.write_node(
src.name,
label=src.get_label(splitlength=14,
rmprefix=self.kw.get('rmprefix')),
fillcolor=colors.rgb2css(bg),
fontcolor=colors.rgb2css(fg),
**kwargs
)
for aname, bname in depgraph.cyclerelations:
try:
a = depgraph.sources[aname]
b = depgraph.sources[bname]
except KeyError:
continue
drawn.add((bname, aname))
ctx.write_rule(
bname, aname,
weight=depgraph.proximity_metric(a, b),
minlen=depgraph.dissimilarity_metric(a, b),
)
visited.add(a)
visited.add(b)
space = colors.ColorSpace(visited)
for src in visited:
bg, fg = depgraph.get_colors(src, space)
kwargs = {}
if src.name in depgraph.cyclenodes:
kwargs['shape'] = 'octagon'
ctx.write_node(
src.name, label=src.label,
fillcolor=colors.rgb2css(bg),
fontcolor=colors.rgb2css(fg),
**kwargs
)
return ctx.text()
minlen=depgraph.dissimilarity_metric(a, b),
)
visited.add(a)
visited.add(b)
space = colors.ColorSpace(visited)
for src in visited:
bg, fg = depgraph.get_colors(src, space)
kwargs = {}
if src.name in depgraph.cyclenodes:
kwargs['shape'] = 'octagon'
ctx.write_node(
src.name, label=src.label,
fillcolor=colors.rgb2css(bg),
fontcolor=colors.rgb2css(fg),
**kwargs
)
return ctx.text()