[yum-commits] Branch 'yum-3_2_X' - 2 commits - yum/config.py yum/yumRepo.py

skvidal at osuosl.org skvidal at osuosl.org
Thu Nov 12 20:28:14 UTC 2009


 yum/config.py  |   23 +++++++++++++++++++++++
 yum/yumRepo.py |   36 ++++++++++++++++++++++++------------
 2 files changed, 47 insertions(+), 12 deletions(-)

New commits:
commit afe029987156811fb69d620c773e2c9ee9f01c31
Merge: 0088482... 9983a01...
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Thu Nov 12 14:36:12 2009 -0500

    Merge branch 'yum-3_2_X' of ssh://yum.baseurl.org/srv/projects/yum/git/yum into yum-3_2_X
    
    * 'yum-3_2_X' of ssh://yum.baseurl.org/srv/projects/yum/git/yum:
      Trivial has_key() to "in" changes.
      Fix for callers that rely on .pkgSackPackages protecting .pkgSack.get*
      Fix get_running_kernel_version_release
      Fix epoch matching in rpmdb.returnPackages()
      Test the first char of a pattern match, if we can

commit 0088482f6f2ee5dbcbc6a238d4e87f10b3ecbbba
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Thu Nov 12 14:35:30 2009 -0500

    updating yumRepo dump() method and adding YumConf.dump() method
    to output nicer lists of all of our config settings

diff --git a/yum/config.py b/yum/config.py
index 2ae7e89..f2830bc 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -39,6 +39,7 @@ if not _use_iniparse:
     from ConfigParser import ConfigParser
 import rpmUtils.transaction
 import Errors
+import types
 
 # Alter/patch these to change the default checking...
 __pkgs_gpgcheck_default__ = False
@@ -708,6 +709,28 @@ class YumConf(StartupConf):
 
     _reposlist = []
 
+    def dump(self):
+        output = '[main]\n'
+        # we exclude all vars which start with _ or are in this list:
+        excluded_vars = ['cfg', 'uid', 'yumvar', 'progress_obj', 'failure_obj',
+                         'disable_excludes', 'config_file_age', 'config_file_path',
+                         ]
+        for attr in dir(self):
+            if attr.startswith('_'):
+                continue
+            if attr in excluded_vars:
+                continue
+            if isinstance(getattr(self, attr), types.MethodType):
+                continue
+            res = getattr(self, attr)
+            if not res:
+                res = ''
+            if type(res) == types.ListType:
+                res = ', '.join(res)
+            output = output + '%s = %s\n' % (attr, res)
+
+        return output
+
 class RepoConf(BaseConfig):
     '''
     Option definitions for repository INI file sections.
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index b95fd20..debae51 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -366,18 +366,30 @@ class YumRepository(Repository, config.RepoConf):
 
     def dump(self):
         output = '[%s]\n' % self.id
-        vars = ['name', 'bandwidth', 'enabled', 'enablegroups',
-                'gpgcheck', 'repo_gpgcheck', # FIXME: gpgcheck => pkgs_gpgcheck
-                'includepkgs', 'keepalive', 'proxy',
-                'proxy_password', 'proxy_username', 'exclude',
-                'retries', 'throttle', 'timeout', 'mirrorlist', 'metalink',
-                'cachedir', 'gpgkey', 'pkgdir', 'hdrdir']
-        vars.sort()
-        for attr in vars:
-            output = output + '%s = %s\n' % (attr, getattr(self, attr))
-        output = output + 'baseurl ='
-        for url in self.urls:
-            output = output + ' %s\n' % url
+        # we exclude all vars which start with _ or are in this list:
+        excluded_vars = ['mediafunc', 'sack', 'metalink_data', 'grab', 
+                         'grabfunc', 'repoXML', 'cfg', 'retrieved',
+                        'mirrorlistparsed', 'gpg_import_func', 'failure_obj',
+                        'callback', 'confirm_func', 'groups_added', 
+                        'interrupt_callback', 'id', 'mirror_failure_obj',
+                        'repo_config_age', 'groupsfilename', 'copy_local', 
+                        'basecachedir', 'http_headers', 'metadata_cookie',
+                        'metadata_cookie_fn', 'quick_enable_disable',
+                        'repoMDFile', 'timestamp_check', 'urls', 'mirrorurls',
+                        'yumvar', 'repofile']
+        for attr in dir(self):
+            if attr.startswith('_'):
+                continue
+            if attr in excluded_vars:
+                continue
+            if isinstance(getattr(self, attr), types.MethodType):
+                continue
+            res = getattr(self, attr)
+            if not res:
+                res = ''
+            if type(res) == types.ListType:
+                res = ', '.join(res)
+            output = output + '%s = %s\n' % (attr, res)
 
         return output
 


More information about the Yum-commits mailing list