From nobody Wed May 14 23:56:47 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521130284617158.4875971966593; Thu, 15 Mar 2018 09:11:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4A63A7FDDE; Thu, 15 Mar 2018 16:11:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1F5805D755; Thu, 15 Mar 2018 16:11:23 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D0C67181BA04; Thu, 15 Mar 2018 16:11:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2FGBH4n006842 for ; Thu, 15 Mar 2018 12:11:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8009F2026E04; Thu, 15 Mar 2018 16:11:17 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 276062026E03 for ; Thu, 15 Mar 2018 16:11:17 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 15 Mar 2018 17:11:05 +0100 Message-Id: <20180315161110.17925-4-abologna@redhat.com> In-Reply-To: <20180315161110.17925-1-abologna@redhat.com> References: <20180315161110.17925-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 3/8] python3: Use the 'in' keyword X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 15 Mar 2018 16:11:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This replaces uses of the has_key() method. Signed-off-by: Andrea Bolognani Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/apibuild.py | 60 ++++++++++++++++++++++++++++------------------------= ---- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/docs/apibuild.py b/docs/apibuild.py index 2e8932bb5e..e448e37ace 100755 --- a/docs/apibuild.py +++ b/docs/apibuild.py @@ -317,9 +317,9 @@ class index: # macro might be used to override functions or variables # definitions # - if self.macros.has_key(id): + if id in self.macros: del self.macros[id] - if self.functions.has_key(id): + if id in self.functions: self.warning("function %s from %s redeclared in %s" % ( id, self.functions[id].header, idx.functions[id].heade= r)) else: @@ -330,30 +330,30 @@ class index: # macro might be used to override functions or variables # definitions # - if self.macros.has_key(id): + if id in self.macros: del self.macros[id] - if self.variables.has_key(id): + if id in self.variables: self.warning("variable %s from %s redeclared in %s" % ( id, self.variables[id].header, idx.variables[id].heade= r)) else: self.variables[id] =3D idx.variables[id] self.identifiers[id] =3D idx.variables[id] for id in idx.structs.keys(): - if self.structs.has_key(id): + if id in self.structs: self.warning("struct %s from %s redeclared in %s" % ( id, self.structs[id].header, idx.structs[id].header)) else: self.structs[id] =3D idx.structs[id] self.identifiers[id] =3D idx.structs[id] for id in idx.unions.keys(): - if self.unions.has_key(id): + if id in self.unions: print("union %s from %s redeclared in %s" % ( id, self.unions[id].header, idx.unions[id].header)) else: self.unions[id] =3D idx.unions[id] self.identifiers[id] =3D idx.unions[id] for id in idx.typedefs.keys(): - if self.typedefs.has_key(id): + if id in self.typedefs: self.warning("typedef %s from %s redeclared in %s" % ( id, self.typedefs[id].header, idx.typedefs[id].header)) else: @@ -364,20 +364,20 @@ class index: # macro might be used to override functions or variables # definitions # - if self.variables.has_key(id): + if id in self.variables: continue - if self.functions.has_key(id): + if id in self.functions: continue - if self.enums.has_key(id): + if id in self.enums: continue - if self.macros.has_key(id): + if id in self.macros: self.warning("macro %s from %s redeclared in %s" % ( id, self.macros[id].header, idx.macros[id].header)) else: self.macros[id] =3D idx.macros[id] self.identifiers[id] =3D idx.macros[id] for id in idx.enums.keys(): - if self.enums.has_key(id): + if id in self.enums: self.warning("enum %s from %s redeclared in %s" % ( id, self.enums[id].header, idx.enums[id].header)) else: @@ -386,7 +386,7 @@ class index: =20 def merge_public(self, idx): for id in idx.functions.keys(): - if self.functions.has_key(id): + if id in self.functions: # check that function condition agrees with header if idx.functions[id].conditionals !=3D \ self.functions[id].conditionals: @@ -725,7 +725,7 @@ class CParser: line =3D m.group(2).lstrip() =20 if item: - if res.has_key(item): + if item in res: res[item] =3D res[item] + " " + line else: res[item] =3D line @@ -824,7 +824,7 @@ class CParser: =20 if name[0:2] =3D=3D '__': quiet =3D 1 - if ignored_macros.has_key(name): + if name in ignored_macros: quiet =3D 1 =20 args =3D [] @@ -903,7 +903,7 @@ class CParser: quiet =3D 1 if name[0:2] =3D=3D '__': quiet =3D 1 - if ignored_functions.has_key(name): + if name in ignored_functions: quiet =3D 1 =20 (ret, args) =3D description @@ -1149,7 +1149,7 @@ class CParser: while token is not None and token[1] !=3D ";": token =3D self.lexer.token() return token - elif token[0] =3D=3D "name" and ignored_words.has_key(token[1]= ): + elif token[0] =3D=3D "name" and token[1] in ignored_words: (n, info) =3D ignored_words[token[1]] i =3D 0 while i < n: @@ -2104,7 +2104,7 @@ class docBuilder: # TODO: generalize this a bit if lower =3D=3D 'and' or lower =3D=3D 'the': pass - elif self.xref.has_key(token): + elif token in self.xref: self.xref[token].append(id) else: self.xref[token] =3D [id] @@ -2228,7 +2228,7 @@ class docBuilder: output.write(" \n") @@ -2297,7 +2297,7 @@ class docBuilder: if ret[0] is not None: if ret[0] =3D=3D "void": output.write(" \n") - elif (ret[1] is None or ret[1] =3D=3D '') and not ignored_= functions.has_key(name): + elif (ret[1] is None or ret[1] =3D=3D '') and name not in = ignored_functions: self.error("Missing documentation for return of functi= on `%s'" % name) else: output.write(" \= n" % ( @@ -2307,7 +2307,7 @@ class docBuilder: if param[0] =3D=3D 'void': continue if (param[2] is None or param[2] =3D=3D ''): - if ignored_functions.has_key(name): + if name in ignored_functions: output.write(" \n" % (param[1], param[0])) else: self.error("Missing documentation for arg `%s' of = function `%s'" % (param[1], name)) @@ -2332,7 +2332,7 @@ class docBuilder: string.lower(data))) except: self.warning("Header %s lacks a %s description" % (mod= ule, data)) - if dict.info.has_key('Description'): + if 'Description' in dict.info: desc =3D dict.info['Description'] if string.find(desc, "DEPRECATED") !=3D -1: output.write(" \n") @@ -2341,17 +2341,17 @@ class docBuilder: ids.sort() for id in uniq(ids): # Macros are sometime used to masquerade other types. - if dict.functions.has_key(id): + if id in dict.functions: continue - if dict.variables.has_key(id): + if id in dict.variables: continue - if dict.typedefs.has_key(id): + if id in dict.typedefs: continue - if dict.structs.has_key(id): + if id in dict.structs: continue - if dict.unions.has_key(id): + if id in dict.unions: continue - if dict.enums.has_key(id): + if id in dict.enums: continue output.write(" \n" = % (id)) ids =3D dict.enums.keys() @@ -2401,7 +2401,7 @@ class docBuilder: for param in params: if param[0] =3D=3D 'void': continue - if funcs.has_key(param[0]): + if param[0] in funcs: funcs[param[0]].append(name) else: funcs[param[0]] =3D [name] @@ -2431,7 +2431,7 @@ class docBuilder: (ret, params, desc) =3D id.info if ret[0] =3D=3D "void": continue - if funcs.has_key(ret[0]): + if ret[0] in funcs: funcs[ret[0]].append(name) else: funcs[ret[0]] =3D [name] --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list