[yum-git] Branch 'yum-3_2_X' - 3 commits - output.py test/check-po-yes-no.py yum/__init__.py

James Antill james at linux.duke.edu
Fri Aug 22 19:44:46 UTC 2008


 output.py               |   41 +++++++++++++++++++++++++++++------------
 test/check-po-yes-no.py |    6 +++++-
 yum/__init__.py         |    2 +-
 3 files changed, 35 insertions(+), 14 deletions(-)

New commits:
commit 6ef73192a36267a933b36a07f076d4a1433e1e58
Author: James Antill <james at and.org>
Date:   Fri Aug 22 15:44:19 2008 -0400

    Add fmtColumns(), just move of code from listTransaction so we can reuse

diff --git a/output.py b/output.py
index 99e09e9..35ed361 100644
--- a/output.py
+++ b/output.py
@@ -255,6 +255,30 @@ class YumOutput:
             hiend = ''
         return (hibeg, hiend)
 
+    def fmtColumns(self, columns, msg=u'', end=u''):
+        """ Return a fmt for columns of data, which can overflow."""
+        def _align_width(width):
+            if width < 0:
+                return (u"-", -width)
+            return (u"", width)
+
+        total_width = len(msg)
+        data = []
+        for (val, width) in columns[:-1]:
+            (align, width) = _align_width(width)
+            if len(val) <= width:
+                msg += u"%%%s%ds " % (align, width)
+            else:
+                msg += u"%s\n" + " " * (total_width + width + 1)
+            total_width += width
+            total_width += 1
+            data.append(val)
+        (val, width) = columns[-1]
+        (align, width) = _align_width(width)
+        msg += u"%%%s%ds%s" % (align, width, end)
+        data.append(val)
+        return msg % tuple(data)
+
     def simpleList(self, pkg, ui_overflow=False, indent='', highlight=False):
         (hibeg, hiend) = self._highlight(highlight)
         ver = pkg.printVer()
@@ -647,6 +671,8 @@ class YumOutput:
                     break
                 ret += tup[1]
             return ret
+        # FIXME: This should be a top level function called calcColumns(), or
+        # something. We output a lot of column data.
         def _calc_widths(data, a_wid):
             """ Dynamically calc. the width of the four fields. """
             # Convert the dict to ascending list of tuples, (field_length, pkgs)
@@ -724,18 +750,9 @@ class YumOutput:
             if lines:
                 totalmsg = u"%s:\n" % action
             for (n, a, evr, repoid, size, obsoletes) in lines:
-                total_width = 1
-                msg = u' '
-                for (val, width) in ((n,   n_wid), (a,      a_wid),
-                                     (evr, v_wid), (repoid, r_wid)):
-                    if len(val) <= width:
-                        msg += u"%%-%ds " % width
-                    else:
-                        msg += u"%s\n" + " " * (total_width + width + 1)
-                    total_width += width
-                    total_width += 1
-                msg += u"%5s\n"
-                msg %= (n, a, evr, repoid, size)
+                columns = ((n,   -n_wid), (a,      -a_wid),
+                           (evr, -v_wid), (repoid, -r_wid), (size, 5))
+                msg = self.fmtColumns(columns, u" ", u"\n")
                 for obspo in obsoletes:
                     appended = _('     replacing  %s.%s %s\n\n') % (obspo.name,
                         obspo.arch, obspo.printVer())
commit af735cd50894ce90ff6b2988e1d94367cffc2e02
Author: James Antill <james at and.org>
Date:   Fri Aug 22 13:59:58 2008 -0400

    do to_utf8 for check-po-yes-no error reporting

diff --git a/test/check-po-yes-no.py b/test/check-po-yes-no.py
index 1ed42e2..e22318e 100755
--- a/test/check-po-yes-no.py
+++ b/test/check-po-yes-no.py
@@ -6,6 +6,8 @@
 import sys
 import glob
 
+from yum.misc import to_utf8
+
 def trans(msg, default):
     if msg == 'msgstr ""\n':
         return unicode(default, encoding='utf-8')
@@ -91,7 +93,9 @@ y          %5s: %s
 no         %5s: %s
 n          %5s: %s
 """ % (fname,
-       is_this_ok, sis_this_ok, yes, syes, y, sy, no, sno, n, sn)
+       to_utf8(is_this_ok), to_utf8(sis_this_ok),
+       to_utf8(yes), to_utf8(syes), to_utf8(y), to_utf8(sy),
+       to_utf8(no), to_utf8(sno), to_utf8(n), to_utf8(sn))
     if syes[0] != sy:
         print >>sys.stderr, """\
 ERROR: yes/y translations don't match in: %s
commit 97daa7c37b849feb0cd8388c5149b83688b5af1d
Author: James Antill <james at and.org>
Date:   Fri Aug 22 13:59:34 2008 -0400

    Don't allow an installed repo.

diff --git a/yum/__init__.py b/yum/__init__.py
index 85b9fe9..62b85a3 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -234,7 +234,7 @@ class YumBase(depsolve.Depsolve):
         # Check sections in the .repo file that was just slurped up
         for section in parser.sections():
 
-            if section == 'main':
+            if section in ['main', 'installed']:
                 continue
 
             # Check the repo.id against the valid chars



More information about the Yum-cvs-commits mailing list