From nobody Wed May 14 23:58:52 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 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