[yum-commits] Branch 'yum-3_2_X' - 4 commits - cli.py output.py yum/__init__.py yumcommands.py
James Antill
james at osuosl.org
Thu Nov 20 06:10:52 UTC 2008
cli.py | 11 +++++++++++
output.py | 42 ++++++++++++++++++++++++++++++++++--------
yum/__init__.py | 27 ++++++++++++++++++++++-----
yumcommands.py | 25 +++++++++++++++++++++----
4 files changed, 88 insertions(+), 17 deletions(-)
New commits:
commit bc04865e5f6534a2bbbdcf5887dcfd5520e5d6db
Author: James Antill <james at and.org>
Date: Thu Nov 20 01:03:54 2008 -0500
Add sections for entering/leaving rpm code
diff --git a/cli.py b/cli.py
index fbbbb59..13a2bfa 100644
--- a/cli.py
+++ b/cli.py
@@ -398,6 +398,8 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
if self.gpgsigcheck(downloadpkgs) != 0:
return 1
+ self.verbose_logger.log(yum.logginglevels.INFO_2,
+ self.fmtSection(_("Entering rpm code")))
if self.conf.rpm_check_debug:
rcd_st = time.time()
self.verbose_logger.log(yum.logginglevels.INFO_2,
@@ -464,6 +466,8 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
resultobject = self.runTransaction(cb=cb)
self.verbose_logger.debug('Transaction time: %0.3f' % (time.time() - ts_st))
+ self.verbose_logger.log(yum.logginglevels.INFO_2,
+ self.fmtSection(_("Leaving rpm code")))
# close things
self.verbose_logger.log(yum.logginglevels.INFO_1,
self.postTransactionOutput())
commit 985c528fb388f2aead376e63ed07d840b76f90b7
Author: James Antill <james at and.org>
Date: Thu Nov 20 01:03:40 2008 -0500
Use utf8_width for fmtSection
diff --git a/output.py b/output.py
index 6bc9df1..d2c2ec5 100755
--- a/output.py
+++ b/output.py
@@ -431,7 +431,7 @@ class YumOutput:
def fmtSection(self, name, fill='='):
name = to_str(name)
cols = self.term.columns - 2
- name_len = len(name)
+ name_len = utf8_width(name)
if name_len >= (cols - 4):
beg = end = fill * 2
else:
commit c9778fd48e18e316c74832941233dc4781ebeb8f
Author: James Antill <james at and.org>
Date: Thu Nov 20 00:57:44 2008 -0500
Allow _highlight() to do colour and other modes.
Extra whizbang highlighting:
. Show installed "extra" packages in bold red.
. Show installed "newer than available" packages in bold yellow.
. Show installed "update available" packages in bold.
. Show available "old" packages in dim cyan.
. Show available "newest" packages in bold blue.
...it's still mostly blank, and all seem to be visible when they are used,
on white and black backgrounds.
Do highlighting for "list available".
diff --git a/cli.py b/cli.py
index e3e77d7..fbbbb59 100644
--- a/cli.py
+++ b/cli.py
@@ -677,10 +677,14 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
pkgnarrow = 'all'
done_hidden_available = False
+ done_hidden_installed = False
if len(extcmds) > 0:
if installed_available and extcmds[0] == 'installed':
done_hidden_available = True
extcmds.pop(0)
+ elif installed_available and extcmds[0] == 'available':
+ done_hidden_installed = True
+ extcmds.pop(0)
elif extcmds[0] in special:
pkgnarrow = extcmds.pop(0)
@@ -709,8 +713,11 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
if installed_available:
ypl.hidden_available = ypl.available
+ ypl.hidden_installed = ypl.installed
if done_hidden_available:
ypl.available = []
+ if done_hidden_installed:
+ ypl.installed = []
return ypl
def search(self, args):
diff --git a/output.py b/output.py
index cc7a585..6bc9df1 100755
--- a/output.py
+++ b/output.py
@@ -264,12 +264,31 @@ class YumOutput:
progressbar(current, total, name)
def _highlight(self, highlight):
- if highlight:
+ hibeg = ''
+ hiend = ''
+ if not highlight:
+ pass
+ elif not isinstance(highlight, basestring) or highlight == 'bold':
hibeg = self.term.MODE['bold']
- hiend = self.term.MODE['normal']
else:
- hibeg = ''
- hiend = ''
+ # Turn a string into a specific output: colour, bold, etc.
+ for high in highlight.replace(',', ' ').split():
+ if False: pass
+ elif high == 'normal':
+ hibeg = ''
+ elif high in self.term.MODE:
+ hibeg += self.term.MODE[high]
+ elif high in self.term.FG_COLOR:
+ hibeg += self.term.FG_COLOR[high]
+ elif (high.startswith('fg:') and
+ high[3:] in self.term.FG_COLOR):
+ hibeg += self.term.FG_COLOR[high[3:]]
+ elif (high.startswith('bg:') and
+ high[3:] in self.term.BG_COLOR):
+ hibeg += self.term.BG_COLOR[high[3:]]
+
+ if hibeg:
+ hiend = self.term.MODE['normal']
return (hibeg, hiend)
@staticmethod
@@ -476,7 +495,7 @@ class YumOutput:
print '%-35.35s [%.12s] %.10s %-20.20s' % (c_compact, c_repo, changetype, i_compact)
def listPkgs(self, lst, description, outputType, highlight_na={},
- columns=None):
+ columns=None, highlight_modes={}):
"""outputs based on whatever outputType is. Current options:
'list' - simple pkg list
'info' - similar to rpm -qi output
@@ -491,8 +510,15 @@ class YumOutput:
for pkg in sorted(lst):
key = (pkg.name, pkg.arch)
highlight = False
- if key in highlight_na and pkg.verLT(highlight_na[key]):
- highlight = True
+ if False: pass
+ elif key not in highlight_na:
+ highlight = highlight_modes.get('not in', 'normal')
+ elif pkg.verEQ(highlight_na[key]):
+ highlight = highlight_modes.get('=', 'normal')
+ elif pkg.verLT(highlight_na[key]):
+ highlight = highlight_modes.get('>', 'bold')
+ else:
+ highlight = highlight_modes.get('<', 'normal')
if outputType == 'list':
self.simpleList(pkg, ui_overflow=True,
diff --git a/yumcommands.py b/yumcommands.py
index bc86088..cc6b387 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -244,6 +244,7 @@ class InfoCommand(YumCommand):
return 1, [str(e)]
else:
update_pkgs = {}
+ inst_pkgs = {}
columns = None
if basecmd == 'list':
@@ -253,17 +254,33 @@ class InfoCommand(YumCommand):
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.hidden_available:
+ # available to update, an extra, or newer than what we have.
+ for pkg in (ypl.hidden_available +
+ ypl.reinstall_available +
+ ypl.old_available):
key = (pkg.name, pkg.arch)
if key not in update_pkgs or pkg.verGT(update_pkgs[key]):
update_pkgs[key] = pkg
+ if highlight and ypl.available:
+ # If we have installed and available lists, then do the
+ # highlighting for the available packages so you can see what's
+ # available to install vs. update vs. old.
+ for pkg in ypl.hidden_installed:
+ key = (pkg.name, pkg.arch)
+ if key not in inst_pkgs or pkg.verGT(inst_pkgs[key]):
+ inst_pkgs[key] = pkg
+
# Output the packages:
rip = base.listPkgs(ypl.installed, _('Installed Packages'), basecmd,
- highlight_na=update_pkgs, columns=columns)
+ highlight_na=update_pkgs, columns=columns,
+ highlight_modes={'>' : 'bold',
+ '<' : 'bold,yellow',
+ 'not in' : 'red,bold'})
rap = base.listPkgs(ypl.available, _('Available Packages'), basecmd,
- columns=columns)
+ highlight_na=inst_pkgs, columns=columns,
+ highlight_modes={'<' : 'bold,blue',
+ '>' : 'cyan,dim'})
rep = base.listPkgs(ypl.extras, _('Extra Packages'), basecmd,
columns=columns)
rup = base.listPkgs(ypl.updates, _('Updated Packages'), basecmd,
commit 7faf7dcbd090e13b96841a0346ff9eabc24743a2
Author: James Antill <james at and.org>
Date: Thu Nov 20 00:55:26 2008 -0500
Add reinstall_available and old_available do doPkgLists
diff --git a/yum/__init__.py b/yum/__init__.py
index 6bbae16..1f03840 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1501,6 +1501,8 @@ class YumBase(depsolve.Depsolve):
installed = []
available = []
+ reinstall_available = []
+ old_available = []
updates = []
obsoletes = []
obsoletesTuples = []
@@ -1526,7 +1528,6 @@ class YumBase(depsolve.Depsolve):
avail = self.pkgSack.returnPackages(patterns=patterns,
ignore_case=ic)
else:
- del dinst # Using ndinst instead
try:
avail = self.pkgSack.returnNewestByNameArch(patterns=patterns,
ignore_case=ic)
@@ -1535,12 +1536,18 @@ class YumBase(depsolve.Depsolve):
for pkg in avail:
if showdups:
- if pkg.pkgtup not in dinst:
+ if pkg.pkgtup in dinst:
+ reinstall_available.append(pkg)
+ else:
available.append(pkg)
else:
key = (pkg.name, pkg.arch)
- if key not in ndinst or pkg.verGT(ndinst[key]):
+ if pkg.pkgtup in dinst:
+ reinstall_available.append(pkg)
+ elif key not in ndinst or pkg.verGT(ndinst[key]):
available.append(pkg)
+ else:
+ old_available.append(pkg)
# produce the updates list of tuples
elif pkgnarrow == 'updates':
@@ -1578,12 +1585,20 @@ class YumBase(depsolve.Depsolve):
for pkg in avail:
if showdups:
- if not self.rpmdb.contains(po=pkg):
+ if self.rpmdb.contains(po=pkg):
+ reinstall_available.append(pkg)
+ else:
available.append(pkg)
else:
ipkgs = self.rpmdb.searchNevra(pkg.name, arch=pkg.arch)
- if not ipkgs or pkg.verGT(sorted(ipkgs, reverse=True)[0]):
+ if ipkgs:
+ latest = sorted(ipkgs, reverse=True)[0]
+ if not ipkgs or pkg.verGT(latest):
available.append(pkg)
+ elif pkg.verEQ(latest):
+ reinstall_available.append(pkg)
+ else:
+ old_available.append(pkg)
# not in a repo but installed
elif pkgnarrow == 'extras':
@@ -1639,6 +1654,8 @@ class YumBase(depsolve.Depsolve):
ygh.installed = installed
ygh.available = available
+ ygh.reinstall_available = reinstall_available
+ ygh.old_available = old_available
ygh.updates = updates
ygh.obsoletes = obsoletes
ygh.obsoletesTuples = obsoletesTuples
More information about the Yum-commits
mailing list