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 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