Run pychecker over everything, fix obvious thing slike modules not in use, variables...
authorAlec Warner <antarus@gentoo.org>
Sun, 22 Jul 2007 09:55:50 +0000 (09:55 -0000)
committerAlec Warner <antarus@gentoo.org>
Sun, 22 Jul 2007 09:55:50 +0000 (09:55 -0000)
svn path=/main/trunk/; revision=7354

pym/portage/checksum.py
pym/portage/getbinpkg.py
pym/portage/glsa.py
pym/portage/news.py
pym/portage/output.py
pym/portage/process.py

index edbd515aed6a0fecaef96748933b006d5eb11e8f..fa00247ab1c70fb569eb58ead6b668df661b433f 100644 (file)
@@ -30,14 +30,14 @@ def _generate_hash_function(hashtype, hashobject, origin="unknown"):
                blocksize = HASHING_BLOCKSIZE
                data = f.read(blocksize)
                size = 0L
-               sum = hashobject()
+               checksum = hashobject()
                while data:
-                       sum.update(data)
+                       checksum.update(data)
                        size = size + len(data)
                        data = f.read(blocksize)
                f.close()
 
-               return (sum.hexdigest(), size)
+               return (checksum.hexdigest(), size)
        hashfunc_map[hashtype] = pyhash
        hashorigin_map[hashtype] = origin
        return pyhash
index 1adab1b511af73e1bd13a328975edcb30939d57f..6e0ab516815aa0fab1442d0ed44dc4bb339e1aef 100644 (file)
@@ -4,7 +4,14 @@
 # $Id$
 
 from portage.output import red, yellow, green
-import htmllib,HTMLParser,formatter,sys,os,portage.xpak,time,tempfile,base64,urllib2
+import portage.xpak
+import HTMLParser
+import sys
+import os
+import time
+import tempfile
+import base64
+import urllib2
 
 try:
        import cPickle
@@ -13,16 +20,12 @@ except ImportError:
 
 try:
        import ftplib
-except SystemExit, e:
-       raise
-except Exception, e:
+except ImportError, e:
        sys.stderr.write(red("!!! CANNOT IMPORT FTPLIB: ")+str(e)+"\n")
 
 try:
        import httplib
-except SystemExit, e:
-       raise
-except Exception, e:
+except ImportError, e:
        sys.stderr.write(red("!!! CANNOT IMPORT HTTPLIB: ")+str(e)+"\n")
 
 def make_metadata_dict(data):
@@ -266,11 +269,11 @@ def match_in_array(array, prefix="", suffix="", match_both=1, allow_overlap=0):
 
                if not allow_overlap: # Not allow to overlap prefix and suffix
                        if len(x) >= (len(prefix)+len(suffix)):
-                               y = x[len(prefix):]
+                               pass
                        else:
                                continue          # Too short to match.
                else:
-                       y = x               # Do whatever... We're overlapping.
+                       pass                      # Do whatever... We're overlapping.
                
                if suffix and (len(x) >= len(suffix)) and (x[-len(suffix):] == suffix):
                        myarray.append(x)   # It matches
@@ -456,8 +459,6 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
 
        conn,protocol,address,params,headers = create_conn(baseurl, conn)
 
-       filedict = {}
-
        try:
                metadatafile = open("/var/cache/edb/remote_metadata.pickle")
                metadata = cPickle.load(metadatafile)
@@ -484,7 +485,6 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
        # Determine if our metadata file is current.
        metalist.sort()
        metalist.reverse() # makes the order new-to-old.
-       havecache=0
        for mfile in metalist:
                if usingcache and \
                   ((metadata[baseurl]["indexname"] != mfile) or \
@@ -650,7 +650,6 @@ class PackageIndex(object):
                cpv_all = self.packages.keys()
                cpv_all.sort()
                if self.modified:
-                       import time
                        self.header["TIMESTAMP"] = str(long(time.time()))
                        self.header["PACKAGES"] = str(len(cpv_all))
                keys = self.header.keys()
index d8053a8204bafc0b796120a1451abd1a162adf6e..5e2d5f08171a3db7b2f1ba658e8692e470721b7c 100644 (file)
@@ -5,8 +5,6 @@
 import os
 import sys
 import urllib
-import time
-import codecs
 import re
 import xml.dom.minidom
 
@@ -535,7 +533,6 @@ class Glsa:
                @rtype:         Boolean
                @returns:       True if the system is affected, False if not
                """
-               vList = []
                rValue = False
                for k in self.packages.keys():
                        pkg = self.packages[k]
index d8df8c294257b5c0c670a3f548bbec84e5c72864..702a377a54687431fb88077dcec6d8c2e6b165d1 100644 (file)
@@ -72,7 +72,6 @@ class NewsManager(object):
 
                path = os.path.join(self.portdb.getRepositoryPath(repoid), self.NEWS_PATH)
 
-               repo_path = self.portdb.getRepositoryPath(repoid)
                # Skip reading news for repoid if the news dir does not exist.  Requested by
                # NightMorph :)
                if not os.path.exists(path):
@@ -83,7 +82,7 @@ class NewsManager(object):
                        try:
                                filename = os.path.join(path, itemid, itemid + "." + self.LANGUAGE_ID + ".txt")
                                item = NewsItem(filename, itemid, timestamp)
-                       except (TypeError, ValueError), e:
+                       except (TypeError, ValueError):
                                continue
                        if item.isRelevant(profile=self._profile_path,
                                config=self.config, vardb=self.vdb):
index 9f0b7950bfaa202a6493b59a332fea9aaf84478c..f4e90fb8e06ed0692af087c9d95304539486a9a7 100644 (file)
@@ -4,7 +4,12 @@
 
 __docformat__ = "epytext"
 
-import commands, errno, os, re, shlex, sys, time
+import commands
+import errno
+import os
+import re
+import shlex
+import sys
 from portage.const import COLOR_MAP_FILE
 from portage.util import writemsg
 from portage.exception import PortageException, ParseError, PermissionDenied, FileNotFound
@@ -170,7 +175,6 @@ def parse_color_map(onerror=None):
        try:
                s = shlex.shlex(open(myfile))
                s.wordchars = s.wordchars + ";" # for ansi codes
-               d = {}
                while True:
                        k, o, v = s.get_token(), s.get_token(), s.get_token()
                        if k is s.eof:
@@ -220,10 +224,11 @@ def parse_color_map(onerror=None):
 
 try:
        parse_color_map(onerror=lambda e: writemsg("%s\n" % str(e), noiselevel=-1))
-except FileNotFound, e:
+except FileNotFound:
        pass
 except PortageException, e:
        writemsg("%s\n" % str(e))
+       del e
 
 def nc_len(mystr):
        tmp = re.sub(esc_seq + "^m]+m", "", mystr);
index c3f5d4df4e959ade9ef06f556a19803f4251fbb1..fad38770e2fd7f8d57920ca3f854c2da526e81ee 100644 (file)
@@ -4,8 +4,10 @@
 # $Id$
 
 
-import os, atexit, signal, sys
-import portage.data
+import os
+import atexit
+import signal
+import sys
 
 from portage.util import dump_traceback
 from portage.const import BASH_BINARY, SANDBOX_BINARY