[Yum-devel] [PATCH] Trivial has_key() to "in" changes.

Ville Skyttä ville.skytta at iki.fi
Thu Oct 29 19:35:20 UTC 2009


This is the first one in set of has_key() avoidance changesets.
---
 cli.py                  |    4 ++--
 rpmUtils/arch.py        |   20 ++++++++++----------
 rpmUtils/transaction.py |    2 +-
 rpmUtils/updates.py     |    8 ++++----
 yum/__init__.py         |   16 ++++++++--------
 yum/comps.py            |    8 ++++----
 yum/depsolve.py         |   10 +++++-----
 yum/packageSack.py      |   10 +++++-----
 yum/packages.py         |   13 ++++++-------
 yum/pgpmsg.py           |    2 +-
 yum/plugins.py          |    2 +-
 yum/repoMDObject.py     |    2 +-
 yum/repos.py            |    2 +-
 yum/rpmsack.py          |    4 ++--
 yum/rpmtrans.py         |    2 +-
 yum/sqlitesack.py       |   10 +++++-----
 yum/transactioninfo.py  |    4 ++--
 yum/update_md.py        |    6 +++---
 yum/yumRepo.py          |    4 ++--
 yumcommands.py          |    2 +-
 20 files changed, 65 insertions(+), 66 deletions(-)

diff --git a/cli.py b/cli.py
index 417cadb..0851e12 100644
--- a/cli.py
+++ b/cli.py
@@ -102,7 +102,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
 
     def registerCommand(self, command):
         for name in command.getNames():
-            if self.yum_cli_commands.has_key(name):
+            if name in self.yum_cli_commands:
                 raise yum.Errors.ConfigError(_('Command "%s" already defined') % name)
             self.yum_cli_commands[name] = command
             
@@ -276,7 +276,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
             for arg in self.extcmds:
                 self.verbose_logger.log(yum.logginglevels.DEBUG_4, '   %s', arg)
         
-        if not self.yum_cli_commands.has_key(self.basecmd):
+        if self.basecmd not in self.yum_cli_commands:
             self.usage()
             raise CliError
     
diff --git a/rpmUtils/arch.py b/rpmUtils/arch.py
index edfc707..b334750 100644
--- a/rpmUtils/arch.py
+++ b/rpmUtils/arch.py
@@ -112,7 +112,7 @@ def canCoinstall(arch1, arch2):
 def archDifference(myarch, targetarch):
     if myarch == targetarch:
         return 1
-    if arches.has_key(myarch):
+    if myarch in arches:
         ret = archDifference(arches[myarch], targetarch)
         if ret != 0:
             return ret + 1
@@ -127,13 +127,13 @@ def isMultiLibArch(arch=None):
     if arch is None:
         arch = canonArch
 
-    if not arches.has_key(arch): # or we could check if it is noarch
+    if arch not in arches: # or we could check if it is noarch
         return 0
     
-    if multilibArches.has_key(arch):
+    if arch in multilibArches:
         return 1
         
-    if multilibArches.has_key(arches[arch]):
+    if arches[arch] in multilibArches:
         return 1
     
     return 0
@@ -188,7 +188,7 @@ def getArchList(thisarch=None):
         thisarch = canonArch
     
     archlist = [thisarch]
-    while arches.has_key(thisarch):
+    while thisarch in arches:
         thisarch = arches[thisarch]
         archlist.append(thisarch)
 
@@ -330,9 +330,9 @@ canonArch = getCanonArch()
 
 # this gets you the "compat" arch of a biarch pair
 def getMultiArchInfo(arch = canonArch):
-    if multilibArches.has_key(arch):
+    if arch in multilibArches:
         return multilibArches[arch]
-    if arches.has_key(arch) and arches[arch] != "noarch":
+    if arch in arches and arches[arch] != "noarch":
         return getMultiArchInfo(arch = arches[arch])
     return None
 
