[yum-cvs] 3 commits - cli.py docs/yum.8 output.py yum/__init__.py yum/packages.py
Seth Vidal
skvidal at linux.duke.edu
Mon Oct 29 13:53:12 UTC 2007
cli.py | 12 +++
docs/yum.8 | 11 +++
output.py | 172 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
yum/__init__.py | 7 ++
yum/packages.py | 3
5 files changed, 200 insertions(+), 5 deletions(-)
New commits:
commit 8bf2dd3fe55b73397b8cb3d45b1dfaee58be52ef
Author: Seth Vidal <skvidal at fedoraproject.org>
Date: Mon Oct 29 09:48:29 2007 -0400
docs for --disableexcludes
diff --git a/docs/yum.8 b/docs/yum.8
index f329a83..af0903f 100644
--- a/docs/yum.8
+++ b/docs/yum.8
@@ -204,8 +204,17 @@ processing logic. For more information see the \fBupdate\fP command above.
Configuration Option: \fBobsoletes\fP
.IP "\fB\-\-exclude=package\fP"
Exclude a specific package by name or glob from updates on all repositories.
-.br
Configuration Option: \fBexclude\fP
+.br
+.IP "\fB\-\-disableexcludes=[all|main|repoid]\fP"
+Disable the excludes defined in your config files. Takes one of three options:
+.br
+all == disable all excludes
+.br
+main == disable excludes defined in [main] in yum.conf
+.br
+repoid == disable excludes defined for that repo
+.br
.IP "\fB\-\-noplugins\fP"
Run with all plugins disabled.
.br
commit 38fbc258ff224f574f440b19257b3ebb5245ebbc
Author: Seth Vidal <skvidal at fedoraproject.org>
Date: Mon Oct 29 09:43:10 2007 -0400
apply patches from jantill:
- make search terms bold in cli output
- remove \n's from summary lines in packages
diff --git a/cli.py b/cli.py
index b3dbbc1..df85285 100644
--- a/cli.py
+++ b/cli.py
@@ -849,7 +849,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
total = 0
for (po, matched_value) in matching:
- self.matchcallback(po, matched_value)
+ self.matchcallback(po, matched_value, args)
total += 1
if total == 0:
diff --git a/output.py b/output.py
index ad4cfd0..ea81af2 100644
--- a/output.py
+++ b/output.py
@@ -25,6 +25,8 @@ import gettext
import rpm
from i18n import _
+import re # For YumTerm
+
from urlgrabber.progress import TextMeter
from urlgrabber.grabber import URLGrabError
from yum.misc import sortPkgObj, prco_tuple_to_string
@@ -39,6 +41,167 @@ class YumTextMeter(TextMeter):
checkSignals()
TextMeter.update(self, amount_read, now)
+class YumTerm:
+ """some terminal "UI" helpers based on curses"""
+
+ # From initial search for "terminfo and python" got:
+ # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/475116
+ # ...it's probably not copyrightable, but if so ASPN says:
+ #
+ # Except where otherwise noted, recipes in the Python Cookbook are
+ # published under the Python license.
+
+ __enabled = True
+
+ columns = 80
+ lines = 24
+ # Output modes:
+ MODE = {
+ 'bold' : '',
+ 'blink' : '',
+ 'dim' : '',
+ 'reverse' : '',
+ 'underline' : '',
+ 'normal' : ''
+ }
+
+ # Colours
+ FG_COLOR = {
+ 'black' : '',
+ 'blue' : '',
+ 'green' : '',
+ 'cyan' : '',
+ 'red' : '',
+ 'magenta' : '',
+ 'yellow' : '',
+ 'white' : ''
+ }
+
+ BG_COLOR = {
+ 'black' : '',
+ 'blue' : '',
+ 'green' : '',
+ 'cyan' : '',
+ 'red' : '',
+ 'magenta' : '',
+ 'yellow' : '',
+ 'white' : ''
+ }
+
+ __cap_names = {
+ 'underline' : 'smul',
+ 'reverse' : 'rev',
+ 'normal' : 'sgr0',
+ }
+
+ __colors = {
+ 'black' : 0,
+ 'blue' : 1,
+ 'green' : 2,
+ 'cyan' : 3,
+ 'red' : 4,
+ 'magenta' : 5,
+ 'yellow' : 6,
+ 'white' : 7
+ }
+ __ansi_colors = {
+ 'black' : 0,
+ 'red' : 1,
+ 'green' : 2,
+ 'yellow' : 3,
+ 'blue' : 4,
+ 'magenta' : 5,
+ 'cyan' : 6,
+ 'white' : 7
+ }
+
+ def __init__(self, term_stream=None):
+ # Curses isn't available on all platforms
+ try:
+ import curses
+ except:
+ self.__enabled = False
+ return
+
+ # If the stream isn't a tty, then assume it has no capabilities.
+ if not term_stream:
+ term_stream = sys.stdout
+ if not term_stream.isatty():
+ self.__enabled = False
+ return
+
+ # Check the terminal type. If we fail, then assume that the
+ # terminal has no capabilities.
+ try:
+ curses.setupterm(fd=term_stream.fileno())
+ except:
+ self.__enabled = False
+ return
+ self._ctigetstr = curses.tigetstr
+
+ self.columns = curses.tigetnum('cols')
+ self.lines = curses.tigetnum('lines')
+
+ # Look up string capabilities.
+ for cap_name in self.MODE.keys():
+ mode = cap_name
+ if cap_name in self.__cap_names:
+ cap_name = self.__cap_names[cap_name]
+ self.MODE[mode] = self._tigetstr(cap_name) or ''
+
+ # Colors
+ set_fg = self._tigetstr('setf')
+ if set_fg:
+ for (color, val) in self.__colors.items():
+ self.FG_COLOR[color] = curses.tparm(set_fg, val) or ''
+ set_fg_ansi = self._tigetstr('setaf')
+ if set_fg_ansi:
+ for (color, val) in self.__ansi_colors.items():
+ self.FG_COLOR[color] = curses.tparm(set_fg_ansi, val) or ''
+ set_bg = self._tigetstr('setb')
+ if set_bg:
+ for (color, val) in self.__colors.items():
+ self.BG_COLOR[color] = curses.tparm(set_bg, val) or ''
+ set_bg_ansi = self._tigetstr('setab')
+ if set_bg_ansi:
+ for (color, val) in self.__ansi_colors.items():
+ self.BG_COLOR[color] = curses.tparm(set_bg_ansi, val) or ''
+
+ def _tigetstr(self, cap_name):
+ # String capabilities can include "delays" of the form "$<2>".
+ # For any modern terminal, we should be able to just ignore
+ # these, so strip them out.
+ cap = self._ctigetstr(cap_name) or ''
+ return re.sub(r'\$<\d+>[/*]?', '', cap)
+
+ def sub(self, haystack, beg, end, needles, escape=None):
+ if not self.__enabled:
+ return haystack
+
+ if not escape:
+ escape = re.escape
+
+ render = lambda match: beg + match.group() + end
+ for needle in needles:
+ haystack = re.sub(escape(needle), render, haystack)
+ return haystack
+ def sub_norm(self, haystack, beg, needles, **kwds):
+ return self.sub(haystack, beg, self.MODE['normal'], needles, **kwds)
+
+ def sub_mode(self, haystack, mode, needles, **kwds):
+ return self.sub_norm(haystack, self.MODE[mode], needles, **kwds)
+
+ def sub_bold(self, haystack, needles, **kwds):
+ return self.sub_mode(haystack, 'bold', needles)
+
+ def sub_fg(self, haystack, color, needles, **kwds):
+ return self.sub_norm(haystack, self.FG_COLOR[color], needles, **kwds)
+
+ def sub_bg(self, haystack, color, needles, **kwds):
+ return self.sub_norm(haystack, self.BG_COLOR[color], needles, **kwds)
+
+
+
class YumOutput:
def __init__(self):
@@ -48,6 +211,8 @@ class YumOutput:
self.i18ndomains = rpm.expandMacro("%_i18ndomains").split(":")
else:
self.i18ndomains = ["redhat-dist"]
+
+ self.term = YumTerm()
def printtime(self):
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
@@ -239,11 +404,16 @@ class YumOutput:
return(format % (number, space, symbols[depth]))
- def matchcallback(self, po, values):
+ def matchcallback(self, po, values, matchfor=None):
msg = '%s.%s : %s' % (po.name, po.arch, po.summary)
+ if matchfor:
+ msg = self.term.sub_bold(msg, matchfor)
+
self.verbose_logger.log(logginglevels.INFO_2, msg)
self.verbose_logger.debug('Matched from:')
for item in values:
+ if matchfor:
+ item = self.term.sub_bold(item, matchfor)
self.verbose_logger.debug('%s', item)
self.verbose_logger.debug('\n\n')
diff --git a/yum/packages.py b/yum/packages.py
index 6089730..fb7d1b7 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -569,6 +569,7 @@ class YumAvailablePackage(PackageObject, RpmBase):
for item in ['summary', 'description', 'packager', 'group',
'buildhost', 'sourcerpm', 'url', 'vendor']:
setattr(self, item, pkgdict.info[item])
+ self.summary = self.summary.replace('\n', '')
self.licenses.append(pkgdict.info['license'])
@@ -626,7 +627,7 @@ class YumHeaderPackage(YumAvailablePackage):
self.release = self.hdr['release']
self.ver = self.version
self.rel = self.release
- self.summary = self.hdr['summary']
+ self.summary = self.hdr['summary'].replace('\n', '')
self.description = self.hdr['description']
self.pkgid = self.hdr[rpm.RPMTAG_SHA1HEADER]
if not self.pkgid:
commit 246140eb470a77e77884df03e92a61c022f8fb78
Author: Seth Vidal <skvidal at fedoraproject.org>
Date: Mon Oct 29 09:40:53 2007 -0400
apply --disableexcludes option patch from jantill
diff --git a/cli.py b/cli.py
index d6469c2..b3dbbc1 100644
--- a/cli.py
+++ b/cli.py
@@ -1179,7 +1179,12 @@ class YumOptionParser(OptionParser):
if opts.installroot:
self.base.conf.installroot = opts.installroot
-
+
+ if opts.disableexcludes:
+ self.base.conf.disable_excludes = opts.disableexcludes
+ else:
+ self.base.conf.disable_excludes = []
+
for exclude in opts.exclude:
try:
excludelist = self.base.conf.exclude
@@ -1282,6 +1287,9 @@ class YumOptionParser(OptionParser):
metavar='[repo]')
self.add_option("-x", "--exclude", default=[], action="append",
help="exclude package(s) by name or glob", metavar='[package]')
+ self.add_option("", "--disableexcludes", default=[], action="append",
+ help="disable exclude from main, for a repo or for everything",
+ metavar='[repo]')
self.add_option("--obsoletes", action="store_true",
help="enable obsoletes processing during updates")
self.add_option("--noplugins", action="store_true",
diff --git a/yum/__init__.py b/yum/__init__.py
index fe11ff1..4a202df 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -648,14 +648,21 @@ class YumBase(depsolve.Depsolve):
"""removes packages from packageSacks based on global exclude lists,
command line excludes and per-repository excludes, takes optional
repo object to use."""
+
+ if "all" in self.conf.disable_excludes:
+ return
# if not repo: then assume global excludes, only
# if repo: then do only that repos' packages and excludes
if not repo: # global only
+ if "main" in self.conf.disable_excludes:
+ return
excludelist = self.conf.exclude
repoid = None
else:
+ if repo.id in self.conf.disable_excludes:
+ return
excludelist = repo.getExcludePkgList()
repoid = repo.id
More information about the Yum-cvs-commits
mailing list