[yum-cvs] yum/yum __init__.py,1.241,1.242 depsolve.py,1.100,1.101

Menno Smits mjs at linux.duke.edu
Mon Sep 4 16:33:32 UTC 2006


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

Modified Files:
	__init__.py depsolve.py 
Log Message:
Clean up the attributes of YumBase so that they are always defined. They are
None when not initialised and set if initialised. No more messing around with
hasattr and deinitialising in now a matter of "self.foo = None".


Index: __init__.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/__init__.py,v
retrieving revision 1.241
retrieving revision 1.242
diff -u -r1.241 -r1.242
--- __init__.py	3 Sep 2006 21:11:05 -0000	1.241
+++ __init__.py	4 Sep 2006 16:33:30 -0000	1.242
@@ -63,7 +63,11 @@
     
     def __init__(self):
         depsolve.Depsolve.__init__(self)
-        self.localdbimported = 0
+        self.tsInfo = None
+        self.rpmdb = None
+        self.up = None
+        self.comps = None
+        self.pkgSack = None
         self.logger = logging.getLogger("yum.YumBase")
         self.verbose_logger = logging.getLogger("yum.verbose.YumBase")
         self.repos = repos.RepoStorage() # class of repositories
@@ -231,7 +235,7 @@
            This can't happen in __init__ b/c we don't know our installroot
            yet"""
         
-        if hasattr(self, 'tsInfo'):
+        if self.tsInfo != None and self.ts != None:
             return
             
         if not self.conf.installroot:
@@ -243,21 +247,16 @@
     def doRpmDBSetup(self):
         """sets up a holder object for important information from the rpmdb"""
 
-        if not self.localdbimported:
+        if self.rpmdb is None:
             self.verbose_logger.debug('Reading Local RPMDB')
             self.rpmdb = rpmsack.RPMDBPackageSack(root=self.conf.installroot)
-            self.localdbimported = 1
 
     def closeRpmDB(self):
         """closes down the instances of the rpmdb we have wangling around"""
-        if hasattr(self, 'rpmdb'):
-            self.rpmdb = None
-            self.localdbimported = 0
-        if hasattr(self, 'ts'):
-            self.ts = None
-        if hasattr(self, 'up'):
-            self.up = None
-        if hasattr(self, 'comps'):
+        self.rpmdb = None
+        self.ts = None
+        self.up = None
+        if self.comps != None:
             self.comps.compiled = False
 
     def doRepoSetup(self, thisrepo=None):
@@ -289,7 +288,7 @@
         """populates the package sacks for information from our repositories,
            takes optional archlist for archs to include"""
            
-        if hasattr(self, 'pkgSack') and thisrepo is None:
+        if self.pkgSack and thisrepo is None:
             self.verbose_logger.log(logginglevels.DEBUG_4,
                 'skipping reposetup, pkgsack exists')
             return
@@ -323,13 +322,13 @@
         """setups up the update object in the base class and fills out the
            updates, obsoletes and others lists"""
         
-        if hasattr(self, 'up'):
+        if self.up != None:
             return
             
         self.verbose_logger.debug('Building updates object')
         #FIXME - add checks for the other pkglists to see if we should
         # raise an error
-        if not hasattr(self, 'pkgSack'):
+        if self.pkgSack is None:
             self.doRepoSetup()
             self.doSackSetup()
         
@@ -374,7 +373,7 @@
                 
         # now we know which repos actually have groups files.
         overwrite = self.conf.overwrite_groups
-        if not hasattr(self, 'comps'):
+        if self.comps is None:
             self.comps = comps.Comps(overwrite_groups = overwrite)
 
         for repo in reposWithGroups:

Index: depsolve.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/depsolve.py,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -r1.100 -r1.101
--- depsolve.py	2 Sep 2006 23:17:08 -0000	1.100
+++ depsolve.py	4 Sep 2006 16:33:30 -0000	1.101
@@ -34,6 +34,7 @@
 
 class Depsolve(object):
     def __init__(self):
+        self.ts = None
         packages.base = self
         self.dsCallback = None
         self.logger = logging.getLogger("yum.Depsolve")
@@ -228,7 +229,7 @@
                     '\nDep Number: %d/%d\n', depcount, len(deps))
                 if sense == rpm.RPMDEP_SENSE_REQUIRES: # requires
                     # if our packageSacks aren't here, then set them up
-                    if not hasattr(self, 'pkgSack'):
+                    if self.pkgSack is None:
                         self.doRepoSetup()
                         self.doSackSetup()
                     (checkdep, missing, conflict, errormsgs) = self._processReq(dep)
@@ -513,7 +514,7 @@
 
         if needmode is None:
             reqpkg = (name, ver, rel, None)
-            if hasattr(self, 'pkgSack'):
+            if self.pkgSack is None:
                 return self._requiringFromTransaction(reqpkg, requirement, errorlist)
             else:
                 self.verbose_logger.log(logginglevels.DEBUG_2, 'Unresolveable requirement %s for %s',




More information about the Yum-cvs-commits mailing list