@@ -361,7 +361,7 @@ def getBaseArch(myarch=None):
     if not myarch:
         myarch = canonArch
 
-    if not arches.has_key(myarch): # this is dumb, but <shrug>
+    if myarch not in arches: # this is dumb, but <shrug>
         return myarch
 
     if myarch.startswith("sparc64"):
@@ -370,12 +370,12 @@ def getBaseArch(myarch=None):
         return "ppc"
         
     if isMultiLibArch(arch=myarch):
-        if multilibArches.has_key(myarch):
+        if myarch in multilibArches:
             return myarch
         else:
             return arches[myarch]
     
-    if arches.has_key(myarch):
+    if myarch in arches:
         basearch = myarch
         value = arches[basearch]
         while value != 'noarch':
diff --git a/rpmUtils/transaction.py b/rpmUtils/transaction.py
index df9bebb..329de69 100644
--- a/rpmUtils/transaction.py
+++ b/rpmUtils/transaction.py
@@ -128,7 +128,7 @@ class TransactionWrapper:
                 continue
             tup = miscutils.pkgTupleFromHeader(h)    
             for r in h[rpm.RPMTAG_REQUIRENAME]:
-                if not req.has_key(r):
+                if r not in req:
                     req[r] = set()
                 req[r].add(tup)
      
diff --git a/rpmUtils/updates.py b/rpmUtils/updates.py
index 3264956..68dee45 100644
--- a/rpmUtils/updates.py
+++ b/rpmUtils/updates.py
@@ -67,7 +67,7 @@ class Updates:
 
     def _delFromDict(self, dict_, keys, value):
         for key in keys:
-            if not dict_.has_key(key):
+            if key not in dict_:
                 continue
             dict_[key] = filter(value.__ne__, dict_[key])
             if not dict_[key]:
@@ -343,7 +343,7 @@ class Updates:
             if a is None: # the None archs are only for lookups
                 continue
     
-            if self.installdict.has_key((n, None)):
+            if (n, None) in self.installdict:
                 installarchs = []
                 availarchs = []
                 for (a, e, v ,r) in newpkgs[(n, None)]:
@@ -440,7 +440,7 @@ class Updates:
                     hapdict = self.makeNADict(highestavailablepkgs, 0)
 
                     for (n, a) in hipdict:
-                        if hapdict.has_key((n, a)):
+                        if (n, a) in hapdict:
                             self.debugprint('processing %s.%s' % (n, a))
                             # we've got a match - get our versions and compare
                             (rpm_e, rpm_v, rpm_r) = hipdict[(n, a)][0] # only ever going to be first one
@@ -674,7 +674,7 @@ class Updates:
             inst[pkgtup] = 1
             
         for pkgtup in self.available:
-            if not updates.has_key(pkgtup) and not inst.has_key(pkgtup):
+            if pkgtup not in updates and pkgtup not in inst:
                 tmplist.append(pkgtup)
 
         returnlist = self.reduceListByNameArch(tmplist, name, arch)
diff --git a/yum/__init__.py b/yum/__init__.py
index 326adca..90fefb0 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1501,7 +1501,7 @@ class YumBase(depsolve.Depsolve):
                 adderror(po, str(e))
             else:
                 po.localpath = mylocal
-                if errors.has_key(po):
+                if po in errors:
                     del errors[po]
 
         if hasattr(urlgrabber.progress, 'text_meter_total_size'):
@@ -1646,7 +1646,7 @@ class YumBase(depsolve.Depsolve):
                 continue
             if txmbr.po.repoid == "installed":
                 continue
-            if not self.repos.repos.has_key(txmbr.po.repoid):
+            if txmbr.po.repoid not in self.repos.repos:
                 continue
             
             # make sure it's not a local file
@@ -2596,7 +2596,7 @@ class YumBase(depsolve.Depsolve):
         """ Given a package return the package it's obsoleted by and so
             we should install instead. Or None if there isn't one. """
         thispkgobsdict = self.up.checkForObsolete([po.pkgtup])
