Skip to content

Commit

Permalink
Merge pull request #48 from aroberge/master
Browse files Browse the repository at this point in the history
New start-color option
  • Loading branch information
thebjorn authored Dec 3, 2019
2 parents 2015c21 + 5ea9e7b commit bef746a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pydeps/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def parse_args(argv=()):
args.add('--max-cluster-size', default=0, type=int, metavar="INT", help="the maximum number of nodes a dependency can have before the cluster is collapsed to a single node (default=0)")
args.add('--keep-target-cluster', action='store_true', help="draw target module as a cluster")
args.add('--rmprefix', default=[], nargs="+", metavar="PREFIX", help="remove PREFIX from the displayed name of the nodes")
args.add('--start-color', default=0, type=int, metavar="INT", help="starting value for hue from 0 (red/default) to 360.")

_args = args.parse_args(argv)

Expand All @@ -140,6 +141,7 @@ def parse_args(argv=()):
noise_level=200, noshow=True, output=None, pylib=False, pylib_all=False,
show=False, show_cycles=False, show_deps=False, show_dot=False,
show_raw_deps=False, verbose=0, include_missing=True, reverse=False,
start_color=0
)

_args.show = True
Expand Down
5 changes: 4 additions & 1 deletion pydeps/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# noinspection PyAugmentAssignment
# import hashlib

START_COLOR = 0 # Value can be changed from command-line argument


def frange(start, end, step):
"""Like range(), but with floats.
Expand All @@ -20,7 +22,8 @@ def distinct_hues(count):
"""Return ``count`` hues, equidistantly spaced.
"""
for i in frange(0., 360., 360. / count):
yield i / 360.
hue = ((i + START_COLOR) % 360) / 360.
yield hue


class ColorSpace(object):
Expand Down
4 changes: 3 additions & 1 deletion pydeps/pydeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
from . import py2depgraph, cli, dot, target
from .depgraph2dot import dep2dot, cycles2dot
import logging
from . import colors
log = logging.getLogger(__name__)


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')
Expand Down Expand Up @@ -74,7 +76,7 @@ def externals(trgt, **kwargs):
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,
show_raw_deps=False, verbose=0, include_missing=True, start_color=0
)
kw.update(kwargs)
depgraph = py2depgraph.py2dep(trgt, **kw)
Expand Down

0 comments on commit bef746a

Please sign in to comment.