[yum-cvs] yum/yum comps.py, 1.10, 1.10.4.1 config.py, 1.105, 1.105.2.1 logginglevels.py, 1.5.2.1, 1.5.2.2 misc.py, 1.19, 1.19.2.1 packages.py, 1.73.2.3, 1.73.2.4 repos.py, 1.101, 1.101.2.1 sqlitesack.py, 1.47, 1.47.2.1 storagefactory.py, 1.3, 1.3.2.1 yumRepo.py, 1.23.2.1, 1.23.2.2

Seth Vidal skvidal at linux.duke.edu
Wed Oct 18 04:18:06 UTC 2006


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

Modified Files:
      Tag: yum-3_0_X
	comps.py config.py logginglevels.py misc.py packages.py 
	repos.py sqlitesack.py storagefactory.py yumRepo.py 
Log Message:

- lots of pychecker fixes
- remove duplicate code for checksumming
- clean up some potential bugs


Index: comps.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/comps.py,v
retrieving revision 1.10
retrieving revision 1.10.4.1
diff -u -r1.10 -r1.10.4.1
--- comps.py	10 Feb 2006 14:01:25 -0000	1.10
+++ comps.py	18 Oct 2006 04:18:03 -0000	1.10.4.1
@@ -86,10 +86,10 @@
         for child in elem:
 
             if child.tag == 'id':
-                id = child.text
+                myid = child.text
                 if self.groupid is not None:
                     raise CompsException
-                self.groupid = id
+                self.groupid = myid
             
             elif child.tag == 'name':
                 text = child.text
@@ -135,21 +135,21 @@
     def parse_package_list(self, packagelist_elem):
         for child in packagelist_elem:
             if child.tag == 'packagereq':
-                type = child.attrib.get('type')
-                if not type:
-                    type = u'mandatory'
+                genre = child.attrib.get('type')
+                if not genre:
+                    genre = u'mandatory'
 
-                if type not in ('mandatory', 'default', 'optional', 'conditional'):
+                if genre not in ('mandatory', 'default', 'optional', 'conditional'):
                     raise CompsException
 
                 package = child.text
-                if type == 'mandatory':
+                if genre == 'mandatory':
                     self.mandatory_packages[package] = 1
-                elif type == 'default':
+                elif genre == 'default':
                     self.default_packages[package] = 1
-                elif type == 'optional':
+                elif genre == 'optional':
                     self.optional_packages[package] = 1
-                elif type == 'conditional':
+                elif genre == 'conditional':
                     self.conditional_packages[package] = child.attrib.get('requires')
 
 
@@ -206,10 +206,10 @@
     def parse(self, elem):
         for child in elem:
             if child.tag == 'id':
-                id = child.text
+                myid = child.text
                 if self.categoryid is not None:
                     raise CompsException
-                self.categoryid = id
+                self.categoryid = myid
 
             elif child.tag == 'name':
                 text = child.text

