Py3k compatibility patch #5 by Ali Polatel <hawking@g.o>.
authorZac Medico <zmedico@gentoo.org>
Tue, 1 Jul 2008 12:53:07 +0000 (12:53 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 1 Jul 2008 12:53:07 +0000 (12:53 -0000)
Replace dict.has_key() calls with "in" and "not in" operators.

svn path=/main/trunk/; revision=10874

bin/dispatch-conf
bin/dohtml
bin/glsa-check
bin/repoman

index 8ae055565b8365caa662a5f6fd876d176d6cb3c4..07131b55ee053918d02283e55fa0ed61fe97e387 100755 (executable)
@@ -72,7 +72,7 @@ class dispatch:
 
         self.options = portage.dispatch_conf.read_config(MANDATORY_OPTS)
 
-        if self.options.has_key("log-file"):
+        if "log-file" in self.options:
             if os.path.isfile(self.options["log-file"]):
                 shutil.copy(self.options["log-file"], self.options["log-file"] + '.old')
             if os.path.isfile(self.options["log-file"]) \
@@ -270,7 +270,7 @@ class dispatch:
                     show_new_diff = 1
                     continue
                 elif c == 'e':
-                    if not os.environ.has_key('EDITOR'):
+                    if 'EDITOR' not in os.environ:
                         os.environ['EDITOR']='nano'
                     os.system(os.environ['EDITOR'] + ' ' + newconf)
                     continue
@@ -334,7 +334,7 @@ class dispatch:
             conf  = re.sub (r'\._cfg\d+_', '', nconf)
             dir   = re.match (r'^(.+)/', nconf).group (1)
 
-            if h.has_key (conf):
+            if conf in h:
                 mrgconf = re.sub(r'\._cfg', '._mrg', h[conf]['new'])
                 if os.path.exists(mrgconf):
                     os.unlink(mrgconf)
index 6162b0199ab1f208226d529be80771ae09478c48..56f95bbfa0e4e0ebf251cddc50c5a722ccafe893 100755 (executable)
@@ -86,11 +86,11 @@ class OptionsClass:
                self.D = ""
                self.DOCDESTTREE = ""
                
-               if os.environ.has_key("PF"):
+               if "PF" in os.environ:
                        self.PF = os.environ["PF"]
-               if os.environ.has_key("D"):
+               if "D" in os.environ:
                        self.D = os.environ["D"]
-               if os.environ.has_key("_E_DOCDESTTREE_"):
+               if "_E_DOCDESTTREE_" in os.environ:
                        self.DOCDESTTREE = os.environ["_E_DOCDESTTREE_"]
                
                self.allowed_exts = [ 'htm', 'html', 'css', 'js',
index 8d955526af179b07cd58e268bb330c4d0d6c9356..82fb5e49d7a624ffaf9b085afb2ca181c05d18e5 100644 (file)
@@ -293,12 +293,12 @@ if mode == "mail":
        # color doesn't make any sense for mail
        nocolor()
 
-       if portage.settings.has_key("PORTAGE_ELOG_MAILURI"):
+       if "PORTAGE_ELOG_MAILURI" in portage.settings:
                myrecipient = portage.settings["PORTAGE_ELOG_MAILURI"].split()[0]
        else:
                myrecipient = "root@localhost"
        
-       if portage.settings.has_key("PORTAGE_ELOG_MAILFROM"):
+       if "PORTAGE_ELOG_MAILFROM" in portage.settings:
                myfrom = portage.settings["PORTAGE_ELOG_MAILFROM"]
        else:
                myfrom = "glsa-check"
index a131eadc52a8628fb9ccdfcb06de54b5021be815..09042b1e215d2bf518d765fe3ff705ce28932585 100755 (executable)
@@ -662,7 +662,7 @@ if os.path.exists(descfile):
                if not os.path.isdir(portdir+"/profiles/"+arch[1]):
                        print "Invalid "+arch[2]+" profile ("+arch[1]+") for arch "+arch[0]
                        continue
-               if profiles.has_key(arch[0]):
+               if arch[0] in profiles:
                        profiles[arch[0]]+= [[arch[1], arch[2]]]
                else:
                        profiles[arch[0]] = [[arch[1], arch[2]]]
@@ -670,7 +670,7 @@ if os.path.exists(descfile):
        for x in repoman_settings.archlist():
                if x[0] == "~":
                        continue
-               if not profiles.has_key(x):
+               if x not in profiles:
                        print red("\""+x+"\" doesn't have a valid profile listed in profiles.desc.")
                        print red("You need to either \"cvs update\" your profiles dir or follow this")
                        print red("up with the "+x+" team.")
@@ -1335,7 +1335,7 @@ for x in scanlist:
 
                # uselist checks - local
                mykey = portage.dep_getkey(catpkg)
-               if luselist.has_key(mykey):
+               if mykey in luselist:
                        for mypos in range(len(myuse)-1,-1,-1):
                                if myuse[mypos] and (myuse[mypos] in luselist[mykey]):
                                        del myuse[mypos]
@@ -1380,7 +1380,7 @@ for x in scanlist:
                                if myskey not in kwlist:
                                        stats["KEYWORDS.invalid"] += 1
                                        fails["KEYWORDS.invalid"].append(x+"/"+y+".ebuild: %s" % mykey)
-                               elif not profiles.has_key(myskey):
+                               elif myskey not in profiles:
                                        stats["KEYWORDS.invalid"] += 1
                                        fails["KEYWORDS.invalid"].append(x+"/"+y+".ebuild: %s (profile invalid)" % mykey)
 
@@ -1420,7 +1420,7 @@ for x in scanlist:
 
                for keyword,arch,groups in arches:
 
-                       if not profiles.has_key(arch):
+                       if arch not in profiles:
                                # A missing profile will create an error further down
                                # during the KEYWORDS verification.
                                continue
@@ -1833,7 +1833,7 @@ else:
                if "PORTAGE_GPG_KEY" not in repoman_settings:
                        raise portage.exception.MissingParameter("PORTAGE_GPG_KEY is unset!")
                if "PORTAGE_GPG_DIR" not in repoman_settings:
-                       if os.environ.has_key("HOME"):
+                       if "HOME" in os.environ:
                                repoman_settings["PORTAGE_GPG_DIR"] = os.path.join(os.environ["HOME"], ".gnupg")
                                logging.info("Automatically setting PORTAGE_GPG_DIR to %s" % repoman_settings["PORTAGE_GPG_DIR"])
                        else:
@@ -1848,7 +1848,7 @@ else:
                                repoman_settings["PORTAGE_GPG_DIR"])
                gpgcmd = "gpg --sign --clearsign --yes "
                gpgcmd+= "--default-key "+repoman_settings["PORTAGE_GPG_KEY"]
-               if repoman_settings.has_key("PORTAGE_GPG_DIR"):
+               if "PORTAGE_GPG_DIR" in repoman_settings:
                        gpgcmd += " --homedir "+repoman_settings["PORTAGE_GPG_DIR"]
                if options.pretend:
                        print "("+gpgcmd+" "+filename+")"