Make sure NONE packages are properly colorized
Previously, BY_NAME did not include packages that were absent from both repositories. This meant that some functions like `gspi` ignored them, which is inconvenient because it does not show packages that were never built (like new kernel flavors) or already deleted. This commit addresses this in the following way: - colorize.colorize() now takes additional argument, an explicit list of package names to colorize - for interactive console, this list is formed from both repositories, AND all the package names found in PACKAGE_TASKS.
This commit is contained in:
parent
c66361223d
commit
8af9e1d7b1
@ -4,7 +4,7 @@ import collections
|
||||
from port_stats import rpm_ffi
|
||||
|
||||
|
||||
COLORS = ('RED', 'ORANGE', 'YELLOW', 'SLATE', 'GREEN', 'EXTRA')
|
||||
COLORS = ('RED', 'ORANGE', 'YELLOW', 'SLATE', 'GREEN', 'EXTRA', 'NONE')
|
||||
PENDING_COLORS = ('ORANGE', 'YELLOW', 'EXTRA')
|
||||
|
||||
LEGEND = {
|
||||
@ -18,12 +18,12 @@ LEGEND = {
|
||||
|
||||
|
||||
def colorize_pair(base_package, new_package):
|
||||
if base_package == new_package:
|
||||
return 'GREEN'
|
||||
if new_package is None:
|
||||
return 'RED'
|
||||
return 'NONE' if base_package is None else 'RED'
|
||||
if base_package is None:
|
||||
return 'EXTRA'
|
||||
if base_package == new_package:
|
||||
return 'GREEN'
|
||||
|
||||
if base_package.epoch != new_package.epoch:
|
||||
return 'ORANGE'
|
||||
@ -36,14 +36,17 @@ def colorize_pair(base_package, new_package):
|
||||
return 'SLATE'
|
||||
|
||||
|
||||
def colorize(base, new):
|
||||
def colorize(base, new, packages=()):
|
||||
b_idx = dict((p.name, p) for p in base)
|
||||
n_idx = dict((p.name, p) for p in new)
|
||||
|
||||
by_name = dict()
|
||||
by_color = collections.defaultdict(list)
|
||||
|
||||
for name in frozenset(b_idx).union(n_idx):
|
||||
if not packages:
|
||||
packages = frozenset(b_idx).union(n_idx)
|
||||
|
||||
for name in packages:
|
||||
bp = b_idx.get(name)
|
||||
np = n_idx.get(name)
|
||||
color = colorize_pair(bp, np)
|
||||
|
@ -123,8 +123,12 @@ def use(repo=None):
|
||||
sys.ps1 = CURRENT['name'] + '>>> '
|
||||
PACKAGE_TASKS = tasks.tasks_by_package(repo_tasks())
|
||||
UPDATE_TIMES = tasks.last_update_times(repo_tasks())
|
||||
packages = (frozenset(PACKAGE_TASKS)
|
||||
.union(p.name for p in REPOS[CURRENT['base']])
|
||||
.union(p.name for p in REPOS[CURRENT['new']]))
|
||||
BY_NAME, BY_COLOR = colorize.colorize(REPOS[CURRENT['base']],
|
||||
REPOS[CURRENT['new']])
|
||||
REPOS[CURRENT['new']],
|
||||
packages)
|
||||
LOG.info("DONE")
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user