[yum-cvs] yum cli.py, 1.232, 1.233 shell.py, 1.29, 1.30 yum-updatesd.py, 1.17, 1.18

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


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

Modified Files:
	cli.py shell.py yum-updatesd.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: cli.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/cli.py,v
retrieving revision 1.232
retrieving revision 1.233
diff -u -r1.232 -r1.233
--- cli.py	3 Sep 2006 21:11:05 -0000	1.232
+++ cli.py	4 Sep 2006 16:33:30 -0000	1.233
@@ -78,7 +78,7 @@
         """grabs the repomd.xml for each enabled repository 
            and sets up the basics of the repository"""
         
-        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

Index: shell.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/shell.py,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- shell.py	23 Jun 2006 14:26:17 -0000	1.29
+++ shell.py	4 Sep 2006 16:33:30 -0000	1.30
@@ -210,8 +210,7 @@
                 value = BOOLEAN_STATES[value.lower()]
                 setattr(self.base.conf, cmd, value)
                 if cmd == 'obsoletes':
-                    if hasattr(self.base, 'up'): # reset the updates
-                        del self.base.up
+                    self.base.up = None
         
         elif cmd in ['exclude']:
             args = args.replace(',', ' ')
@@ -223,11 +222,10 @@
                 return False
             else:
                 setattr(self.base.conf, cmd, opts)
-                if hasattr(self.base, 'pkgSack'): # kill the pkgSack
-                    del self.base.pkgSack
+                if self.base.pkgSack:       # kill the pkgSack
+                    self.base.pkgSack = None
                     self.base.repos._selectSackType()
-                if hasattr(self.base, 'up'): # reset the updates
-                    del self.base.up
+                self.base.up = None         # reset the updates
                 # reset the transaction set, we have to or we shall surely die!
                 self.base.closeRpmDB() 
                 self.base.doTsSetup()
@@ -274,8 +272,7 @@
                             self.base.repos.disableRepo(repo)
                             return False
                             
-                    if hasattr(self.base, 'up'): # reset the updates
-                        del self.base.up
+                    self.base.up = None
             
         elif cmd == 'disable':
             repos = self._shlex_split(args)
@@ -288,11 +285,10 @@
                     self.logger.critical(e)
 
                 else:
-                    if hasattr(self.base, 'pkgSack'): # kill the pkgSack
-                        del self.base.pkgSack
+                    if self.base.pkgSack:       # kill the pkgSack
+                        self.base.pkgSack = None
                         self.base.repos._selectSackType()
-                    if hasattr(self.base, 'up'): # reset the updates
-                        del self.base.up
+                    self.base.up = None     # reset the updates
                     # reset the transaction set and refresh everything
                     self.base.closeRpmDB() 
                     self.base.doTsSetup()

Index: yum-updatesd.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum-updatesd.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- yum-updatesd.py	23 Aug 2006 11:59:56 -0000	1.17
+++ yum-updatesd.py	4 Sep 2006 16:33:30 -0000	1.18
@@ -333,7 +333,7 @@
 
             return pkgDict
 
-        if not hasattr(self, 'up'):
+        if self.up is None:
             # we're _only_ called after updates are setup
             return
 




More information about the Yum-cvs-commits mailing list