summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2018-10-26 22:19:11 -0700
committerGitHub <noreply@github.com>2018-10-26 22:19:11 -0700
commitb27fbfb379926cf1df81d6c4ae644377d3b95b82 (patch)
treedd576747dc5c8f7bfac8f17cac6b93bb829690b4 /lib
parentdaab8d9109550c6bed9ac69601edd1ec28836eac (diff)
downloadspack-b27fbfb379926cf1df81d6c4ae644377d3b95b82.tar.gz
spack-b27fbfb379926cf1df81d6c4ae644377d3b95b82.tar.bz2
spack-b27fbfb379926cf1df81d6c4ae644377d3b95b82.tar.xz
spack-b27fbfb379926cf1df81d6c4ae644377d3b95b82.zip
config: `spack config blame` now colors filenames in config output (#9656)
- it was hard to distinguish all-gray filenames - added rotating colors to `spack config blame`
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/util/spack_yaml.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/spack/spack/util/spack_yaml.py b/lib/spack/spack/util/spack_yaml.py
index ee4b37388c..a1966664d9 100644
--- a/lib/spack/spack/util/spack_yaml.py
+++ b/lib/spack/spack/util/spack_yaml.py
@@ -275,6 +275,8 @@ class LineAnnotationDumper(OrderedLineDumper):
def __init__(self, *args, **kwargs):
super(LineAnnotationDumper, self).__init__(*args, **kwargs)
del _annotations[:]
+ self.colors = 'KgrbmcyGRBMCY'
+ self.filename_colors = {}
def process_scalar(self):
super(LineAnnotationDumper, self).process_scalar()
@@ -301,7 +303,15 @@ class LineAnnotationDumper(OrderedLineDumper):
# append annotations at the end of each line
if self.saved:
mark = self.saved._start_mark
- ann = '@K{%s}' % mark.name
+
+ color = self.filename_colors.get(mark.name)
+ if not color:
+ ncolors = len(self.colors)
+ color = self.colors[len(self.filename_colors) % ncolors]
+ self.filename_colors[mark.name] = color
+
+ fmt = '@%s{%%s}' % color
+ ann = fmt % mark.name
if mark.line is not None:
ann += ':@c{%s}' % (mark.line + 1)
_annotations.append(colorize(ann))