interactive: Annotate ti and *spi with annotations
This commit is contained in:
parent
9d2e14f5dc
commit
d98fc78de6
@ -131,7 +131,7 @@ def use(repo=None):
|
|||||||
if annotation_file:
|
if annotation_file:
|
||||||
LOG.info("Loading annotations from %s", annotation_file)
|
LOG.info("Loading annotations from %s", annotation_file)
|
||||||
with open(annotation_file, "r") as f:
|
with open(annotation_file, "r") as f:
|
||||||
ANNOTATES = dict(line.split('\t', 1) for line in f)
|
ANNOTATES = dict(line.strip().split('\t', 1) for line in f)
|
||||||
LOG.info("DONE")
|
LOG.info("DONE")
|
||||||
|
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ def update_days(to=pager):
|
|||||||
def _spi_by_predicate(pred, colors):
|
def _spi_by_predicate(pred, colors):
|
||||||
colors = colors or colorize.COLORS
|
colors = colors or colorize.COLORS
|
||||||
return '\n'.join(
|
return '\n'.join(
|
||||||
reports.package_one_line(name, BY_NAME, PACKAGE_TASKS)
|
reports.package_one_line(name, BY_NAME, PACKAGE_TASKS, ANNOTATES)
|
||||||
for name in sorted(BY_NAME)
|
for name in sorted(BY_NAME)
|
||||||
if pred(name) and BY_NAME[name][0] in colors)
|
if pred(name) and BY_NAME[name][0] in colors)
|
||||||
|
|
||||||
@ -190,12 +190,20 @@ def list_spi(pkgs, colors=None, to=print):
|
|||||||
to(lines)
|
to(lines)
|
||||||
|
|
||||||
|
|
||||||
def _colorizer():
|
def _annotator():
|
||||||
return colorize.package_colorizer(BY_NAME, 'NONE')
|
clr = colorize.package_colorizer(BY_NAME, 'NONE')
|
||||||
|
|
||||||
|
def _the_annotator(name):
|
||||||
|
ann = ANNOTATES.get(name)
|
||||||
|
if (ann):
|
||||||
|
return clr(name) + ' ' + ann
|
||||||
|
else:
|
||||||
|
return clr(name)
|
||||||
|
return _the_annotator
|
||||||
|
|
||||||
|
|
||||||
def ti(num, to=print):
|
def ti(num, to=print):
|
||||||
to(tasks.format_task(get_task(num, TASKS), _colorizer()))
|
to(tasks.format_task(get_task(num, TASKS), _annotator()))
|
||||||
|
|
||||||
|
|
||||||
def display_tasks(infos=None, num=None, min_id=None, sort=None,
|
def display_tasks(infos=None, num=None, min_id=None, sort=None,
|
||||||
@ -205,7 +213,7 @@ def display_tasks(infos=None, num=None, min_id=None, sort=None,
|
|||||||
infos = (t for t in infos if t['taskid'] >= min_id)
|
infos = (t for t in infos if t['taskid'] >= min_id)
|
||||||
if sort is not None:
|
if sort is not None:
|
||||||
infos = sorted(infos, key=lambda t: t[sort])
|
infos = sorted(infos, key=lambda t: t[sort])
|
||||||
czr = _colorizer()
|
czr = _annotator()
|
||||||
infos = (tasks.format_task(t, czr) for t in infos)
|
infos = (tasks.format_task(t, czr) for t in infos)
|
||||||
if include:
|
if include:
|
||||||
pi = re.compile(include)
|
pi = re.compile(include)
|
||||||
@ -243,7 +251,7 @@ def _fresh_subtasks(info):
|
|||||||
def fresh(num, color=True, to=print):
|
def fresh(num, color=True, to=print):
|
||||||
subtasks = _fresh_subtasks(get_task(num, TASKS))
|
subtasks = _fresh_subtasks(get_task(num, TASKS))
|
||||||
if subtasks:
|
if subtasks:
|
||||||
clr = _colorizer() if color else None
|
clr = _annotator() if color else None
|
||||||
items = sorted((int(k), tasks.format_subtask(s, clr))
|
items = sorted((int(k), tasks.format_subtask(s, clr))
|
||||||
for k, s in utils.items(subtasks))
|
for k, s in utils.items(subtasks))
|
||||||
to('\n'.join('%6d %s' % item for item in items))
|
to('\n'.join('%6d %s' % item for item in items))
|
||||||
@ -306,7 +314,7 @@ def inapt_reporter():
|
|||||||
d = inapt.DependencyInfo.load(CONFIG['repos'][CURRENT['base']])
|
d = inapt.DependencyInfo.load(CONFIG['repos'][CURRENT['base']])
|
||||||
|
|
||||||
def _reporter(name, to=pager):
|
def _reporter(name, to=pager):
|
||||||
to(d.recursive_srpm_report(name, _colorizer()))
|
to(d.recursive_srpm_report(name, _annotator()))
|
||||||
|
|
||||||
return _reporter
|
return _reporter
|
||||||
|
|
||||||
|
@ -57,9 +57,15 @@ def color_totals(by_color, names=None, total=None, summary=False):
|
|||||||
return text_totals(keys, data, legend, total)
|
return text_totals(keys, data, legend, total)
|
||||||
|
|
||||||
|
|
||||||
def package_one_line(name, by_name, package_tasks, separator='\t'):
|
def package_one_line(name, by_name, package_tasks,
|
||||||
|
annotations=None, separator='\t'):
|
||||||
color, bp, np = by_name[name]
|
color, bp, np = by_name[name]
|
||||||
tasks_str = tasks.format_tasks_short(package_tasks.get(name))
|
tasks_str = tasks.format_tasks_short(package_tasks.get(name))
|
||||||
|
if annotations is not None:
|
||||||
|
ann = annotations.get(name, '')
|
||||||
|
annot_str = '[%s]' % ann.replace(separator, ' ')
|
||||||
|
return '\t'.join((color, name, lists.format_evr(bp),
|
||||||
|
lists.format_evr(np), annot_str, tasks_str))
|
||||||
return '\t'.join((color, name, lists.format_evr(bp),
|
return '\t'.join((color, name, lists.format_evr(bp),
|
||||||
lists.format_evr(np), tasks_str))
|
lists.format_evr(np), tasks_str))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user