[yum-cvs] yum/yum __init__.py, 1.253, 1.254 config.py, 1.99, 1.100 yumRepo.py, 1.22, 1.23

Menno Smits mjs at linux.duke.edu
Thu Sep 14 07:05:28 UTC 2006


Update of /home/groups/yum/cvs/yum/yum
In directory login1.linux.duke.edu:/tmp/cvs-serv22028/yum

Modified Files:
	__init__.py config.py yumRepo.py 
Log Message:
As discussed privately with Paul Nasrat, merged YumRepository and RepoConf to
help allow config dumping.


Index: __init__.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/__init__.py,v
retrieving revision 1.253
retrieving revision 1.254
diff -u -r1.253 -r1.254
--- __init__.py	13 Sep 2006 22:19:57 -0000	1.253
+++ __init__.py	14 Sep 2006 07:05:26 -0000	1.254
@@ -19,7 +19,6 @@
 import os.path
 import rpm
 import re
-import fnmatch
 import types
 import errno
 import time
@@ -28,7 +27,6 @@
 import logging
 import logging.config
 from ConfigParser import ParsingError
-
 import Errors
 import rpmsack
 import rpmUtils.updates
@@ -45,7 +43,7 @@
 import depsolve
 import plugins
 import logginglevels
-
+import yumRepo
 
 from packages import parsePackages, YumAvailablePackage, YumLocalPackage, YumInstalledPackage
 from constants import *
@@ -149,6 +147,8 @@
     def getReposFromConfig(self):
         """read in repositories from config main and .repo files"""
 
+        #FIXME this method could be a simpler
+
         reposlist = []
 
         # Check yum.conf for repositories
@@ -158,7 +158,7 @@
                 continue
 
             try:
-                thisrepo = config.readRepoConfig(self.conf.cfg, section, self.conf)
+                thisrepo = self.readRepoConfig(self.conf.cfg, section)
             except (Errors.RepoError, Errors.ConfigError), e:
                 self.logger.warning(e)
             else:
@@ -183,7 +183,7 @@
         # Check sections in the .repo files that were just slurped up
         for section in parser.sections():
             try:
-                thisrepo = config.readRepoConfig(parser, section, self.conf)
+                thisrepo = self.readRepoConfig(parser, section)
             except (Errors.RepoError, Errors.ConfigError), e:
                 self.logger.warning(e)
             else:
@@ -197,6 +197,29 @@
                 self.logger.warning(e)
                 continue
 
+    def readRepoConfig(self, parser, section):
+        '''Parse an INI file section for a repository.
+
+        @param parser: ConfParser or similar to read INI file values from.
+        @param section: INI file section to read.
+        @return: YumRepository instance.
+        '''
+        repo = yumRepo.YumRepository(section)
+        repo.populate(parser, section, self.conf)
+
+        # Ensure that the repo name is set
+        if not repo.name:
+            repo.name = section
+            self.logger.error('Repository %r is missing name in configuration, '
+                    'using id' % section)
+
+        # Set attributes not from the config file
+        repo.basecachedir = self.conf.cachedir
+        repo.yumvar.update(self.conf.yumvar)
+        repo.cfg = parser
+
+        return repo
+
     def disablePlugins(self):
         '''Disable yum plugins
         '''

Index: config.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/config.py,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -r1.99 -r1.100
--- config.py	15 Jun 2006 09:59:14 -0000	1.99
+++ config.py	14 Sep 2006 07:05:26 -0000	1.100
@@ -20,13 +20,11 @@
 import rpm
 import copy
 import urlparse
-import sys
 from parser import IncludingConfigParser, IncludedDirConfigParser
 from ConfigParser import NoSectionError, NoOptionError
 import rpmUtils.transaction
 import rpmUtils.arch
 import Errors
-from yumRepo import YumRepository
 
 class OptionData(object):
     '''
@@ -628,39 +626,6 @@
 
     return yumconf
 
-def readRepoConfig(parser, section, mainconf):
-    '''Parse an INI file section for a repository.
-
-    @param parser: ConfParser or similar to read INI file values from.
-    @param section: INI file section to read.
-    @param mainconf: ConfParser or similar for yum.conf.
-    @return: Repository instance.
-    '''
-
-    conf = RepoConf()
-    conf.populate(parser, section, mainconf)
-
-    # Ensure that the repo name is set
-    if not conf.name:
-        conf.name = section
-        print >> sys.stderr, \
-            'Repository %r is missing name in configuration, using id' % section
-
-    thisrepo = YumRepository(section)
-
-    # Transfer attributes across
-    #TODO: merge RepoConf and Repository 
-    for k, v in conf.iteritems():
-        if v or not hasattr(thisrepo, k):
-            thisrepo.setAttribute(k, v)
-
-    # Set attributes not from the config file
-    thisrepo.basecachedir = mainconf.cachedir
-    thisrepo.yumvar.update(mainconf.yumvar)
-    thisrepo.cfg = parser
-
-    return thisrepo
-
 def getOption(conf, section, name, option):
     '''Convenience function to retrieve a parsed and converted value from a
     ConfigParser.

Index: yumRepo.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/yumRepo.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- yumRepo.py	11 Sep 2006 21:46:21 -0000	1.22
+++ yumRepo.py	14 Sep 2006 07:05:26 -0000	1.23
@@ -11,10 +11,9 @@
 import repoMDObject
 import packageSack
 from repos import Repository
-from packages import YumAvailablePackage
 import parser
 import storagefactory
-
+from yum import config
 
 class YumPackageSack(packageSack.PackageSack):
     """imports/handles package objects from an mdcache dict object"""
@@ -60,7 +59,7 @@
                     for po in self.pkgsByID[pkgid]:
                         po.importFromDict(pkgdict)
 
-            self.added[repoid].append(datatype)
+            self.added[repo].append(datatype)
             # indexes will need to be rebuilt
             self.indexesBuilt = 0
         else:
@@ -118,31 +117,26 @@
         # get rid of all this stuff we don't need now
         del repo.cacheHandler
 
-
-class YumRepository(Repository):
-    """this is an actual repository object"""
+class YumRepository(Repository, config.RepoConf):
+    """
+    This is an actual repository object
+   
+    Configuration attributes are pulled in from config.RepoConf.
+    """
                 
     def __init__(self, repoid):
+        config.RepoConf.__init__(self)
         Repository.__init__(self, repoid)
 
-        self.name = repoid # name is repoid until someone sets it to a real name
-        # some default (ish) things
         self.urls = []
-        self.gpgcheck = 0
-        self.enabled = 0
         self.enablegroups = 0 
         self.groupsfilename = 'yumgroups.xml' # something some freaks might
                                               # eventually want
         self.repoMDFile = 'repodata/repomd.xml'
         self.repoXML = None
         self.cache = 0
-        self.mirrorlist = None # filename/url of mirrorlist file
         self.mirrorlistparsed = 0
-        self.baseurl = [] # baseurls from the config file 
         self.yumvar = {} # empty dict of yumvariables for $string replacement
-        self.proxy_password = None
-        self.proxy_username = None
-        self.proxy = None
         self._proxy_dict = {}
         self.metadata_cookie_fn = 'cachecookie'
         self.groups_added = False
@@ -703,6 +697,7 @@
     if hasattr(urlgrabber.grabber, 'urlopen'):
         urlresolver = urlgrabber.grabber
     else:
+        import urllib
         urlresolver = urllib
 
     scheme = urlparse.urlparse(mirrorlist)[0]




More information about the Yum-cvs-commits mailing list