From nobody Wed May 14 19:44:07 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 152096658897627.565972278811614; Tue, 13 Mar 2018 11:43:08 -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 BD149C05CDE4; Tue, 13 Mar 2018 18:43:07 +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 92E57197E2; Tue, 13 Mar 2018 18:43:07 +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 58882180BAE6; Tue, 13 Mar 2018 18:43:07 +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 w2DIgtYY020534 for ; Tue, 13 Mar 2018 14:42:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id E6605202322A; Tue, 13 Mar 2018 18:42:54 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8E1D4202322B for ; Tue, 13 Mar 2018 18:42:54 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Tue, 13 Mar 2018 19:42:46 +0100 Message-Id: <20180313184247.29212-5-abologna@redhat.com> In-Reply-To: <20180313184247.29212-1-abologna@redhat.com> References: <20180313184247.29212-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 4/5] hyperv: Port hyperv_wmi_generator.py to Python 3 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.31]); Tue, 13 Mar 2018 18:43:08 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" A few tweaks needed. The generated files are bit by bit identical to those produced before when the script is invoked using Python 2, but not when Python 3 is used, in which case members of the various structs are shuffled around. Signed-off-by: Andrea Bolognani --- src/hyperv/hyperv_wmi_generator.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/hyperv/hyperv_wmi_generator.py b/src/hyperv/hyperv_wmi_gen= erator.py index b60335e26b..d548102117 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 @@ -57,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 @@ -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") + return open(filename, "wt") =20 =20 =20 def report_error(message): - print "error: " + message + print("error: " + message) sys.exit(1) =20 =20 @@ -466,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: @@ -499,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