From nobody Fri Apr 19 23:41:13 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 1520966577816834.5667505033937; Tue, 13 Mar 2018 11:42:57 -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 007C25BEC9; Tue, 13 Mar 2018 18:42:56 +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 7097E5D9C6; Tue, 13 Mar 2018 18:42:55 +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 E01034CABE; Tue, 13 Mar 2018 18:42:54 +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 w2DIgraK020512 for ; Tue, 13 Mar 2018 14:42:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 238722026E04; Tue, 13 Mar 2018 18:42:53 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BF1682026DFD for ; Tue, 13 Mar 2018 18:42:52 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Tue, 13 Mar 2018 19:42:43 +0100 Message-Id: <20180313184247.29212-2-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] [PATCH 1/5] NEWS: Move generation to the docs/ directory 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.38]); Tue, 13 Mar 2018 18:42:56 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" All the input files and scripts used to generate the release notes live in the docs/ directory, so it makes sense for the output file to be created there as well. A symbolic link is created in the top-level source directory to comply with GNU standards as well as user expectations. Signed-off-by: Andrea Bolognani --- .gitignore | 1 + Makefile.am | 24 +++++------------------- docs/Makefile.am | 24 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 2ca7d9776e..234993cdcb 100644 --- a/.gitignore +++ b/.gitignore @@ -59,6 +59,7 @@ /configure /configure.lineno /conftest.* +/docs/NEWS /docs/aclperms.htmlinc /docs/apibuild.py.stamp /docs/devhelp/libvirt.devhelp diff --git a/Makefile.am b/Makefile.am index 81c7f52d9c..93d1351656 100644 --- a/Makefile.am +++ b/Makefile.am @@ -46,25 +46,11 @@ EXTRA_DIST =3D \ pkgconfigdir =3D $(libdir)/pkgconfig pkgconfig_DATA =3D libvirt.pc libvirt-qemu.pc libvirt-lxc.pc libvirt-admin= .pc =20 -NEWS: \ - $(srcdir)/docs/news.xml \ - $(srcdir)/docs/news-ascii.xsl \ - $(srcdir)/docs/reformat-news.py - $(AM_V_GEN) \ - if [ -x $(XSLTPROC) ]; then \ - $(XSLTPROC) --nonet \ - $(srcdir)/docs/news-ascii.xsl \ - $(srcdir)/docs/news.xml \ - >$@-tmp \ - || { rm -f $@-tmp; exit 1; }; \ - $(srcdir)/docs/reformat-news.py $@-tmp >$@ \ - || { rm -f $@-tmp; exit 1; }; \ - rm -f $@-tmp; \ - fi -EXTRA_DIST +=3D \ - $(srcdir)/docs/news.xml \ - $(srcdir)/docs/news-ascii.xsl \ - $(srcdir)/docs/reformat-news.py +NEWS: $(builddir)/docs/NEWS + $(LN_S) -f $< $@ + +$(builddir)/docs/NEWS: + $(MAKE) $(AM_MAKEFLAGS) -C docs NEWS =20 rpm: clean @(unset CDPATH ; $(MAKE) dist && rpmbuild -ta $(distdir).tar.xz) diff --git a/docs/Makefile.am b/docs/Makefile.am index 9620587a77..3259799e4f 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -197,6 +197,8 @@ MAINTAINERCLEANFILES =3D \ $(addprefix $(srcdir)/,$(dot_php)) \ $(srcdir)/hvsupport.html.in $(srcdir)/aclperms.htmlinc =20 +CLEANFILES =3D + timestamp=3D"$(shell if test -n "$$SOURCE_DATE_EPOCH"; \ then \ date -u --date=3D"@$$SOURCE_DATE_EPOCH"; \ @@ -244,6 +246,28 @@ EXTRA_DIST +=3D \ MAINTAINERCLEANFILES +=3D \ $(srcdir)/news.html.in =20 +NEWS: \ + $(srcdir)/news.xml \ + $(srcdir)/news-ascii.xsl \ + $(srcdir)/reformat-news.py + $(AM_V_GEN) \ + if [ -x $(XSLTPROC) ]; then \ + $(XSLTPROC) --nonet \ + $(srcdir)/news-ascii.xsl \ + $(srcdir)/news.xml \ + >$@-tmp \ + || { rm -f $@-tmp; exit 1; }; \ + $(srcdir)/reformat-news.py $@-tmp >$@ \ + || { rm -f $@-tmp; exit 1; }; \ + rm -f $@-tmp; \ + fi +EXTRA_DIST +=3D \ + $(srcdir)/news.xml \ + $(srcdir)/news-ascii.xsl \ + $(srcdir)/reformat-news.py +CLEANFILES +=3D \ + NEWS + %.png: %.fig convert -rotate 90 $< $@ =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 19 23:41:13 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 1520966723871208.8332656521751; Tue, 13 Mar 2018 11:45:23 -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 5CF003C42; Tue, 13 Mar 2018 18:45:22 +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 1EE689658C; Tue, 13 Mar 2018 18:45:22 +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 340F8181BA08; Tue, 13 Mar 2018 18:45:21 +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 w2DIgrSh020518 for ; Tue, 13 Mar 2018 14:42:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id B60D52026E04; Tue, 13 Mar 2018 18:42:53 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5D9C42026DFD for ; Tue, 13 Mar 2018 18:42:53 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Tue, 13 Mar 2018 19:42:44 +0100 Message-Id: <20180313184247.29212-3-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] [PATCH 2/5] docs: Call reformat-news.py with $(PYTHON) 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.30]); Tue, 13 Mar 2018 18:45:22 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This is the only Python script which we invoke directly, which works pretty fine in general but becomes a problem if the user has explicitly overridden Python binary detection at configure time. Signed-off-by: Andrea Bolognani Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Makefile.am b/docs/Makefile.am index 3259799e4f..6435c4dde6 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -257,7 +257,7 @@ NEWS: \ $(srcdir)/news.xml \ >$@-tmp \ || { rm -f $@-tmp; exit 1; }; \ - $(srcdir)/reformat-news.py $@-tmp >$@ \ + $(PYTHON) $(srcdir)/reformat-news.py $@-tmp >$@ \ || { rm -f $@-tmp; exit 1; }; \ rm -f $@-tmp; \ fi --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 19 23:41:13 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 1520966729574128.02306617518457; Tue, 13 Mar 2018 11:45:29 -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 50CFB68D4; Tue, 13 Mar 2018 18:45:28 +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 190AF60BEB; Tue, 13 Mar 2018 18:45:28 +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 CC887180215E; Tue, 13 Mar 2018 18:45:27 +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 w2DIgskK020529 for ; Tue, 13 Mar 2018 14:42:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 54881202322A; 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 EFF962024CAB for ; Tue, 13 Mar 2018 18:42:53 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Tue, 13 Mar 2018 19:42:45 +0100 Message-Id: <20180313184247.29212-4-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 3/5] esx: Port esx_vi_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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 13 Mar 2018 18:45:28 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Very few tweaks needed. The generated files are bit by bit identical to those produced before, regardless of whether the script is invoked using Python 2 or Python 3. Signed-off-by: Andrea Bolognani --- src/esx/esx_vi_generator.py | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py index a2b8bef721..176db8449d 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,11 +1323,11 @@ 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") + return open(filename, "wt") =20 =20 =20 @@ -1433,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: @@ -1702,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()) @@ -1724,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()) @@ -1746,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()) @@ -1760,15 +1759,13 @@ 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()) methods_source.write(methods_by_name[name].generate_source()) =20 -names =3D list(autobind_names) -names.sort() +names =3D sorted(list(autobind_names)) =20 for name in names: string =3D aligned("#define ESX_VI__METHOD__PARAMETER__THIS__%s " % na= me, "\\\n", 78) @@ -1780,8 +1777,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()) --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 19 23:41:13 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 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 From nobody Fri Apr 19 23:41:13 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 1520966594320199.07636599784053; Tue, 13 Mar 2018 11:43:14 -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 0D26B85546; Tue, 13 Mar 2018 18:43:12 +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 C14465F729; Tue, 13 Mar 2018 18:43:11 +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 75E47181BA06; Tue, 13 Mar 2018 18:43:11 +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 w2DIgurn020549 for ; Tue, 13 Mar 2018 14:42:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 20F1C202322A; Tue, 13 Mar 2018 18:42:56 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2C708202322B for ; Tue, 13 Mar 2018 18:42:55 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Tue, 13 Mar 2018 19:42:47 +0100 Message-Id: <20180313184247.29212-6-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 5/5] docs: Port apibuild.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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 13 Mar 2018 18:43:13 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" A lot of tweaks needed. The generated files are bit by bit identical to those produced before when the script is invoked using Python 2, but using Python 3 results in some errors being reported and the build step to be considered failed. The output files are mostly the same, except , and are missing in *-api.xml files and are missing from *-refs.xml files. Signed-off-by: Andrea Bolognani --- docs/apibuild.py | 379 ++++++++++++++++++++++++++-------------------------= ---- 1 file changed, 181 insertions(+), 198 deletions(-) diff --git a/docs/apibuild.py b/docs/apibuild.py index a788086a65..2209b4b942 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 @@ -119,19 +122,18 @@ 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): 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: @@ -150,8 +152,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) @@ -160,11 +162,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 @@ -210,8 +212,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 +245,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 +265,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 +306,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 @@ -314,9 +316,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: @@ -327,30 +329,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): - print "union %s from %s redeclared in %s" % ( - id, self.unions[id].header, idx.unions[id].header) + 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: @@ -361,20 +363,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: @@ -383,7 +385,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: @@ -394,8 +396,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 +409,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): @@ -437,16 +439,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: @@ -460,9 +462,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 []: @@ -475,8 +477,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 @@ -569,21 +571,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 \ @@ -596,7 +598,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 \ @@ -611,8 +613,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 @@ -691,27 +693,27 @@ 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): 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() @@ -722,7 +724,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 @@ -760,10 +762,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 @@ -786,7 +788,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): @@ -802,11 +804,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 "": @@ -821,7 +823,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 [] @@ -835,7 +837,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): @@ -849,9 +851,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)) @@ -859,11 +861,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 @@ -876,11 +878,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 "": @@ -900,7 +902,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 @@ -915,7 +917,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): @@ -930,9 +932,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)) @@ -940,11 +942,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 @@ -975,16 +977,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: @@ -996,8 +998,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: # @@ -1018,7 +1020,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() @@ -1043,7 +1045,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 @@ -1080,7 +1082,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 @@ -1088,7 +1090,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 @@ -1100,17 +1102,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() @@ -1146,7 +1148,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: @@ -1156,7 +1158,7 @@ class CParser: continue else: if debug: - print "=3D> ", token + print("=3D> ", token) return token return None =20 @@ -1178,7 +1180,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, @@ -1267,7 +1269,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 +1308,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 +1324,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 +1358,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 # @@ -1385,7 +1387,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] @@ -1914,7 +1916,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 +1926,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 +2027,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': @@ -2046,13 +2048,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() @@ -2064,35 +2066,35 @@ 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: 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 @@ -2101,7 +2103,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] @@ -2110,7 +2112,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): @@ -2134,7 +2136,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: @@ -2143,7 +2145,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: @@ -2225,7 +2227,7 @@ class docBuilder: output.write(" \n") @@ -2271,7 +2273,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, @@ -2294,7 +2296,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" % ( @@ -2304,7 +2306,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)) @@ -2312,8 +2314,8 @@ 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] - self.warning("Failed to save function %s info: %s" % (name, `i= d.info`)) + print("Exception:", sys.exc_info()[1], file=3Dsys.stderr) + 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): @@ -2329,61 +2331,56 @@ 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: + 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 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() - 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)) 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.sort() + ids =3D sorted(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()))) for id in ids: output.write(" \n" % (id)) output.write(" \n") @@ -2398,21 +2395,19 @@ 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] 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]) pid =3D '' # not sure why we have dups, but get rid of them! for id in ids: if id !=3D pid: @@ -2428,29 +2423,26 @@ 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] 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: @@ -2462,8 +2454,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 @@ -2474,8 +2465,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 @@ -2498,8 +2488,7 @@ class docBuilder: letter =3D id[0] output.write(" \n" % (letter)) output.write(" \n" % (id)) - tokens =3D index[id] - tokens.sort() + tokens =3D sorted(index[id]) tok =3D None for token in tokens: if tok =3D=3D token: @@ -2542,35 +2531,29 @@ 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) 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") @@ -2578,12 +2561,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 +2579,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 +2592,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 +2602,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"], []) --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list