Index: config.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/config.py,v
retrieving revision 1.105
retrieving revision 1.105.2.1
diff -u -r1.105 -r1.105.2.1
--- config.py	2 Oct 2006 13:02:13 -0000	1.105
+++ config.py	18 Oct 2006 04:18:03 -0000	1.105.2.1
@@ -591,10 +591,10 @@
     '''
     
     # Set up substitution vars
-    vars = _getEnvVar()
-    vars['basearch'] = rpmUtils.arch.getBaseArch()          # FIXME make this configurable??
-    vars['arch'] = rpmUtils.arch.getCanonArch()             # FIXME make this configurable??
-    vars['releasever'] = _getsysver(startupconf.installroot, startupconf.distroverpkg)
+    yumvars = _getEnvVar()
+    yumvars['basearch'] = rpmUtils.arch.getBaseArch()          # FIXME make this configurable??
+    yumvars['arch'] = rpmUtils.arch.getCanonArch()             # FIXME make this configurable??
+    yumvars['releasever'] = _getsysver(startupconf.installroot, startupconf.distroverpkg)
 
     # Read [main] section
     yumconf = YumConf()
@@ -606,7 +606,7 @@
         setattr(yumconf, option, yumconf.installroot + path)
     
     # Add in some extra attributes which aren't actually configuration values 
-    yumconf.yumvar = vars
+    yumconf.yumvar = yumvars
     yumconf.uid = 0
     yumconf.cache = 0
     yumconf.progess_obj = None

Index: logginglevels.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/logginglevels.py,v
retrieving revision 1.5.2.1
retrieving revision 1.5.2.2
diff -u -r1.5.2.1 -r1.5.2.2
--- logginglevels.py	13 Oct 2006 01:17:48 -0000	1.5.2.1
+++ logginglevels.py	18 Oct 2006 04:18:03 -0000	1.5.2.2
@@ -22,6 +22,7 @@
 import socket
 import sys
 import logging
+import logging.handlers
 
 INFO_1 = 19
 INFO_2 = 18
@@ -140,5 +141,6 @@
                 "%b %d %H:%M:%S")
             filehandler.setFormatter(formatter)
             filelogger.addHandler(filehandler)
-        except Exception, e:
+        #FIXME: XXX: A global exception catch? That seems unlikely.
+        except Exception:
             logging.getLogger("yum").critical('Cannot open logfile %s', logfile)

Index: misc.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/misc.py,v
retrieving revision 1.19
retrieving revision 1.19.2.1
diff -u -r1.19 -r1.19.2.1
--- misc.py	8 Sep 2006 16:21:32 -0000	1.19
+++ misc.py	18 Oct 2006 04:18:03 -0000	1.19.2.1
@@ -103,22 +103,22 @@
             
         if sumtype == 'md5':
             import md5
-            sum = md5.new()
+            sumalgo = md5.new()
         elif sumtype == 'sha':
             import sha
-            sum = sha.new()
+            sumalgo = sha.new()
         else:
             raise MiscError, 'Error Checksumming file, bad checksum type %s' % sumtype
         chunk = fo.read
         while chunk: 
             chunk = fo.read(CHUNK)
-            sum.update(chunk)
+            sumalgo.update(chunk)
 
         if type(file) is types.StringType:
             fo.close()
             del fo
             
-        return sum.hexdigest()
+        return sumalgo.hexdigest()
     except (IOError, OSError), e:
         raise MiscError, 'Error opening file for checksum: %s' % file
 

Index: packages.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/packages.py,v
retrieving revision 1.73.2.3
retrieving revision 1.73.2.4
diff -u -r1.73.2.3 -r1.73.2.4
--- packages.py	16 Oct 2006 22:30:20 -0000	1.73.2.3
+++ packages.py	18 Oct 2006 04:18:03 -0000	1.73.2.4
@@ -20,7 +20,6 @@
 import os.path
 import misc
 import re
-import types
 import fnmatch
 import stat
 import warnings
@@ -30,7 +29,6 @@
 import rpmUtils.miscutils
 import Errors
 
-base=None
 
 def comparePoEVR(po1, po2):
     (e1, v1, r1) = (po1.epoch, po1.ver, po1.rel)

Index: repos.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/repos.py,v
retrieving revision 1.101
retrieving revision 1.101.2.1
diff -u -r1.101 -r1.101.2.1
--- repos.py	29 Sep 2006 15:42:59 -0000	1.101
+++ repos.py	18 Oct 2006 04:18:03 -0000	1.101.2.1
@@ -19,7 +19,6 @@
 import re
 import fnmatch
 import types
-import time
 
 import Errors
 from packageSack import MetaSack

Index: sqlitesack.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/sqlitesack.py,v
retrieving revision 1.47
retrieving revision 1.47.2.1
diff -u -r1.47 -r1.47.2.1
--- sqlitesack.py	13 Sep 2006 22:37:46 -0000	1.47
+++ sqlitesack.py	18 Oct 2006 04:18:04 -0000	1.47.2.1
@@ -21,9 +21,7 @@
 
 import os
 import os.path
-import types
 import re
-import repos
 import yumRepo
 from packages import YumAvailablePackage
 import Errors

Index: storagefactory.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/storagefactory.py,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- storagefactory.py	21 Jun 2006 17:07:44 -0000	1.3
+++ storagefactory.py	18 Oct 2006 04:18:04 -0000	1.3.2.1
@@ -14,7 +14,6 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 # Copyright 2004 Duke University
 
-import repos
 import Errors
 
 class Storage:

Index: yumRepo.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/yumRepo.py,v
retrieving revision 1.23.2.1
retrieving revision 1.23.2.2
diff -u -r1.23.2.1 -r1.23.2.2
--- yumRepo.py	6 Oct 2006 02:24:47 -0000	1.23.2.1
+++ yumRepo.py	18 Oct 2006 04:18:04 -0000	1.23.2.2
@@ -14,6 +14,7 @@
 import parser
 import storagefactory
 from yum import config
+from yum import misc
 
 class YumPackageSack(packageSack.PackageSack):
     """imports/handles package objects from an mdcache dict object"""
@@ -202,35 +203,10 @@
            sumtype = md5 or sha
            filename = /path/to/file
            CHUNK=65536 by default"""
-
-        # chunking brazenly lifted from Ryan Tomayko
         try:
-            if type(file) is not types.StringType:
-                fo = file # assume it's a file-like-object
-            else:
-                fo = open(file, 'r', CHUNK)
-
-            if sumtype == 'md5':
-                import md5
-                sum = md5.new()
-            elif sumtype == 'sha':
-                import sha
-                sum = sha.new()
-            else:
-                raise Errors.RepoError, 'Error Checksumming file, wrong \
-                                         checksum type %s' % sumtype
-            chunk = fo.read
-            while chunk:
-                chunk = fo.read(CHUNK)
-                sum.update(chunk)
-
-            if type(file) is types.StringType:
-                fo.close()
-                del fo
-
-            return sum.hexdigest()
-        except (EnvironmentError, IOError, OSError):
-            raise Errors.RepoError, 'Error opening file for checksum'
+            misc.checksum(sumtype, file, CHUNK)
+        except (Errors.MiscError, EnvironmentError), e:
+            raise Errors.RepoError, 'Error opening file for checksum: %s' % e
 
     def dump(self):
         output = '[%s]\n' % self.id
@@ -568,7 +544,7 @@
             filepath = fo
 
         try:
-            foo = repoMDObject.RepoMD(self.id, filepath)
+            repoMDObject.RepoMD(self.id, filepath)
         except Errors.RepoMDError, e:
             raise URLGrabError(-1, 'Error importing repomd.xml for %s: %s' % (self, e))
 




More information about the Yum-cvs-commits mailing list