-        if thispkgobsdict.has_key(po.pkgtup):
+        if po.pkgtup in thispkgobsdict:
             obsoleting = thispkgobsdict[po.pkgtup][0]
             obsoleting_pkg = self.getPackageObject(obsoleting)
             return obsoleting_pkg
@@ -2703,7 +2703,7 @@ class YumBase(depsolve.Depsolve):
             if not kwargs:
                 raise Errors.InstallError, _('Nothing specified to install')
 
-            if kwargs.has_key('pattern'):
+            if 'pattern' in kwargs:
                 if kwargs['pattern'][0] == '@':
                     return self._at_groupinstall(kwargs['pattern'])
 
@@ -2819,7 +2819,7 @@ class YumBase(depsolve.Depsolve):
                     continue
             
             # make sure this shouldn't be passed to update:
-            if self.up.updating_dict.has_key(po.pkgtup):
+            if po.pkgtup in self.up.updating_dict:
                 txmbrs = self.update(po=po)
                 tx_return.extend(txmbrs)
                 continue
@@ -3009,7 +3009,7 @@ class YumBase(depsolve.Depsolve):
                 availpkgs.append(po)
                 
                 
-        elif kwargs.has_key('pattern'):
+        elif 'pattern' in kwargs:
             if kwargs['pattern'][0] == '@':
                 return self._at_groupinstall(kwargs['pattern'])
 
@@ -3190,7 +3190,7 @@ class YumBase(depsolve.Depsolve):
         if po:
             pkgs = [po]  
         else:
-            if kwargs.has_key('pattern'):
+            if 'pattern' in kwargs:
                 if kwargs['pattern'][0] == '@':
                     return self._at_groupremove(kwargs['pattern'])
 
@@ -3738,7 +3738,7 @@ class YumBase(depsolve.Depsolve):
             thiskey = {}
             for info in ('keyid', 'timestamp', 'userid', 
                          'fingerprint', 'raw_key'):
-                if not keyinfo.has_key(info):
+                if info not in keyinfo:
                     raise Errors.YumBaseError, \
                       _('GPG key parsing failed: key does not have value %s') + info
                 thiskey[info] = keyinfo[info]
diff --git a/yum/comps.py b/yum/comps.py
index 1e91b64..7e85a5a 100755
--- a/yum/comps.py
+++ b/yum/comps.py
@@ -87,14 +87,14 @@ class CompsObj(object):
     def nameByLang(self, lang):
 
         for langcode in self._expand_languages(lang):
-            if self.translated_name.has_key(langcode):
+            if langcode in self.translated_name:
                 return to_unicode(self.translated_name[langcode])
 
         return to_unicode(self.name)
 
     def descriptionByLang(self, lang):
         for langcode in self._expand_languages(lang):
-            if self.translated_description.has_key(langcode):
+            if langcode in self.translated_description:
                 return to_unicode(self.translated_description[langcode])
         return to_unicode(self.description)
 
@@ -451,7 +451,7 @@ class Comps(object):
 
         for item in pattern.split(','):
             item = item.strip()
-            if self._categories.has_key(item):
+            if item in self._categories:
                 cat = self._categories[item]
                 returns[cat.categoryid] = cat
                 continue
@@ -528,7 +528,7 @@ class Comps(object):
             if len(group.mandatory_packages) > 0:
                 group.installed = True
                 for pkgname in group.mandatory_packages:
-                    if not inst_pkg_names.has_key(pkgname):
+                    if pkgname not in inst_pkg_names:
                         group.installed = False
                         break
             # if it doesn't have any of those then see if it has ANY of the
diff --git a/yum/depsolve.py b/yum/depsolve.py
index 4c9ebd0..f1fa28a 100644
--- a/yum/depsolve.py
+++ b/yum/depsolve.py
@@ -142,7 +142,7 @@ class Depsolve(object):
         self._ts.setFlags(0) # reset everything.
         
         for flag in self.conf.tsflags:
