[Yum-devel] [PATCH 1/2] Combine the code for "requires dep. problems". Make it nicer/easier to read.
Tim Lauridsen
tim.lauridsen at googlemail.com
Thu Jan 14 06:18:16 UTC 2010
On Wed, Jan 13, 2010 at 5:32 PM, James Antill <james at and.org> wrote:
> ---
> yum/depsolve.py | 25 +++++++++++++++----------
> yummain.py | 6 ++++--
> 2 files changed, 19 insertions(+), 12 deletions(-)
>
> diff --git a/yum/depsolve.py b/yum/depsolve.py
> index a09bd4b..89b32c6 100644
> --- a/yum/depsolve.py
> +++ b/yum/depsolve.py
> @@ -308,6 +308,17 @@ class Depsolve(object):
> def _prco_req2req(self, req):
> return self._prco_req_nfv2req(req[0], req[1], req[2])
>
> + def _err_missing_requires(self, reqPo, reqTup):
> + """ Create a message for errorlist. """
> + needname, needflags, needversion = reqTup
> +
> + prob_pkg = "%s (%s)" % (reqPo, reqPo.ui_from_repo)
> + msg = _('Package: %s') % (prob_pkg,)
> + ui_req = rpmUtils.miscutils.formatRequire(needname, needversion,
> + needflags)
> + msg += _('\n Requires: %s') % (ui_req,)
> + return msg
> +
> def _requiringFromInstalled(self, requiringPo, requirement, errorlist):
> """processes the dependency resolution for a dep where the
> requiring
> package is installed"""
> @@ -414,9 +425,7 @@ class Depsolve(object):
> if self.pkgSack is None:
> return self._requiringFromTransaction(requiringPo,
> requirement, errorlist)
> else:
> - prob_pkg = "%s (%s)" % (requiringPo,requiringPo.repoid)
> - msg = _('Unresolvable requirement %s for %s') %
> (niceformatneed,
> - prob_pkg)
> + msg = self._err_missing_requires(requiringPo, requirement)
> self.verbose_logger.log(logginglevels.DEBUG_2, msg)
> checkdeps = 0
> missingdep = 1
> @@ -514,10 +523,7 @@ class Depsolve(object):
>
> if len(provSack) == 0: # unresolveable
> missingdep = 1
> - prob_pkg = "%s (%s)" % (requiringPo,requiringPo.repoid)
> - msg = _('Missing Dependency: %s is needed by package %s') % \
> - (rpmUtils.miscutils.formatRequire(needname, needversion,
> needflags),
> -
> prob_pkg)
> + msg = self._err_missing_requires(requiringPo, requirement)
> errorlist.append(msg)
> return checkdeps, missingdep
>
> @@ -560,8 +566,7 @@ class Depsolve(object):
> if self.rpmdb.contains(po=best): # is it already installed?
> missingdep = 1
> checkdeps = 0
> - prob_pkg = "%s (%s)" % (requiringPo,requiringPo.repoid)
> - msg = _('Missing Dependency: %s is needed by package %s') %
> (needname, prob_pkg)
> + msg = self._err_missing_requires(requiringPo, requirement)
> errorlist.append(msg)
> return checkdeps, missingdep
>
> @@ -760,7 +765,7 @@ class Depsolve(object):
> errors = unique(errors)
> for po,wpo,err in self.po_with_problems:
> self.verbose_logger.info(_("%s from %s has depsolving
> problems") % (po,po.repoid))
> - self.verbose_logger.info(" --> %s" % (err))
> + self.verbose_logger.info(" --> %s" % (err.replace('\n',
> '\n --> ')))
> return (1, errors)
>
> if len(self.tsInfo) > 0:
> diff --git a/yummain.py b/yummain.py
> index e8dd43c..305e0c7 100755
> --- a/yummain.py
> +++ b/yummain.py
> @@ -28,7 +28,7 @@ from yum import Errors
> from yum import plugins
> from yum import logginglevels
> from yum import _
> -from yum.i18n import to_unicode
> +from yum.i18n import to_unicode, utf8_width
> import yum.misc
> import cli
> from utils import suppress_keyboard_interrupt_message, show_lock_owner
> @@ -166,7 +166,9 @@ def main(args):
> elif result == 1:
> # Fatal error
> for msg in resultmsgs:
> - logger.critical(_('Error: %s'), msg)
> + prefix = _('Error: %s')
> + prefix2nd = (' ' * (utf8_width(prefix) - 2))
> + logger.critical(prefix, msg.replace('\n', '\n' + prefix2nd))
> if not base.conf.skip_broken:
> verbose_logger.info(_(" You could try using --skip-broken to
> work around the problem"))
> if not base._rpmdb_warn_checks(out=verbose_logger.info,
> warn=False):
> --
> 1.6.5.2
>
> _______________________________________________
> Yum-devel mailing list
> Yum-devel at lists.baseurl.org
> http://lists.baseurl.org/mailman/listinfo/yum-devel
>
ACK
Tim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.baseurl.org/pipermail/yum-devel/attachments/20100114/ebaaba24/attachment.htm>
More information about the Yum-devel
mailing list