[yum-commits] Branch 'yum-3_2_X' - 3 commits - cli.py output.py yumcommands.py
James Antill
james at osuosl.org
Wed Nov 19 00:03:11 UTC 2008
cli.py | 16 ++++++++++--
output.py | 1
yumcommands.py | 73 +++++++++++++++++++++++++++++++++++++++------------------
3 files changed, 66 insertions(+), 24 deletions(-)
New commits:
commit 12c70cbc6080f1a8a05b0b7c380424991359ffe0
Author: James Antill <james at and.org>
Date: Tue Nov 18 16:18:48 2008 -0500
Do dynamic repolist columns, always output the id and num, chop name
diff --git a/yumcommands.py b/yumcommands.py
index 77f550b..bc86088 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -738,7 +738,6 @@ class RepoListCommand(YumCommand):
repos = base.repos.repos.values()
repos.sort()
enabled_repos = base.repos.listEnabled()
- done = False
verbose = base.verbose_logger.isEnabledFor(logginglevels.DEBUG_3)
if arg == 'all':
ehibeg = base.term.FG_COLOR['green'] + base.term.MODE['bold']
@@ -749,43 +748,31 @@ class RepoListCommand(YumCommand):
dhibeg = ''
hiend = ''
tot_num = 0
+ cols = []
for repo in repos:
if len(extcmds) and not _repo_match(repo, extcmds):
continue
if repo in enabled_repos:
enabled = True
- ui_enabled = ehibeg + _('enabled') + hiend
+ ui_enabled = ehibeg + _('enabled') + hiend + ": "
+ ui_endis_wid = utf8_width(_('enabled')) + 2
num = len(repo.sack)
tot_num += num
ui_num = to_unicode(locale.format("%d", num, True))
- ui_fmt_num = ": %7s"
if verbose:
ui_size = _repo_size(repo)
else:
enabled = False
ui_enabled = dhibeg + _('disabled') + hiend
+ ui_endis_wid = utf8_width(_('disabled'))
ui_num = ""
- ui_fmt_num = "%s"
- ui_endis_wid = utf8_width(_('disabled'))
- if ui_endis_wid < utf8_width(_('enabled')):
- ui_endis_wid = utf8_width(_('enabled'))
if (arg == 'all' or
(arg == 'enabled' and enabled) or
(arg == 'disabled' and not enabled)):
if not verbose:
- if not done:
- txt_rid = utf8_width_fill(_('repo id'), 20, 20)
- txt_rnam = utf8_width_fill(_('repo name'), 40, 40)
- base.verbose_logger.log(logginglevels.INFO_2,"%s %s %s",
- txt_rid, txt_rnam, _('status'))
- done = True
- base.verbose_logger.log(logginglevels.INFO_2, "%s %s %s%s",
- utf8_width_fill(str(repo), 20, 20),
- utf8_width_fill(repo.name, 40, 40),
- utf8_width_fill(ui_enabled,
- ui_endis_wid),
- ui_fmt_num % ui_num)
+ cols.append((str(repo), repo.name,
+ (ui_enabled, ui_endis_wid), ui_num))
else:
md = repo.repoXML
out = [base.fmtKeyValFill(_("Repo-id : "), repo),
@@ -839,6 +826,47 @@ class RepoListCommand(YumCommand):
"%s\n",
"\n".join(out))
+ if not verbose and cols:
+ # Work out the first (id) and last (enabled/disalbed/count),
+ # then chop the middle (name)...
+ id_len = utf8_width(_('repo id'))
+ nm_len = 0
+ ct_len = 0
+ ui_len = 0
+
+ for (rid, rname, (ui_enabled, ui_endis_wid), ui_num) in cols:
+ if id_len < utf8_width(rid):
+ id_len = utf8_width(rid)
+ if nm_len < utf8_width(rname):
+ nm_len = utf8_width(rname)
+ if ct_len < ui_endis_wid:
+ ct_len = ui_endis_wid
+ if ui_len < len(ui_num):
+ ui_len = len(ui_num)
+ if utf8_width(_('status')) > ct_len + ui_len:
+ left = base.term.columns - (id_len + utf8_width(_('status')) +2)
+ else:
+ left = base.term.columns - (id_len + ct_len + ui_len + 2)
+
+ if left < nm_len: # Name gets chopped
+ nm_len = left
+ else: # Share the extra...
+ left -= nm_len
+ id_len += left / 2
+ nm_len += left - (left / 2)
+
+ txt_rid = utf8_width_fill(_('repo id'), id_len)
+ txt_rnam = utf8_width_fill(_('repo name'), nm_len, nm_len)
+ base.verbose_logger.log(logginglevels.INFO_2,"%s %s %s",
+ txt_rid, txt_rnam, _('status'))
+ for (rid, rname, (ui_enabled, ui_endis_wid), ui_num) in cols:
+ if ui_num:
+ ui_num = utf8_width_fill(ui_num, ui_len, left=False)
+ base.verbose_logger.log(logginglevels.INFO_2, "%s %s %s%s",
+ utf8_width_fill(rid, id_len),
+ utf8_width_fill(rname, nm_len, nm_len),
+ ui_enabled, ui_num)
+
return 0, ['repolist: ' +to_unicode(locale.format("%d", tot_num, True))]
def needTs(self, base, basecmd, extcmds):
commit c49b794a6fe6384b05b14d7bf31a214bf5142334
Author: James Antill <james at and.org>
Date: Tue Nov 18 15:55:01 2008 -0500
Add repo back into search -v
diff --git a/output.py b/output.py
index 5191b9b..cc7a585 100755
--- a/output.py
+++ b/output.py
@@ -711,6 +711,7 @@ class YumOutput:
if not verbose:
return
+ print _("Repo : %s") % po.repoid
print _('Matched from:')
for item in yum.misc.unique(values):
if po.name == item or po.summary == item:
commit 58832271b5fbb15a42770bac6875ce8f46595de0
Author: James Antill <james at and.org>
Date: Tue Nov 18 11:05:26 2008 -0500
Do the update pkg highlighting for "yum list install", turn off when no bold
diff --git a/cli.py b/cli.py
index 9a93d15..e3e77d7 100644
--- a/cli.py
+++ b/cli.py
@@ -657,7 +657,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
return 2, [_('Package(s) to install')]
return 0, [_('Nothing to do')]
- def returnPkgLists(self, extcmds):
+ def returnPkgLists(self, extcmds, installed_available=False):
"""Returns packages lists based on arguments on the cli.returns a
GenericHolder instance with the following lists defined:
available = list of packageObjects
@@ -666,14 +666,22 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
extras = list of packageObjects
obsoletes = tuples of packageObjects (obsoleting, installed)
recent = list of packageObjects
+
+ installed_available = that the available package list is present
+ as .hidden_available when doing any of:
+ all/available/installed
"""
special = ['available', 'installed', 'all', 'extras', 'updates', 'recent',
'obsoletes']
pkgnarrow = 'all'
+ done_hidden_available = False
if len(extcmds) > 0:
- if extcmds[0] in special:
+ if installed_available and extcmds[0] == 'installed':
+ done_hidden_available = True
+ extcmds.pop(0)
+ elif extcmds[0] in special:
pkgnarrow = extcmds.pop(0)
ypl = self.doPackageLists(pkgnarrow=pkgnarrow, patterns=extcmds,
@@ -699,6 +707,10 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
ypl.extras = _shrinklist(ypl.extras, extcmds)
ypl.obsoletes = _shrinklist(ypl.obsoletes, extcmds)
+ if installed_available:
+ ypl.hidden_available = ypl.available
+ if done_hidden_available:
+ ypl.available = []
return ypl
def search(self, args):
diff --git a/yumcommands.py b/yumcommands.py
index 6766593..77f550b 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -238,7 +238,8 @@ class InfoCommand(YumCommand):
def doCommand(self, base, basecmd, extcmds):
try:
- ypl = base.returnPkgLists(extcmds)
+ highlight = base.term.MODE['bold']
+ ypl = base.returnPkgLists(extcmds, installed_available=highlight)
except yum.Errors.YumBaseError, e:
return 1, [str(e)]
else:
@@ -249,11 +250,11 @@ class InfoCommand(YumCommand):
# Dynamically size the columns
columns = _list_cmd_calc_columns(base, ypl)
- if ypl.installed:
+ if highlight and ypl.installed:
# If we have installed and available lists, then do the
# highlighting for the installed packages so you can see what's
# available to install vs. available to update.
- for pkg in ypl.available:
+ for pkg in ypl.hidden_available:
key = (pkg.name, pkg.arch)
if key not in update_pkgs or pkg.verGT(update_pkgs[key]):
update_pkgs[key] = pkg
More information about the Yum-commits
mailing list