-            if ts_flags_to_rpm.has_key(flag):
+            if flag in ts_flags_to_rpm:
                 self._ts.addTsFlag(ts_flags_to_rpm[flag])
             else:
                 self.logger.critical(_('Invalid tsflag in config file: %s'), flag)
@@ -224,7 +224,7 @@ class Depsolve(object):
         for txmbr in self.tsInfo.getMembers():
             self.verbose_logger.log(logginglevels.DEBUG_3, _('Member: %s'), txmbr)
             if txmbr.ts_state in ['u', 'i']:
-                if ts_elem.has_key((txmbr.pkgtup, 'i')):
+                if (txmbr.pkgtup, 'i') in ts_elem:
                     continue
                 rpmfile = txmbr.po.localPkg()
                 if os.path.exists(rpmfile):
@@ -248,7 +248,7 @@ class Depsolve(object):
                     self.dsCallback.pkgAdded(txmbr.pkgtup, txmbr.ts_state)
             
             elif txmbr.ts_state in ['e']:
-                if ts_elem.has_key((txmbr.pkgtup, txmbr.ts_state)):
+                if (txmbr.pkgtup, txmbr.ts_state) in ts_elem:
                     continue
                 self.ts.addErase(txmbr.po.idx)
                 if self.dsCallback: self.dsCallback.pkgAdded(txmbr.pkgtup, 'e')
@@ -332,7 +332,7 @@ class Depsolve(object):
         needpo = None
         providers = []
         
-        if self.cheaterlookup.has_key((needname, needflags, needversion)):
+        if (needname, needflags, needversion) in self.cheaterlookup:
             self.verbose_logger.log(logginglevels.DEBUG_2, _('Needed Require has already been looked up, cheating'))
             cheater_po = self.cheaterlookup[(needname, needflags, needversion)]
             providers = [cheater_po]
@@ -590,7 +590,7 @@ class Depsolve(object):
             # if we had other packages with this name.arch that we found
             # before, they're not going to be installed anymore, so we
             # should mark them to be re-checked
-            if upgraded.has_key(best.pkgtup):
+            if best.pkgtup in upgraded:
                 map(self.tsInfo.remove, upgraded[best.pkgtup])
 
         checkdeps = 1
diff --git a/yum/packageSack.py b/yum/packageSack.py
index 33fdbfe..7f563dc 100644
--- a/yum/packageSack.py
+++ b/yum/packageSack.py
@@ -330,7 +330,7 @@ class PackageSackBase(object):
             if not po.requires_names:
                 continue
             for r in po.requires_names:
-                if not req.has_key(r):
+                if r not in req:
                     req[r] = set()
                 if len(req[r]) > 1: #  We only need to know if another pkg.
                     continue        # reqs. the provide. So 2 pkgs. is enough.
@@ -643,7 +643,7 @@ class PackageSack(PackageSackBase):
     def searchNevra(self, name=None, epoch=None, ver=None, rel=None, arch=None):
         """return list of pkgobjects matching the nevra requested"""
         self._checkIndexes(failure='build')
-        if self.nevra.has_key((name, epoch, ver, rel, arch)):
+        if (name, epoch, ver, rel, arch) in self.nevra:
             return self.nevra[(name, epoch, ver, rel, arch)]
         elif name is not None:
             pkgs = self.nevra.get((name, None, None, None, None), [])
@@ -767,7 +767,7 @@ class PackageSack(PackageSackBase):
         dict[key].append(data)
 
     def _delFromListOfDict(self, dict, key, data):
-        if not dict.has_key(key):
+        if key not in dict:
             return
         try:
             dict[key].remove(data)
@@ -902,7 +902,7 @@ class PackageSack(PackageSackBase):
                     highdict[(pkg.name, pkg.arch)] = pkg
         
         if naTup:
-            if highdict.has_key(naTup):
+            if naTup in highdict:
                 return [highdict[naTup]]
             else:
                 raise PackageSackError, 'No Package Matching %s.%s' % naTup
@@ -927,7 +927,7 @@ class PackageSack(PackageSackBase):
                     highdict[pkg.name].append(pkg)
                 
         if name:
-            if highdict.has_key(name):
+            if name in highdict:
                 return highdict[name]
             else:
                 raise PackageSackError, 'No Package Matching  %s' % name
diff --git a/yum/packages.py b/yum/packages.py
index 3c62f2a..a429348 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -110,7 +110,7 @@ def parsePackages(pkgs, usercommands, casematch=0,
     for command in usercommands:
         if not casematch:
             command = command.lower()
-        if pkgdict.has_key(command):
+        if command in pkgdict:
             exactmatch.extend(pkgdict[command])
             del pkgdict[command]
         else:
@@ -368,7 +368,7 @@ class RpmBase(object):
     def checkPrco(self, prcotype, prcotuple):
         """returns 1 or 0 if the pkg contains the requested tuple/tuple range"""
         # get rid of simple cases - nothing
-        if not self.prco.has_key(prcotype):
+        if prcotype not in self.prco:
             return 0
 
         # First try and exact match, then search
@@ -446,9 +446,8 @@ class RpmBase(object):
     def returnFileEntries(self, ftype='file'):
         """return list of files based on type"""
         # fixme - maybe should die - use direct access to attribute
-        if self.files:
-            if self.files.has_key(ftype):
-                return self.files[ftype]
+        if self.files and ftype in self.files:
+            return self.files[ftype]
         return []
             
     def returnFileTypes(self):
@@ -468,7 +467,7 @@ class RpmBase(object):
         return self.provides_names
 
     def simpleFiles(self, ftype='files'):
-        if self.files and self.files.has_key(ftype):
+        if self.files and ftype in self.files:
             return self.files[ftype]
         return []
     
@@ -1189,7 +1188,7 @@ class YumHeaderPackage(YumAvailablePackage):
                         self.files['file'] = []
                     self.files['file'].append(fn)
                     continue
-                if not self.__mode_cache.has_key(mode):
+                if mode not in self.__mode_cache:
                     self.__mode_cache[mode] = stat.S_ISDIR(mode)
           
                 fkey = 'file'
diff --git a/yum/pgpmsg.py b/yum/pgpmsg.py
index 4f0ff7e..24f5e42 100644
--- a/yum/pgpmsg.py
+++ b/yum/pgpmsg.py
@@ -368,7 +368,7 @@ def map_to_str(m, vals) :
     if type(vals) != types.ListType and type(vals) != types.TupleType :
         vals = list((vals,))
     for i in vals :
-        if m.has_key(i) :
+        if i in m :
             slist.append(m[i])
         else :
             slist.append('unknown(' + str(i) + ')')
diff --git a/yum/plugins.py b/yum/plugins.py
index 02f0d57..9968614 100644
--- a/yum/plugins.py
+++ b/yum/plugins.py
@@ -310,7 +310,7 @@ class YumPlugins:
                                 modname)
 
         # Store the plugin module and its configuration file
