From nobody Fri May 3 05:47:52 2024 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 1521130280554143.82373904655583; Thu, 15 Mar 2018 09:11:20 -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 8CBCE41A20; Thu, 15 Mar 2018 16:11:18 +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 2B18D5D70B; Thu, 15 Mar 2018 16:11:18 +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 A25A3181B9FD; Thu, 15 Mar 2018 16:11:17 +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 w2FGBG8T006826 for ; Thu, 15 Mar 2018 12:11:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4DC512026E04; Thu, 15 Mar 2018 16:11:16 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9460D2026E03 for ; Thu, 15 Mar 2018 16:11:15 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 15 Mar 2018 17:11:03 +0100 Message-Id: <20180315161110.17925-2-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 1/8] python3: Use the print() function 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.30]); Thu, 15 Mar 2018 16:11:19 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" It has replaced the 'print' statement. Signed-off-by: Andrea Bolognani Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/apibuild.py | 85 ++++++++++++++++++++--------------= ---- src/esx/esx_vi_generator.py | 8 ++-- src/hyperv/hyperv_wmi_generator.py | 8 ++-- 3 files changed, 54 insertions(+), 47 deletions(-) diff --git a/docs/apibuild.py b/docs/apibuild.py index a788086a65..9ac6442337 100755 --- a/docs/apibuild.py +++ b/docs/apibuild.py @@ -7,6 +7,9 @@ # # daniel@veillard.com # + +from __future__ import print_function + import os, sys import string import glob @@ -150,8 +153,8 @@ class identifier: else: self.conditionals =3D conditionals[:] if self.name =3D=3D debugsym and not quiet: - print "=3D> define %s : %s" % (debugsym, (module, type, info, - extra, conditionals)) + print("=3D> define %s : %s" % (debugsym, (module, type, info, + extra, conditionals))) =20 def __repr__(self): r =3D "%s %s:" % (self.type, self.name) @@ -210,8 +213,8 @@ class identifier: def update(self, header, module, type =3D None, info =3D None, extra= =3DNone, conditionals=3DNone): if self.name =3D=3D debugsym and not quiet: - print "=3D> update %s : %s" % (debugsym, (module, type, info, - extra, conditionals)) + print("=3D> update %s : %s" % (debugsym, (module, type, info, + extra, conditionals))) if header is not None and self.header is None: self.set_header(module) if module is not None and (self.module is None or self.header =3D= =3D self.module): @@ -243,7 +246,7 @@ class index: def warning(self, msg): global warnings warnings =3D warnings + 1 - print msg + print(msg) =20 def add_ref(self, name, header, module, static, type, lineno, info=3DN= one, extra=3DNone, conditionals =3D None): if name[0:2] =3D=3D '__': @@ -263,7 +266,7 @@ class index: self.references[name] =3D d =20 if name =3D=3D debugsym and not quiet: - print "New ref: %s" % (d) + print("New ref: %s" % (d)) =20 return d =20 @@ -304,7 +307,7 @@ class index: self.warning("Unable to register type ", type) =20 if name =3D=3D debugsym and not quiet: - print "New symbol: %s" % (d) + print("New symbol: %s" % (d)) =20 return d =20 @@ -344,8 +347,8 @@ class index: self.identifiers[id] =3D idx.structs[id] for id in idx.unions.keys(): if self.unions.has_key(id): - print "union %s from %s redeclared in %s" % ( - id, self.unions[id].header, idx.unions[id].header) + 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] @@ -394,8 +397,8 @@ class index: up =3D idx.functions[id] self.functions[id].update(None, up.module, up.type, up.in= fo, up.extra) # else: - # print "Function %s from %s is not declared in headers" = % ( - # id, idx.functions[id].module) + # print("Function %s from %s is not declared in headers" = % ( + # id, idx.functions[id].module)) # TODO: do the same for variables. =20 def analyze_dict(self, type, dict): @@ -407,9 +410,9 @@ class index: if id.static =3D=3D 0: public =3D public + 1 if count !=3D public: - print " %d %s , %d public" % (count, type, public) + print(" %d %s , %d public" % (count, type, public)) elif count !=3D 0: - print " %d public %s" % (count, type) + print(" %d public %s" % (count, type)) =20 =20 def analyze(self): @@ -460,9 +463,9 @@ class CLexer: self.tokens.insert(0, token) =20 def debug(self): - print "Last token: ", self.last - print "Token queue: ", self.tokens - print "Line %d end: " % (self.lineno), self.line + print("Last token: ", self.last) + print("Token queue: ", self.tokens) + print("Line %d end: " % (self.lineno), self.line) =20 def token(self): while self.tokens =3D=3D []: @@ -691,22 +694,22 @@ class CParser: warnings =3D warnings + 1 if self.no_error: return - print msg + print(msg) =20 def error(self, msg, token=3D-1): if self.no_error: return =20 - print "Parse Error: " + msg + print("Parse Error: " + msg) if token !=3D -1: - print "Got token ", token + print("Got token ", token) self.lexer.debug() sys.exit(1) =20 def debug(self, msg, token=3D-1): - print "Debug: " + msg + print("Debug: " + msg) if token !=3D -1: - print "Got token ", token + print("Got token ", token) self.lexer.debug() =20 def parseTopComment(self, comment): @@ -1018,7 +1021,7 @@ class CParser: =20 def parsePreproc(self, token): if debug: - print "=3D> preproc ", token, self.lexer.tokens + print("=3D> preproc ", token, self.lexer.tokens) name =3D token[1] if name =3D=3D "#include": token =3D self.lexer.token() @@ -1156,7 +1159,7 @@ class CParser: continue else: if debug: - print "=3D> ", token + print("=3D> ", token) return token return None =20 @@ -1267,7 +1270,7 @@ class CParser: elif token[0] =3D=3D "sep" and token[1] =3D=3D "}": self.struct_fields =3D fields #self.debug("end parseStruct", token) - #print fields + #print(fields) token =3D self.token() return token else: @@ -1306,7 +1309,7 @@ class CParser: self.type =3D base_type self.struct_fields =3D fields #self.debug("end parseStruct", token) - #print fields + #print(fields) return token =20 # @@ -1322,7 +1325,7 @@ class CParser: elif token[0] =3D=3D "sep" and token[1] =3D=3D "}": self.union_fields =3D fields # self.debug("end parseUnion", token) - # print fields + # print(fields) token =3D self.token() return token else: @@ -1356,7 +1359,7 @@ class CParser: self.type =3D base_type self.union_fields =3D fields # self.debug("end parseUnion", token) - # print fields + # print(fields) return token =20 # @@ -1914,7 +1917,7 @@ class CParser: return token if token[0] =3D=3D 'sep' and token[1] =3D=3D "{": token =3D self.token() -# print 'Entering extern "C line ', self.lineno() +# print('Entering extern "C line ', self.lineno()) while token is not None and (token[0] !=3D 'sep' or token[1] !=3D "}"): if token[0] =3D=3D 'name': @@ -1924,7 +1927,7 @@ class CParser: "token %s %s unexpected at the top level"= % ( token[0], token[1])) token =3D self.parseGlobal(token) -# print 'Exiting extern "C" line', self.lineno() +# print('Exiting extern "C" line', self.lineno()) token =3D self.token() return token else: @@ -2025,7 +2028,7 @@ class CParser: =20 def parse(self): if not quiet: - print "Parsing %s" % (self.filename) + print("Parsing %s" % (self.filename)) token =3D self.token() while token is not None: if token[0] =3D=3D 'name': @@ -2064,11 +2067,11 @@ class docBuilder: def warning(self, msg): global warnings warnings =3D warnings + 1 - print msg + print(msg) =20 def error(self, msg): self.errors +=3D 1 - print >>sys.stderr, "Error:", msg + print("Error:", msg, file=3Dsys.stderr) =20 def indexString(self, id, str): if str is None: @@ -2110,7 +2113,7 @@ class docBuilder: =20 def analyze(self): if not quiet: - print "Project %s : %d headers, %d modules" % (self.name, len(= self.headers.keys()), len(self.modules.keys())) + print("Project %s : %d headers, %d modules" % (self.name, len(= self.headers.keys()), len(self.modules.keys()))) self.idx.analyze() =20 def scanHeaders(self): @@ -2271,7 +2274,7 @@ class docBuilder: def serialize_function(self, output, name): id =3D self.idx.functions[name] if name =3D=3D debugsym and not quiet: - print "=3D>", id + print("=3D>", id) =20 # NB: this is consumed by a regex in 'getAPIFilenames' in hvsuppor= t.pl output.write(" <%s name=3D'%s' file=3D'%s' module=3D'%s'>\n" % = (id.type, @@ -2312,7 +2315,7 @@ class docBuilder: output.write(" \n" % (param[1], param[0], escape(param[2]))) self.indexString(name, param[2]) except: - print >>sys.stderr, "Exception:", sys.exc_info()[1] + print("Exception:", sys.exc_info()[1], file=3Dsys.stderr) self.warning("Failed to save function %s info: %s" % (name, `i= d.info`)) output.write(" \n" % (id.type)) =20 @@ -2542,7 +2545,7 @@ class docBuilder: def serialize(self): filename =3D "%s/%s-api.xml" % (self.path, self.name) if not quiet: - print "Saving XML description %s" % (filename) + print("Saving XML description %s" % (filename)) output =3D open(filename, "w") output.write('\n') output.write("\n" % self.name) @@ -2578,12 +2581,12 @@ class docBuilder: output.close() =20 if self.errors > 0: - print >>sys.stderr, "apibuild.py: %d error(s) encountered duri= ng generation" % self.errors + print("apibuild.py: %d error(s) encountered during generation"= % self.errors, file=3Dsys.stderr) sys.exit(3) =20 filename =3D "%s/%s-refs.xml" % (self.path, self.name) if not quiet: - print "Saving XML Cross References %s" % (filename) + print("Saving XML Cross References %s" % (filename)) output =3D open(filename, "w") output.write('\n') output.write("\n" % self.name) @@ -2596,7 +2599,7 @@ class app: def warning(self, msg): global warnings warnings =3D warnings + 1 - print msg + print(msg) =20 def rebuild(self, name): if name not in ["libvirt", "libvirt-qemu", "libvirt-lxc", "libvirt= -admin"]: @@ -2609,7 +2612,7 @@ class app: builddir =3D None if glob.glob(srcdir + "/../src/libvirt.c") !=3D [] : if not quiet: - print "Rebuilding API description for %s" % name + print("Rebuilding API description for %s" % name) dirs =3D [srcdir + "/../src", srcdir + "/../src/util", srcdir + "/../include/libvirt"] @@ -2619,7 +2622,7 @@ class app: builder =3D docBuilder(name, srcdir, dirs, []) elif glob.glob("src/libvirt.c") !=3D [] : if not quiet: - print "Rebuilding API description for %s" % name + print("Rebuilding API description for %s" % name) builder =3D docBuilder(name, srcdir, ["src", "src/util", "include/libvirt"], []) diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py index a2b8bef721..d7e68f69b1 100755 --- a/src/esx/esx_vi_generator.py +++ b/src/esx/esx_vi_generator.py @@ -22,6 +22,8 @@ # . # =20 +from __future__ import print_function + import sys import os import os.path @@ -1196,7 +1198,7 @@ class Enum(Type): =20 =20 def report_error(message): - print "error: " + message + print("error: " + message) sys.exit(1) =20 =20 @@ -1321,9 +1323,9 @@ def is_known_type(type): =20 def open_and_print(filename): if filename.startswith("./"): - print " GEN " + filename[2:] + print(" GEN " + filename[2:]) else: - print " GEN " + filename + print(" GEN " + filename) =20 return open(filename, "wb") =20 diff --git a/src/hyperv/hyperv_wmi_generator.py b/src/hyperv/hyperv_wmi_gen= erator.py index b60335e26b..f6e0523f32 100755 --- a/src/hyperv/hyperv_wmi_generator.py +++ b/src/hyperv/hyperv_wmi_generator.py @@ -20,6 +20,8 @@ # . # =20 +from __future__ import print_function + import sys import os import os.path @@ -390,16 +392,16 @@ class Property: =20 def open_and_print(filename): if filename.startswith("./"): - print " GEN " + filename[2:] + print(" GEN " + filename[2:]) else: - print " GEN " + filename + print(" GEN " + filename) =20 return open(filename, "wb") =20 =20 =20 def report_error(message): - print "error: " + message + print("error: " + message) sys.exit(1) =20 =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 05:47:52 2024 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 1521130279835664.1601727512275; Thu, 15 Mar 2018 09:11:19 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8BE2D7FEAD; Thu, 15 Mar 2018 16:11:18 +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 2B9A318796; Thu, 15 Mar 2018 16:11:18 +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 C5018181B9FB; Thu, 15 Mar 2018 16:11:17 +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 w2FGBG0g006835 for ; Thu, 15 Mar 2018 12:11:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id E166C2026E04; Thu, 15 Mar 2018 16:11:16 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 87B452026E03 for ; Thu, 15 Mar 2018 16:11:16 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 15 Mar 2018 17:11:04 +0100 Message-Id: <20180315161110.17925-3-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 2/8] python3: Use the repr() function 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 15 Mar 2018 16:11:18 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This replaces the `` built-in. Signed-off-by: Andrea Bolognani Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/apibuild.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/apibuild.py b/docs/apibuild.py index 9ac6442337..2e8932bb5e 100755 --- a/docs/apibuild.py +++ b/docs/apibuild.py @@ -163,11 +163,11 @@ class identifier: if self.module is not None: r =3D r + " from %s" % (self.module) if self.info is not None: - r =3D r + " " + `self.info` + r =3D r + " " + repr(self.info) if self.extra is not None: - r =3D r + " " + `self.extra` + r =3D r + " " + repr(self.extra) if self.conditionals is not None: - r =3D r + " " + `self.conditionals` + r =3D r + " " + repr(self.conditionals) return r =20 =20 @@ -2316,7 +2316,7 @@ class docBuilder: self.indexString(name, param[2]) except: print("Exception:", sys.exc_info()[1], file=3Dsys.stderr) - self.warning("Failed to save function %s info: %s" % (name, `i= d.info`)) + self.warning("Failed to save function %s info: %s" % (name, re= pr(id.info))) output.write(" \n" % (id.type)) =20 def serialize_exports(self, output, file): --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 05:47:52 2024 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 From nobody Fri May 3 05:47:52 2024 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 1521130284705657.1345792176356; Thu, 15 Mar 2018 09:11:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4441FC01CB63; Thu, 15 Mar 2018 16:11:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 15E5B60244; 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 CF9954CA9C; 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 w2FGBIRN006852 for ; Thu, 15 Mar 2018 12:11:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 200042026E04; Thu, 15 Mar 2018 16:11:18 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BA2892026E03 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:06 +0100 Message-Id: <20180315161110.17925-5-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 4/8] python3: Remove uses of string.*() functions 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 15 Mar 2018 16:11:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" All of these have been replaced with methods. Signed-off-by: Andrea Bolognani Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/apibuild.py | 142 +++++++++++++++++++++++++++------------------------= ---- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/docs/apibuild.py b/docs/apibuild.py index e448e37ace..2097400cd1 100755 --- a/docs/apibuild.py +++ b/docs/apibuild.py @@ -122,11 +122,11 @@ hidden_macros =3D { } =20 def escape(raw): - raw =3D string.replace(raw, '&', '&') - raw =3D string.replace(raw, '<', '<') - raw =3D string.replace(raw, '>', '>') - raw =3D string.replace(raw, "'", ''') - raw =3D string.replace(raw, '"', '"') + raw =3D raw.replace('&', '&') + raw =3D raw.replace('<', '<') + raw =3D raw.replace('>', '>') + raw =3D raw.replace("'", ''') + raw =3D raw.replace('"', '"') return raw =20 def uniq(items): @@ -440,16 +440,16 @@ class CLexer: if not line: return None self.lineno =3D self.lineno + 1 - line =3D string.lstrip(line) - line =3D string.rstrip(line) + line =3D line.lstrip() + line =3D line.rstrip() if line =3D=3D '': continue while line[-1] =3D=3D '\\': line =3D line[:-1] n =3D self.input.readline() self.lineno =3D self.lineno + 1 - n =3D string.lstrip(n) - n =3D string.rstrip(n) + n =3D n.lstrip() + n =3D n.rstrip() if not n: break else: @@ -478,8 +478,8 @@ class CLexer: return None =20 if line[0] =3D=3D '#': - self.tokens =3D map((lambda x: ('preproc', x)), - string.split(line)) + self.tokens =3D list(map((lambda x: ('preproc', x)), + line.split())) =20 # We might have whitespace between the '#' and preproc # macro name, so instead of having a single token element @@ -572,21 +572,21 @@ class CLexer: while i < l: o =3D ord(line[i]) if (o >=3D 97 and o <=3D 122) or (o >=3D 65 and o = <=3D 90) or \ - (o >=3D 48 and o <=3D 57) or string.find( - " \t(){}:;,+-*/%&!|[]=3D><", line[i]) =3D= =3D -1: + (o >=3D 48 and o <=3D 57) or \ + (" \t(){}:;,+-*/%&!|[]=3D><".find(line[i]) =3D= =3D -1): i =3D i + 1 else: break self.tokens.append(('name', line[s:i])) continue - if string.find("(){}:;,[]", line[i]) !=3D -1: + if "(){}:;,[]".find(line[i]) !=3D -1: # if line[i] =3D=3D '(' or line[i] =3D=3D ')' or line[i] = =3D=3D '{' or \ # line[i] =3D=3D '}' or line[i] =3D=3D ':' or line[i] = =3D=3D ';' or \ # line[i] =3D=3D ',' or line[i] =3D=3D '[' or line[i] = =3D=3D ']': self.tokens.append(('sep', line[i])) i =3D i + 1 continue - if string.find("+-*><=3D/%&!|.", line[i]) !=3D -1: + if "+-*><=3D/%&!|.".find(line[i]) !=3D -1: # if line[i] =3D=3D '+' or line[i] =3D=3D '-' or line[i] = =3D=3D '*' or \ # line[i] =3D=3D '>' or line[i] =3D=3D '<' or line[i] = =3D=3D '=3D' or \ # line[i] =3D=3D '/' or line[i] =3D=3D '%' or line[i] = =3D=3D '&' or \ @@ -599,7 +599,7 @@ class CLexer: =20 j =3D i + 1 if j < l and ( - string.find("+-*><=3D/%&!|", line[j]) !=3D -1): + "+-*><=3D/%&!|".find(line[j]) !=3D -1): # line[j] =3D=3D '+' or line[j] =3D=3D '-' or line[j= ] =3D=3D '*' or \ # line[j] =3D=3D '>' or line[j] =3D=3D '<' or line[j= ] =3D=3D '=3D' or \ # line[j] =3D=3D '/' or line[j] =3D=3D '%' or line[j= ] =3D=3D '&' or \ @@ -614,8 +614,8 @@ class CLexer: while i < l: o =3D ord(line[i]) if (o >=3D 97 and o <=3D 122) or (o >=3D 65 and o <=3D= 90) or \ - (o >=3D 48 and o <=3D 57) or ( - string.find(" \t(){}:;,+-*/%&!|[]=3D><", line[i]) = =3D=3D -1): + (o >=3D 48 and o <=3D 57) or \ + (" \t(){}:;,+-*/%&!|[]=3D><".find(line[i]) =3D=3D -= 1): # line[i] !=3D ' ' and line[i] !=3D '\t' and # line[i] !=3D '(' and line[i] !=3D ')' and # line[i] !=3D '{' and line[i] !=3D '}' and @@ -714,7 +714,7 @@ class CParser: =20 def parseTopComment(self, comment): res =3D {} - lines =3D string.split(comment, "\n") + lines =3D comment.split("\n") item =3D None for line in lines: line =3D line.lstrip().lstrip('*').lstrip() @@ -763,10 +763,10 @@ class CParser: self.comment =3D self.comment + com token =3D self.lexer.token() =20 - if string.find(self.comment, "DOC_DISABLE") !=3D -1: + if self.comment.find("DOC_DISABLE") !=3D -1: self.stop_error() =20 - if string.find(self.comment, "DOC_ENABLE") !=3D -1: + if self.comment.find("DOC_ENABLE") !=3D -1: self.start_error() =20 return token @@ -789,7 +789,7 @@ class CParser: if not quiet: self.warning("Missing * in type comment for %s" % (name)) return((args, desc)) - lines =3D string.split(self.comment, '\n') + lines =3D self.comment.split('\n') if lines[0] =3D=3D '*': del lines[0] if lines[0] !=3D "* %s:" % (name): @@ -805,11 +805,11 @@ class CParser: l =3D lines[0] while len(l) > 0 and l[0] =3D=3D '*': l =3D l[1:] - l =3D string.strip(l) + l =3D l.strip() desc =3D desc + " " + l del lines[0] =20 - desc =3D string.strip(desc) + desc =3D desc.strip() =20 if quiet =3D=3D 0: if desc =3D=3D "": @@ -838,7 +838,7 @@ class CParser: if not quiet: self.warning("Missing * in macro comment for %s" % (name)) return((args, desc)) - lines =3D string.split(self.comment, '\n') + lines =3D self.comment.split('\n') if lines[0] =3D=3D '*': del lines[0] if lines[0] !=3D "* %s:" % (name): @@ -852,9 +852,9 @@ class CParser: while len(lines) > 0 and lines[0][0:3] =3D=3D '* @': l =3D lines[0][3:] try: - (arg, desc) =3D string.split(l, ':', 1) - desc=3Dstring.strip(desc) - arg=3Dstring.strip(arg) + (arg, desc) =3D l.split(':', 1) + desc =3D desc.strip() + arg =3D arg.strip() except: if not quiet: self.warning("Misformatted macro comment for %s" % (na= me)) @@ -862,11 +862,11 @@ class CParser: del lines[0] continue del lines[0] - l =3D string.strip(lines[0]) + l =3D lines[0].strip() while len(l) > 2 and l[0:3] !=3D '* @': while l[0] =3D=3D '*': l =3D l[1:] - desc =3D desc + ' ' + string.strip(l) + desc =3D desc + ' ' + l.strip() del lines[0] if len(lines) =3D=3D 0: break @@ -879,11 +879,11 @@ class CParser: l =3D lines[0] while len(l) > 0 and l[0] =3D=3D '*': l =3D l[1:] - l =3D string.strip(l) + l =3D l.strip() desc =3D desc + " " + l del lines[0] =20 - desc =3D string.strip(desc) + desc =3D desc.strip() =20 if quiet =3D=3D 0: if desc =3D=3D "": @@ -918,7 +918,7 @@ class CParser: if not quiet: self.warning("Missing * in function comment for %s" % (nam= e)) return(((ret[0], retdesc), args, desc)) - lines =3D string.split(self.comment, '\n') + lines =3D self.comment.split('\n') if lines[0] =3D=3D '*': del lines[0] if lines[0] !=3D "* %s:" % (name): @@ -933,9 +933,9 @@ class CParser: while len(lines) > 0 and lines[0][0:3] =3D=3D '* @': l =3D lines[0][3:] try: - (arg, desc) =3D string.split(l, ':', 1) - desc=3Dstring.strip(desc) - arg=3Dstring.strip(arg) + (arg, desc) =3D l.split(':', 1) + desc =3D desc.strip() + arg =3D arg.strip() except: if not quiet: self.warning("Misformatted function comment for %s" % = (name)) @@ -943,11 +943,11 @@ class CParser: del lines[0] continue del lines[0] - l =3D string.strip(lines[0]) + l =3D lines[0].strip() while len(l) > 2 and l[0:3] !=3D '* @': while l[0] =3D=3D '*': l =3D l[1:] - desc =3D desc + ' ' + string.strip(l) + desc =3D desc + ' ' + l.strip() del lines[0] if len(lines) =3D=3D 0: break @@ -978,16 +978,16 @@ class CParser: l =3D l[i:] if len(l) >=3D 6 and l[0:7] =3D=3D "Returns": try: - l =3D string.split(l, ' ', 1)[1] + l =3D l.split(' ', 1)[1] except: l =3D "" - retdesc =3D string.strip(l) + retdesc =3D l.strip() del lines[0] while len(lines) > 0: l =3D lines[0] while len(l) > 0 and l[0] =3D=3D '*': l =3D l[1:] - l =3D string.strip(l) + l =3D l.strip() retdesc =3D retdesc + " " + l del lines[0] else: @@ -999,8 +999,8 @@ class CParser: =20 if desc is None: desc =3D "" - retdesc =3D string.strip(retdesc) - desc =3D string.strip(desc) + retdesc =3D retdesc.strip() + desc =3D desc.strip() =20 if quiet =3D=3D 0: # @@ -1046,7 +1046,7 @@ class CParser: lst.append(token[1]) token =3D self.lexer.token() try: - name =3D string.split(name, '(') [0] + name =3D name.split('(') [0] except: pass =20 @@ -1083,7 +1083,7 @@ class CParser: apstr =3D self.lexer.tokens[0][1] try: self.defines.append(apstr) - if string.find(apstr, 'ENABLED') !=3D -1: + if apstr.find('ENABLED') !=3D -1: self.conditionals.append("defined(%s)" % apstr) except: pass @@ -1091,7 +1091,7 @@ class CParser: apstr =3D self.lexer.tokens[0][1] try: self.defines.append(apstr) - if string.find(apstr, 'ENABLED') !=3D -1: + if apstr.find('ENABLED') !=3D -1: self.conditionals.append("!defined(%s)" % apstr) except: pass @@ -1103,17 +1103,17 @@ class CParser: apstr =3D apstr + tok[1] try: self.defines.append(apstr) - if string.find(apstr, 'ENABLED') !=3D -1: + if apstr.find('ENABLED') !=3D -1: self.conditionals.append(apstr) except: pass elif name =3D=3D "#else": if self.conditionals !=3D [] and \ - string.find(self.defines[-1], 'ENABLED') !=3D -1: + self.defines[-1].find('ENABLED') !=3D -1: self.conditionals[-1] =3D "!(%s)" % self.conditionals[-1] elif name =3D=3D "#endif": if self.conditionals !=3D [] and \ - string.find(self.defines[-1], 'ENABLED') !=3D -1: + self.defines[-1].find('ENABLED') !=3D -1: self.conditionals =3D self.conditionals[:-1] self.defines =3D self.defines[:-1] token =3D self.lexer.token() @@ -1181,7 +1181,7 @@ class CParser: name =3D token[1] signature =3D self.signature if signature is not None: - type =3D string.split(type, '(')[0] + type =3D type.split('(')[0] d =3D self.mergeFunctionComment(name, ((type, None), signature), 1) self.index_add(name, self.filename, not self.is_header, @@ -1388,7 +1388,7 @@ class CParser: self.cleanupComment() if name is not None: if self.comment is not None: - comment =3D string.strip(self.comment) + comment =3D self.comment.strip() self.comment =3D None self.enums.append((name, value, comment)) name =3D token[1] @@ -2076,26 +2076,26 @@ class docBuilder: def indexString(self, id, str): if str is None: return - str =3D string.replace(str, "'", ' ') - str =3D string.replace(str, '"', ' ') - str =3D string.replace(str, "/", ' ') - str =3D string.replace(str, '*', ' ') - str =3D string.replace(str, "[", ' ') - str =3D string.replace(str, "]", ' ') - str =3D string.replace(str, "(", ' ') - str =3D string.replace(str, ")", ' ') - str =3D string.replace(str, "<", ' ') - str =3D string.replace(str, '>', ' ') - str =3D string.replace(str, "&", ' ') - str =3D string.replace(str, '#', ' ') - str =3D string.replace(str, ",", ' ') - str =3D string.replace(str, '.', ' ') - str =3D string.replace(str, ';', ' ') - tokens =3D string.split(str) + str =3D str.replace("'", ' ') + str =3D str.replace('"', ' ') + str =3D str.replace("/", ' ') + str =3D str.replace('*', ' ') + str =3D str.replace("[", ' ') + str =3D str.replace("]", ' ') + str =3D str.replace("(", ' ') + str =3D str.replace(")", ' ') + str =3D str.replace("<", ' ') + str =3D str.replace('>', ' ') + str =3D str.replace("&", ' ') + str =3D str.replace('#', ' ') + str =3D str.replace(",", ' ') + str =3D str.replace('.', ' ') + str =3D str.replace(';', ' ') + tokens =3D str.split() for token in tokens: try: c =3D token[0] - if string.find(string.letters, c) < 0: + if string.letters.find(c) < 0: pass elif len(token) < 3: pass @@ -2137,7 +2137,7 @@ class docBuilder: for file in files: skip =3D 1 for incl in self.includes: - if string.find(file, incl) !=3D -1: + if file.find(incl) !=3D -1: skip =3D 0 break if skip =3D=3D 0: @@ -2146,7 +2146,7 @@ class docBuilder: for file in files: skip =3D 1 for incl in self.includes: - if string.find(file, incl) !=3D -1: + if file.find(incl) !=3D -1: skip =3D 0 break if skip =3D=3D 0: @@ -2334,7 +2334,7 @@ class docBuilder: self.warning("Header %s lacks a %s description" % (mod= ule, data)) if 'Description' in dict.info: desc =3D dict.info['Description'] - if string.find(desc, "DEPRECATED") !=3D -1: + if desc.find("DEPRECATED") !=3D -1: output.write(" \n") =20 ids =3D dict.macros.keys() --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 05:47:52 2024 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 1521130287494768.3067496703827; Thu, 15 Mar 2018 09:11:27 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3836C80086; Thu, 15 Mar 2018 16:11:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0E83360BB6; Thu, 15 Mar 2018 16:11:26 +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 CCF594CA9E; Thu, 15 Mar 2018 16:11:25 +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 w2FGBIOb006862 for ; Thu, 15 Mar 2018 12:11:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id B26542026E04; Thu, 15 Mar 2018 16:11:18 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 59C752026E03 for ; Thu, 15 Mar 2018 16:11:18 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 15 Mar 2018 17:11:07 +0100 Message-Id: <20180315161110.17925-6-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 5/8] python3: Call list() explicitly as needed 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 15 Mar 2018 16:11:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" For list concatenation to work, the value returned by the keys() method must be converted to a list first. Signed-off-by: Andrea Bolognani Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/apibuild.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/apibuild.py b/docs/apibuild.py index 2097400cd1..bc6c609431 100755 --- a/docs/apibuild.py +++ b/docs/apibuild.py @@ -2049,13 +2049,13 @@ class docBuilder: self.path =3D path self.directories =3D directories if name =3D=3D "libvirt": - self.includes =3D includes + included_files.keys() + self.includes =3D includes + list(included_files.keys()) elif name =3D=3D "libvirt-qemu": - self.includes =3D includes + qemu_included_files.keys() + self.includes =3D includes + list(qemu_included_files.keys()) elif name =3D=3D "libvirt-lxc": - self.includes =3D includes + lxc_included_files.keys() + self.includes =3D includes + list(lxc_included_files.keys()) elif name =3D=3D "libvirt-admin": - self.includes =3D includes + admin_included_files.keys() + self.includes =3D includes + list(admin_included_files.keys()) self.modules =3D {} self.headers =3D {} self.idx =3D index() @@ -2383,9 +2383,12 @@ class docBuilder: module =3D self.modulename_file(file) output.write(" \n" % (module)) dict =3D self.headers[file] - ids =3D uniq(dict.functions.keys() + dict.variables.keys() + \ - dict.macros.keys() + dict.typedefs.keys() + \ - dict.structs.keys() + dict.enums.keys()) + ids =3D uniq(list(dict.functions.keys()) + \ + list(dict.variables.keys()) + \ + list(dict.macros.keys()) + \ + list(dict.typedefs.keys()) + \ + list(dict.structs.keys()) + \ + list(dict.enums.keys())) ids.sort() for id in ids: output.write(" \n" % (id)) --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 05:47:52 2024 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 1521130288317450.3543134841698; Thu, 15 Mar 2018 09:11:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A1C1F2F30C0; Thu, 15 Mar 2018 16:11:26 +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 7196B53B22; Thu, 15 Mar 2018 16:11:26 +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 2D001181BA06; Thu, 15 Mar 2018 16:11:26 +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 w2FGBJav006888 for ; Thu, 15 Mar 2018 12:11:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 510E12026E04; Thu, 15 Mar 2018 16:11:19 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ECEB82026E03 for ; Thu, 15 Mar 2018 16:11:18 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 15 Mar 2018 17:11:08 +0100 Message-Id: <20180315161110.17925-7-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 6/8] python3: Replace keys() + sort() with sorted() 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 15 Mar 2018 16:11:27 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The keys() method no longer returns a list, so converting the return value would be necessary before calling sort() on it; alternatively, we can just call sorted(), which returns a sorted list. Signed-off-by: Andrea Bolognani Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/apibuild.py | 60 +++++++++++++---------------------= ---- src/esx/esx_vi_generator.py | 15 ++++------ src/hyperv/hyperv_wmi_generator.py | 3 +- 3 files changed, 26 insertions(+), 52 deletions(-) diff --git a/docs/apibuild.py b/docs/apibuild.py index bc6c609431..67b7eed1e6 100755 --- a/docs/apibuild.py +++ b/docs/apibuild.py @@ -133,8 +133,7 @@ def uniq(items): d =3D {} for item in items: d[item]=3D1 - k =3D d.keys() - k.sort() + k =3D sorted(d.keys()) return k =20 class identifier: @@ -2337,8 +2336,7 @@ class docBuilder: if desc.find("DEPRECATED") !=3D -1: output.write(" \n") =20 - ids =3D dict.macros.keys() - ids.sort() + ids =3D sorted(dict.macros.keys()) for id in uniq(ids): # Macros are sometime used to masquerade other types. if id in dict.functions: @@ -2354,31 +2352,25 @@ class docBuilder: if id in dict.enums: continue output.write(" \n" = % (id)) - ids =3D dict.enums.keys() - ids.sort() + ids =3D sorted(dict.enums.keys()) for id in uniq(ids): output.write(" \n" %= (id)) - ids =3D dict.typedefs.keys() - ids.sort() + ids =3D sorted(dict.typedefs.keys()) for id in uniq(ids): output.write(" \n= " % (id)) - ids =3D dict.structs.keys() - ids.sort() + ids =3D sorted(dict.structs.keys()) for id in uniq(ids): output.write(" \n"= % (id)) - ids =3D dict.variables.keys() - ids.sort() + ids =3D sorted(dict.variables.keys()) for id in uniq(ids): output.write(" \= n" % (id)) - ids =3D dict.functions.keys() - ids.sort() + ids =3D sorted(dict.functions.keys()) for id in uniq(ids): output.write(" \= n" % (id)) output.write(" \n") =20 def serialize_xrefs_files(self, output): - headers =3D self.headers.keys() - headers.sort() + headers =3D sorted(self.headers.keys()) for file in headers: module =3D self.modulename_file(file) output.write(" \n" % (module)) @@ -2410,8 +2402,7 @@ class docBuilder: funcs[param[0]] =3D [name] except: pass - typ =3D funcs.keys() - typ.sort() + typ =3D sorted(funcs.keys()) for type in typ: if type =3D=3D '' or type =3D=3D 'void' or type =3D=3D "int" o= r \ type =3D=3D "char *" or type =3D=3D "const char *" : @@ -2440,23 +2431,20 @@ class docBuilder: funcs[ret[0]] =3D [name] except: pass - typ =3D funcs.keys() - typ.sort() + typ =3D sorted(funcs.keys()) for type in typ: if type =3D=3D '' or type =3D=3D 'void' or type =3D=3D "int" o= r \ type =3D=3D "char *" or type =3D=3D "const char *" : continue output.write(" \n" % (type)) - ids =3D funcs[type] - ids.sort() + ids =3D sorted(funcs[type]) for id in ids: output.write(" \n" % (id)) output.write(" \n") =20 def serialize_xrefs_alpha(self, output): letter =3D None - ids =3D self.idx.identifiers.keys() - ids.sort() + ids =3D sorted(self.idx.identifiers.keys()) for id in ids: if id[0] !=3D letter: if letter is not None: @@ -2468,8 +2456,7 @@ class docBuilder: output.write(" \n") =20 def serialize_xrefs_references(self, output): - typ =3D self.idx.identifiers.keys() - typ.sort() + typ =3D sorted(self.idx.identifiers.keys()) for id in typ: idf =3D self.idx.identifiers[id] module =3D idf.header @@ -2480,8 +2467,7 @@ class docBuilder: =20 def serialize_xrefs_index(self, output): index =3D self.xref - typ =3D index.keys() - typ.sort() + typ =3D sorted(index.keys()) letter =3D None count =3D 0 chunk =3D 0 @@ -2553,30 +2539,24 @@ class docBuilder: output.write('\n') output.write("\n" % self.name) output.write(" \n") - headers =3D self.headers.keys() - headers.sort() + headers =3D sorted(self.headers.keys()) for file in headers: self.serialize_exports(output, file) output.write(" \n") output.write(" \n") - macros =3D self.idx.macros.keys() - macros.sort() + macros =3D sorted(self.idx.macros.keys()) for macro in macros: self.serialize_macro(output, macro) - enums =3D self.idx.enums.keys() - enums.sort() + enums =3D sorted(self.idx.enums.keys()) for enum in enums: self.serialize_enum(output, enum) - typedefs =3D self.idx.typedefs.keys() - typedefs.sort() + typedefs =3D sorted(self.idx.typedefs.keys()) for typedef in typedefs: self.serialize_typedef(output, typedef) - variables =3D self.idx.variables.keys() - variables.sort() + variables =3D sorted(self.idx.variables.keys()) for variable in variables: self.serialize_variable(output, variable) - functions =3D self.idx.functions.keys() - functions.sort() + functions =3D sorted(self.idx.functions.keys()) for function in functions: self.serialize_function(output, function) output.write(" \n") diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py index d7e68f69b1..2f3c88812d 100755 --- a/src/esx/esx_vi_generator.py +++ b/src/esx/esx_vi_generator.py @@ -1704,8 +1704,7 @@ types_typedef.write(separator + " * VI Enums\n" + " */\n\n") =20 -names =3D enums_by_name.keys() -names.sort() +names =3D sorted(enums_by_name.keys()) =20 for name in names: types_typedef.write(enums_by_name[name].generate_typedef()) @@ -1726,8 +1725,7 @@ types_typeenum.write("\n") types_typetostring.write("\n") types_typefromstring.write("\n") =20 -names =3D objects_by_name.keys() -names.sort() +names =3D sorted(objects_by_name.keys()) =20 for name in names: types_typedef.write(objects_by_name[name].generate_typedef()) @@ -1748,8 +1746,7 @@ types_typeenum.write("\n") types_typetostring.write("\n") types_typefromstring.write("\n") =20 -names =3D managed_objects_by_name.keys() -names.sort() +names =3D sorted(managed_objects_by_name.keys()) =20 for name in names: types_typedef.write(managed_objects_by_name[name].generate_typedef()) @@ -1762,8 +1759,7 @@ for name in names: =20 =20 # output methods -names =3D methods_by_name.keys() -names.sort() +names =3D sorted(methods_by_name.keys()) =20 for name in names: methods_header.write(methods_by_name[name].generate_header()) @@ -1782,8 +1778,7 @@ for name in names: =20 =20 # output helpers -names =3D managed_objects_by_name.keys() -names.sort() +names =3D sorted(managed_objects_by_name.keys()) =20 for name in names: helpers_header.write(managed_objects_by_name[name].generate_helper_hea= der()) diff --git a/src/hyperv/hyperv_wmi_generator.py b/src/hyperv/hyperv_wmi_gen= erator.py index f6e0523f32..1cf16a7836 100755 --- a/src/hyperv/hyperv_wmi_generator.py +++ b/src/hyperv/hyperv_wmi_generator.py @@ -501,8 +501,7 @@ def main(): classes_header.write(notice) classes_source.write(notice) =20 - names =3D wmi_classes_by_name.keys() - names.sort() + names =3D sorted(wmi_classes_by_name.keys()) =20 for name in names: cls =3D wmi_classes_by_name[name] --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 05:47:52 2024 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 1521130292649865.907906144555; Thu, 15 Mar 2018 09:11:32 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D9C207E9D9; Thu, 15 Mar 2018 16:11:29 +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 A7FC05D9CD; Thu, 15 Mar 2018 16:11:29 +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 5C538180BAD5; Thu, 15 Mar 2018 16:11:29 +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 w2FGBKCn006924 for ; Thu, 15 Mar 2018 12:11:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id E400C2026E04; Thu, 15 Mar 2018 16:11:19 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8B20A2026E03 for ; Thu, 15 Mar 2018 16:11:19 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 15 Mar 2018 17:11:09 +0100 Message-Id: <20180315161110.17925-8-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] [RFC PATCH v2 7/8] python3: Open files in text instead of binary mode 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 15 Mar 2018 16:11:30 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We use text operations on the contents after reading them. Signed-off-by: Andrea Bolognani Reviewed-by: Daniel P. Berrang=C3=A9 --- This seems reasonable and works correctly AFAICT, but I'm not 100% confident it's the right way to address the issue. src/esx/esx_vi_generator.py | 4 ++-- src/hyperv/hyperv_wmi_generator.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py index 2f3c88812d..6ce017d794 100755 --- a/src/esx/esx_vi_generator.py +++ b/src/esx/esx_vi_generator.py @@ -1327,7 +1327,7 @@ def open_and_print(filename): else: print(" GEN " + filename) =20 - return open(filename, "wb") + return open(filename, "wt") =20 =20 =20 @@ -1435,7 +1435,7 @@ block =3D None =20 =20 # parse input file -for line in file(input_filename, "rb").readlines(): +for line in open(input_filename, "rt").readlines(): number +=3D 1 =20 if "#" in line: diff --git a/src/hyperv/hyperv_wmi_generator.py b/src/hyperv/hyperv_wmi_gen= erator.py index 1cf16a7836..7dc11ba905 100755 --- a/src/hyperv/hyperv_wmi_generator.py +++ b/src/hyperv/hyperv_wmi_generator.py @@ -396,7 +396,7 @@ def open_and_print(filename): else: print(" GEN " + filename) =20 - return open(filename, "wb") + return open(filename, "wt") =20 =20 =20 @@ -468,7 +468,7 @@ def main(): number =3D 0 block =3D None =20 - for line in file(input_filename, "rb").readlines(): + for line in open(input_filename, "rt").readlines(): number +=3D 1 =20 if "#" in line: --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 05:47:52 2024 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 15211302948581015.4142771552878; Thu, 15 Mar 2018 09:11:34 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5A5D77E9E1; Thu, 15 Mar 2018 16:11:33 +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 22442600C9; Thu, 15 Mar 2018 16:11:33 +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 C3E74180BAD8; Thu, 15 Mar 2018 16:11:32 +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 w2FGBKRv007012 for ; Thu, 15 Mar 2018 12:11:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8234B2026E04; Thu, 15 Mar 2018 16:11:20 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 29DAF2026E03 for ; Thu, 15 Mar 2018 16:11:20 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 15 Mar 2018 17:11:10 +0100 Message-Id: <20180315161110.17925-9-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] [RFC PATCH v2 8/8] python3: Fix sort function 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 15 Mar 2018 16:11:33 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This deals with cls.version possibly being None. Signed-off-by: Andrea Bolognani Reviewed-by: Daniel P. Berrang=C3=A9 --- Really not sure about this one. The script runs all the way to the end after applying it, so there's that I guess. src/hyperv/hyperv_wmi_generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hyperv/hyperv_wmi_generator.py b/src/hyperv/hyperv_wmi_gen= erator.py index 7dc11ba905..d548102117 100755 --- a/src/hyperv/hyperv_wmi_generator.py +++ b/src/hyperv/hyperv_wmi_generator.py @@ -59,7 +59,7 @@ class WmiClass: """ # sort vesioned classes by version in case input file did not have= them # in order - self.versions =3D sorted(self.versions, key=3Dlambda cls: cls.vers= ion) + self.versions =3D sorted(self.versions, key=3Dlambda cls: cls.vers= ion or "") =20 # if there's more than one verion make sure first one has name suf= fixed # because we'll generate "common" memeber and will be the "base" n= ame --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list