I spent some time running pychecker on some of the files in pym/ to just get a gander at what is going on. I've noticed a lot of bogus imports and bogus variable scopes, and one bug i thought we fixed ages ago but apparently we didn't. If no one objects out of hand I will go through and start fixing things.
Some starter patches are attached
Index: portage_checksum.py =================================================================== --- portage_checksum.py (revision 3058) +++ portage_checksum.py (working copy) @@ -7,11 +7,9 @@ from portage_const import PRIVATE_PATH,PRELINK_BINARY,HASHING_BLOCKSIZE import os import errno -import shutil import stat import portage_exception import portage_exec -import portage_util import portage_locks import commands import sha @@ -134,7 +132,6 @@ # Files rejected by prelink are summed in place. retval=portage_exec.spawn([PRELINK_BINARY,"--undo","-o",prelink_tmpfile,filename],fd_pipes={}) if retval==0: - #portage_util.writemsg(">>> prelink checksum '"+str(filename)+"'.\n") myfilename=prelink_tmpfile try: if hashname not in hashfunc_map:
Index: portage_contents.py =================================================================== --- portage_contents.py (revision 3058) +++ portage_contents.py (working copy) @@ -4,13 +4,9 @@ # $Id: /var/cvsroot/gentoo-src/portage/pym/portage_contents.py,v 1.3.2.1 2005/01/16 02:35:33 carpaski Exp $ -import os,string,types,sys,copy +import os,string,types import portage_exception -import portage_const -#import gettext -#gettext_t = gettext.translation('portage.contents', portage_const.LOCALE_DATA_PATH) -#_ = gettext_t.ugettext def _(mystr): return mystr @@ -32,7 +28,6 @@ parts = string.split(line) mytype = parts[0] - mytarget = None if mytype in ["dir","dev","fif"]: mypath = string.join(parts[1:]) @@ -43,7 +38,6 @@ sl = string.split(sl, " -> ") mypath = sl[0] - mytarget = sl[1] else: print _("Unknown type:"),mytype @@ -71,7 +65,6 @@ raise portage_exception.IncorrectParameter, _("Handler of type '%(type)s' not 'function'") % {"type": type(handler)} filelist,dirlist = handler(filename) - filestat = os.stat(filename) if type(filelist) != types.ListType: raise portage_exception.InvalidDataType, _("%(handler)s returned an invalid file list") % {"handler": handler.__name__} @@ -148,7 +141,6 @@ def test(): - import os plt = PathLookupTable("spork") for x in os.listdir("/var/db/pkg"): for y in os.listdir("/var/db/pkg/"+x):
Index: portage_data.py =================================================================== --- portage_data.py (revision 3058) +++ portage_data.py (working copy) @@ -4,7 +4,7 @@ # $Id: /var/cvsroot/gentoo-src/portage/pym/portage_data.py,v 1.5.2.2 2005/02/26 11:22:38 carpaski Exp $ -import os,pwd,grp +import os,pwd,grp,sys from portage_util import writemsg from output import green,red