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`
This commit is contained in:
parent
daab8d9109
commit
b27fbfb379
@ -275,6 +275,8 @@ class LineAnnotationDumper(OrderedLineDumper):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(LineAnnotationDumper, self).__init__(*args, **kwargs)
|
super(LineAnnotationDumper, self).__init__(*args, **kwargs)
|
||||||
del _annotations[:]
|
del _annotations[:]
|
||||||
|
self.colors = 'KgrbmcyGRBMCY'
|
||||||
|
self.filename_colors = {}
|
||||||
|
|
||||||
def process_scalar(self):
|
def process_scalar(self):
|
||||||
super(LineAnnotationDumper, self).process_scalar()
|
super(LineAnnotationDumper, self).process_scalar()
|
||||||
@ -301,7 +303,15 @@ def write_line_break(self):
|
|||||||
# append annotations at the end of each line
|
# append annotations at the end of each line
|
||||||
if self.saved:
|
if self.saved:
|
||||||
mark = self.saved._start_mark
|
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:
|
if mark.line is not None:
|
||||||
ann += ':@c{%s}' % (mark.line + 1)
|
ann += ':@c{%s}' % (mark.line + 1)
|
||||||
_annotations.append(colorize(ann))
|
_annotations.append(colorize(ann))
|
||||||
|
Loading…
Reference in New Issue
Block a user