Skip to content

Commit bef746a

Browse files
authored
Merge pull request #48 from aroberge/master
New start-color option
2 parents 2015c21 + 5ea9e7b commit bef746a

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

pydeps/cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ def parse_args(argv=()):
130130
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)")
131131
args.add('--keep-target-cluster', action='store_true', help="draw target module as a cluster")
132132
args.add('--rmprefix', default=[], nargs="+", metavar="PREFIX", help="remove PREFIX from the displayed name of the nodes")
133+
args.add('--start-color', default=0, type=int, metavar="INT", help="starting value for hue from 0 (red/default) to 360.")
133134

134135
_args = args.parse_args(argv)
135136

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

145147
_args.show = True

pydeps/colors.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# noinspection PyAugmentAssignment
77
# import hashlib
88

9+
START_COLOR = 0 # Value can be changed from command-line argument
10+
911

1012
def frange(start, end, step):
1113
"""Like range(), but with floats.
@@ -20,7 +22,8 @@ def distinct_hues(count):
2022
"""Return ``count`` hues, equidistantly spaced.
2123
"""
2224
for i in frange(0., 360., 360. / count):
23-
yield i / 360.
25+
hue = ((i + START_COLOR) % 360) / 360.
26+
yield hue
2427

2528

2629
class ColorSpace(object):

pydeps/pydeps.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
from . import py2depgraph, cli, dot, target
1010
from .depgraph2dot import dep2dot, cycles2dot
1111
import logging
12+
from . import colors
1213
log = logging.getLogger(__name__)
1314

1415

1516
def _pydeps(trgt, **kw):
1617
# Pass args as a **kw dict since we need to pass it down to functions
1718
# called, but extract locally relevant parameters first to make the
1819
# code prettier (and more fault tolerant).
20+
colors.START_COLOR = kw.get('start_color')
1921
show_cycles = kw.get('show_cycles')
2022
nodot = kw.get('nodot')
2123
no_output = kw.get('no_output')
@@ -74,7 +76,7 @@ def externals(trgt, **kwargs):
7476
externals=True, format='svg', max_bacon=2**65, no_config=True, nodot=False,
7577
noise_level=2**65, noshow=True, output=None, pylib=True, pylib_all=True,
7678
show=False, show_cycles=False, show_deps=False, show_dot=False,
77-
show_raw_deps=False, verbose=0, include_missing=True,
79+
show_raw_deps=False, verbose=0, include_missing=True, start_color=0
7880
)
7981
kw.update(kwargs)
8082
depgraph = py2depgraph.py2dep(trgt, **kw)

0 commit comments

Comments
 (0)