-        if not self._plugins.has_key(modname):
+        if modname not in self._plugins:
             self._plugins[modname] = (module, conf)
         else:
             raise Errors.ConfigError(_('Two or more plugins with the name "%s" ' \
diff --git a/yum/repoMDObject.py b/yum/repoMDObject.py
index 06ad82a..9f70f1d 100755
--- a/yum/repoMDObject.py
+++ b/yum/repoMDObject.py
@@ -134,7 +134,7 @@ class RepoMD:
         return self.repoData.keys()
     
     def getData(self, type):
-        if self.repoData.has_key(type):
+        if type in self.repoData:
             return self.repoData[type]
         else:
             raise RepoMDError, "requested datatype %s not available" % type
diff --git a/yum/repos.py b/yum/repos.py
index 7d35612..246c33c 100644
--- a/yum/repos.py
+++ b/yum/repos.py
@@ -93,7 +93,7 @@ class RepoStorage:
             repo.close()
 
     def add(self, repoobj):
-        if self.repos.has_key(repoobj.id):
+        if repoobj.id in self.repos:
             raise Errors.DuplicateRepoError, 'Repository %s is listed more than once in the configuration' % (repoobj.id)
         self.repos[repoobj.id] = repoobj
         if hasattr(repoobj, 'quick_enable_disable'):
diff --git a/yum/rpmsack.py b/yum/rpmsack.py
index 9a542e5..4789976 100644
--- a/yum/rpmsack.py
+++ b/yum/rpmsack.py
@@ -483,7 +483,7 @@ class RPMDBPackageSack(PackageSackBase):
     def _search(self, name=None, epoch=None, ver=None, rel=None, arch=None):
         '''List of matching packages, to zero or more of NEVRA.'''
         pkgtup = (name, arch, epoch, ver, rel)
-        if self._tup2pkg.has_key(pkgtup):
+        if pkgtup in self._tup2pkg:
             return [self._tup2pkg[pkgtup]]
 
         loc = locals()
@@ -527,7 +527,7 @@ class RPMDBPackageSack(PackageSackBase):
         return ret
 
     def _makePackageObject(self, hdr, index):
-        if self._idx2pkg.has_key(index):
+        if index in self._idx2pkg:
             return self._idx2pkg[index]
         po = RPMInstalledPackage(hdr, index, self)
         self._idx2pkg[index] = po
diff --git a/yum/rpmtrans.py b/yum/rpmtrans.py
index b1b896f..befead8 100644
--- a/yum/rpmtrans.py
+++ b/yum/rpmtrans.py
@@ -112,7 +112,7 @@ class RPMBaseCallback:
     def filelog(self, package, action):
         # If the action is not in the fileaction list then dump it as a string
         # hurky but, sadly, not much else 
-        if self.fileaction.has_key(action):
+        if action in self.fileaction:
             msg = '%s: %s' % (self.fileaction[action], package)
         else:
             msg = '%s: %s' % (package, action)
diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index 21b5c43..bf4aa26 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -316,7 +316,7 @@ class YumAvailablePackageSqlite(YumAvailablePackage, PackageObject, RpmBase):
     def _loadChangelog(self):
         result = []
         if not self._changelog:
-            if not self.sack.otherdb.has_key(self.repo):
+            if self.repo not in self.sack.otherdb:
                 try:
                     self.sack.populate(self.repo, mdtype='otherdata')
                 except Errors.RepoError:
@@ -688,10 +688,10 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
         if exclude and self._pkgKeyExcluded(repo, pkgKey):
             return None
 
-        if not self._key2pkg.has_key(repo):
+        if repo not in self._key2pkg:
             self._key2pkg[repo] = {}
             self._pkgname2pkgkeys[repo] = {}
-        if not self._key2pkg[repo].has_key(pkgKey):
+        if pkgKey not in self._key2pkg[repo]:
             sql = "SELECT pkgKey, pkgId, name, epoch, version, release, arch " \
                   "FROM packages WHERE pkgKey = ?"
             data = self._sql_MD('primary', repo, sql, (pkgKey,)).fetchone()
@@ -1145,7 +1145,7 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
 
         prcotype = _share_data(prcotype)
         req      = _share_data(req)
-        if self._search_cache[prcotype].has_key(req):
+        if req in self._search_cache[prcotype]:
             return self._search_cache[prcotype][req]
 
         result = { }
@@ -1342,7 +1342,7 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
                 
                 #~ # If it matches the dirname, that doesnt mean it matches
                 #~ # the filename, check if it does
-                #~ if filename and not quicklookup.has_key(filename):
+                #~ if filename and filename not in quicklookup:
                     #~ continue
                 
                 #~ matching_ids.append(str(res['pkgId']))
diff --git a/yum/transactioninfo.py b/yum/transactioninfo.py
index bd7bf80..d131db6 100644
--- a/yum/transactioninfo.py
+++ b/yum/transactioninfo.py
@@ -183,7 +183,7 @@ class TransactionData:
         for oldpo in txmember.updates:
             self.addUpdated(oldpo, txmember.po)
 
-        if not self.pkgdict.has_key(txmember.pkgtup):
+        if txmember.pkgtup not in self.pkgdict:
             self.pkgdict[txmember.pkgtup] = []
         else:
             self.debugprint("Package: %s.%s - %s:%s-%s already in ts" % txmember.pkgtup)
@@ -210,7 +210,7 @@ class TransactionData:
 
     def remove(self, pkgtup):
         """remove a package from the transaction"""
-        if not self.pkgdict.has_key(pkgtup):
+        if pkgtup not in self.pkgdict:
             self.debugprint("Package: %s not in ts" %(pkgtup,))
             return
         for txmbr in self.pkgdict[pkgtup]:
diff --git a/yum/update_md.py b/yum/update_md.py
index b3a120e..dadfa39 100644
--- a/yum/update_md.py
+++ b/yum/update_md.py
@@ -95,7 +95,7 @@ class UpdateNotice(object):
         if len(bzs):
             buglist = "       Bugs :"
             for bz in bzs:
-                buglist += " %s%s\n\t    :" % (bz['id'], bz.has_key('title')
+                buglist += " %s%s\n\t    :" % (bz['id'], 'title' in bz
                                                and ' - %s' % bz['title'] or '')
             head += buglist[: - 1].rstrip() + '\n'
 
@@ -201,7 +201,7 @@ class UpdateNotice(object):
         """
         for collection in elem:
             data = { 'packages' : [] }
-            if collection.attrib.has_key('short'):
+            if 'short' in collection.attrib:
                 data['short'] = collection.attrib.get('short')
             for item in collection:
                 if item.tag == 'name':
@@ -383,7 +383,7 @@ class UpdateMetadata(object):
                     print >> sys.stderr, "An update notice is broken, skipping."
                     # what else should we do?
                     continue
-                if not self._notices.has_key(un['update_id']):
+                if un['update_id'] not in self._notices:
                     self._notices[un['update_id']] = un
                     for pkg in un['pkglist']:
                         for file in pkg['packages']:
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index b95fd20..3b0a9f9 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -730,7 +730,7 @@ class YumRepository(Repository, config.RepoConf):
         headers = self.__headersListFromDict()
 
         # We will always prefer to send no-cache.
-        if not (cache or self.http_headers.has_key('Pragma')):
+        if not (cache or 'Pragma' in self.http_headers):
             headers.append(('Pragma', 'no-cache'))
 
         headers = tuple(headers)
@@ -1244,7 +1244,7 @@ class YumRepository(Repository, config.RepoConf):
     def _check_db_version(self, mdtype, repoXML=None):
         if repoXML is None:
             repoXML = self.repoXML
-        if repoXML.repoData.has_key(mdtype):
+        if mdtype in repoXML.repoData:
             if DBVERSION == repoXML.repoData[mdtype].dbversion:
                 return True
         return False
diff --git a/yumcommands.py b/yumcommands.py
index 1451a36..c0504a6 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -1009,7 +1009,7 @@ class HelpCommand(YumCommand):
         return help_output
 
     def doCommand(self, base, basecmd, extcmds):
-        if base.yum_cli_commands.has_key(extcmds[0]):
+        if extcmds[0] in base.yum_cli_commands:
             command = base.yum_cli_commands[extcmds[0]]
             base.verbose_logger.log(logginglevels.INFO_2,
                     self._makeOutput(command))
-- 
1.6.2.5



More information about the Yum-devel mailing list