scripts: treemap.py/codemap.py: Tweaked -L to imply -l
And added the optional --no-label to explicitly opt out. This is a bit more consistent with treemapd3.py/codemapd3.py's handling of labels, while still keeping the no-label default. It also makes it easier to temporarily hide labels when editing commands.
This commit is contained in:
+6
-1
@@ -717,6 +717,7 @@ def main(paths, *,
|
|||||||
title=None,
|
title=None,
|
||||||
padding=0,
|
padding=0,
|
||||||
label=False,
|
label=False,
|
||||||
|
no_label=False,
|
||||||
**args):
|
**args):
|
||||||
# figure out what color should be
|
# figure out what color should be
|
||||||
if color == 'auto':
|
if color == 'auto':
|
||||||
@@ -1100,7 +1101,7 @@ def main(paths, *,
|
|||||||
else chars_[0]),
|
else chars_[0]),
|
||||||
color=t.color if t.color is not None else colors_[0])
|
color=t.color if t.color is not None else colors_[0])
|
||||||
|
|
||||||
if label:
|
if label or (labels and not no_label):
|
||||||
if t.label is not None:
|
if t.label is not None:
|
||||||
label__ = t.label
|
label__ = t.label
|
||||||
else:
|
else:
|
||||||
@@ -1315,6 +1316,10 @@ if __name__ == "__main__":
|
|||||||
'-l', '--label',
|
'-l', '--label',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help="Render labels.")
|
help="Render labels.")
|
||||||
|
parser.add_argument(
|
||||||
|
'--no-label',
|
||||||
|
action='store_true',
|
||||||
|
help="Don't render any labels.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--code-path',
|
'--code-path',
|
||||||
type=lambda x: x.split(),
|
type=lambda x: x.split(),
|
||||||
|
|||||||
+8
-5
@@ -731,6 +731,7 @@ def main(csv_paths, *,
|
|||||||
title=None,
|
title=None,
|
||||||
padding=0,
|
padding=0,
|
||||||
label=False,
|
label=False,
|
||||||
|
no_label=False,
|
||||||
**args):
|
**args):
|
||||||
# figure out what color should be
|
# figure out what color should be
|
||||||
if color == 'auto':
|
if color == 'auto':
|
||||||
@@ -785,18 +786,16 @@ def main(csv_paths, *,
|
|||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
# if by not specified, guess it's anything not in fields/labels/defines
|
# if by not specified, guess it's anything not in fields/defines
|
||||||
if not by:
|
if not by:
|
||||||
by = [k for k in fields_
|
by = [k for k in fields_
|
||||||
if k not in (fields or [])
|
if k not in (fields or [])
|
||||||
and k not in (labels or [])
|
|
||||||
and not any(k == k_ for k_, _ in defines)]
|
and not any(k == k_ for k_, _ in defines)]
|
||||||
|
|
||||||
# if fields not specified, guess it's anything not in by/labels/defines
|
# if fields not specified, guess it's anything not in by/defines
|
||||||
if not fields:
|
if not fields:
|
||||||
fields = [k for k in fields_
|
fields = [k for k in fields_
|
||||||
if k not in (by or [])
|
if k not in (by or [])
|
||||||
and k not in (labels or [])
|
|
||||||
and not any(k == k_ for k_, _ in defines)]
|
and not any(k == k_ for k_, _ in defines)]
|
||||||
|
|
||||||
# then extract the requested dataset
|
# then extract the requested dataset
|
||||||
@@ -977,7 +976,7 @@ def main(csv_paths, *,
|
|||||||
else chars_[0]),
|
else chars_[0]),
|
||||||
color=t.color if t.color is not None else colors_[0])
|
color=t.color if t.color is not None else colors_[0])
|
||||||
|
|
||||||
if label:
|
if label or (labels and not no_label):
|
||||||
if t.label is not None:
|
if t.label is not None:
|
||||||
label__ = t.label
|
label__ = t.label
|
||||||
else:
|
else:
|
||||||
@@ -1187,6 +1186,10 @@ if __name__ == "__main__":
|
|||||||
'-l', '--label',
|
'-l', '--label',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help="Render labels.")
|
help="Render labels.")
|
||||||
|
parser.add_argument(
|
||||||
|
'--no-label',
|
||||||
|
action='store_true',
|
||||||
|
help="Don't render any labels.")
|
||||||
sys.exit(main(**{k: v
|
sys.exit(main(**{k: v
|
||||||
for k, v in vars(parser.parse_intermixed_args()).items()
|
for k, v in vars(parser.parse_intermixed_args()).items()
|
||||||
if v is not None}))
|
if v is not None}))
|
||||||
|
|||||||
@@ -619,14 +619,12 @@ def main(csv_paths, output, *,
|
|||||||
if not by:
|
if not by:
|
||||||
by = [k for k in fields_
|
by = [k for k in fields_
|
||||||
if k not in (fields or [])
|
if k not in (fields or [])
|
||||||
and k not in (labels or [])
|
|
||||||
and not any(k == k_ for k_, _ in defines)]
|
and not any(k == k_ for k_, _ in defines)]
|
||||||
|
|
||||||
# if fields not specified, guess it's anything not in by/labels/defines
|
# if fields not specified, guess it's anything not in by/labels/defines
|
||||||
if not fields:
|
if not fields:
|
||||||
fields = [k for k in fields_
|
fields = [k for k in fields_
|
||||||
if k not in (by or [])
|
if k not in (by or [])
|
||||||
and k not in (labels or [])
|
|
||||||
and not any(k == k_ for k_, _ in defines)]
|
and not any(k == k_ for k_, _ in defines)]
|
||||||
|
|
||||||
# then extract the requested dataset
|
# then extract the requested dataset
|
||||||
|
|||||||
Reference in New Issue
Block a user