From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.126; helo=mga18.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 82942210DC1D1 for ; Thu, 21 Jun 2018 05:40:33 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jun 2018 05:40:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,251,1526367600"; d="scan'208";a="209975285" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga004.jf.intel.com with ESMTP; 21 Jun 2018 05:40:33 -0700 Received: from fmsmsx123.amr.corp.intel.com (10.18.125.38) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 21 Jun 2018 05:40:32 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx123.amr.corp.intel.com (10.18.125.38) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 21 Jun 2018 05:40:32 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.51]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.116]) with mapi id 14.03.0319.002; Thu, 21 Jun 2018 20:40:29 +0800 From: "Zhu, Yonghong" To: Gary Lin , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [PATCH v3 05/20] BaseTools: Use the python3-range functions Thread-Index: AQHUCRqL/gFbxeh/EUaRJfTj+Ai0+aRqph8w Date: Thu, 21 Jun 2018 12:40:29 +0000 Message-ID: References: <20180621044346.28495-1-glin@suse.com> <20180621044346.28495-6-glin@suse.com> In-Reply-To: <20180621044346.28495-6-glin@suse.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v3 05/20] BaseTools: Use the python3-range functions X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2018 12:40:33 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Gary, Python 2.7 doesn't have the module builtins, if we apply this patch now, it= will cause build failure on Python 2.7. Best Regards, Zhu Yonghong -----Original Message----- From: Gary Lin [mailto:glin@suse.com]=20 Sent: Thursday, June 21, 2018 12:44 PM To: edk2-devel@lists.01.org Cc: Zhu, Yonghong ; Gao, Liming Subject: [PATCH v3 05/20] BaseTools: Use the python3-range functions Replace xrange() and range() with the newer range() function Based on "futu= rize -f libfuturize.fixes.fix_xrange_with_import" Contributed-under: TianoCore Contribution Agreement 1.1 Cc: Yonghong Zhu Cc: Liming Gao Signed-off-by: Gary Lin --- BaseTools/Scripts/BinToPcd.py = | 3 ++- BaseTools/Scripts/ConvertMasmToNasm.py = | 1 + BaseTools/Scripts/FormatDosFiles.py = | 3 ++- BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py = | 1 + BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibin= ary.py | 1 + BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py= | 1 + BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/doxyg= engen.py | 3 ++- BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/doxyg= engen_spec.py | 3 ++- BaseTools/Scripts/PatchCheck.py = | 5 +++-- BaseTools/Source/Python/AutoGen/AutoGen.py = | 1 + BaseTools/Source/Python/AutoGen/BuildEngine.py = | 1 + BaseTools/Source/Python/AutoGen/GenC.py = | 1 + BaseTools/Source/Python/AutoGen/GenPcdDb.py = | 23 ++++++++++---------- BaseTools/Source/Python/AutoGen/GenVar.py = | 3 ++- BaseTools/Source/Python/AutoGen/InfSectionParser.py = | 1 + BaseTools/Source/Python/AutoGen/StrGather.py = | 1 + BaseTools/Source/Python/AutoGen/UniClassObject.py = | 1 + BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py = | 1 + BaseTools/Source/Python/BPDG/GenVpd.py = | 7 +++--- BaseTools/Source/Python/Common/Expression.py = | 1 + BaseTools/Source/Python/Common/Misc.py = | 3 ++- BaseTools/Source/Python/Common/Parsing.py = | 1 + BaseTools/Source/Python/Common/RangeExpression.py = | 1 + BaseTools/Source/Python/Common/StringUtils.py = | 1 + BaseTools/Source/Python/Common/ToolDefClassObject.py = | 1 + BaseTools/Source/Python/Ecc/Check.py = | 1 + BaseTools/Source/Python/Ecc/MetaDataParser.py = | 3 ++- BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py = | 1 + BaseTools/Source/Python/Eot/Eot.py = | 1 + BaseTools/Source/Python/Eot/InfParserLite.py = | 1 + BaseTools/Source/Python/GenFds/AprioriSection.py = | 1 + BaseTools/Source/Python/GenFds/FfsFileStatement.py = | 1 + BaseTools/Source/Python/GenFds/Fv.py = | 1 + BaseTools/Source/Python/GenFds/GenFds.py = | 1 + BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py = | 1 + BaseTools/Source/Python/GenFds/Region.py = | 3 ++- BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py = | 1 + BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py = | 3 ++- BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py = | 3 ++- BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py = | 3 ++- BaseTools/Source/Python/Trim/Trim.py = | 1 + BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py = | 5 +++-- BaseTools/Source/Python/UPT/Library/CommentParsing.py = | 3 ++- BaseTools/Source/Python/UPT/Library/Misc.py = | 5 +++-- BaseTools/Source/Python/UPT/Library/Parsing.py = | 3 ++- BaseTools/Source/Python/UPT/Library/StringUtils.py = | 1 + BaseTools/Source/Python/UPT/Library/UniClassObject.py = | 3 ++- BaseTools/Source/Python/UPT/Parser/DecParserMisc.py = | 1 + BaseTools/Source/Python/UPT/Parser/InfSectionParser.py = | 3 ++- BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py = | 1 + BaseTools/Source/Python/UPT/UPT.py = | 1 + BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py = | 1 + BaseTools/Source/Python/UPT/Xml/IniToXml.py = | 1 + BaseTools/Source/Python/UPT/Xml/XmlParser.py = | 1 + BaseTools/Source/Python/UPT/Xml/XmlParserMisc.py = | 3 ++- BaseTools/Source/Python/Workspace/DscBuildData.py = | 1 + BaseTools/Source/Python/Workspace/InfBuildData.py = | 1 + BaseTools/Source/Python/Workspace/MetaFileParser.py = | 1 + BaseTools/Tests/TestTools.py = | 3 ++- BaseTools/Tests/TianoCompress.py = | 1 + BaseTools/gcc/mingw-gcc-build.py = | 1 + 61 files changed, 98 insertions(+), 37 deletions(-) diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.py = index 10b5043325cc..88c46c35aa33 100644 --- a/BaseTools/Scripts/BinToPcd.py +++ b/BaseTools/Scripts/BinToPcd.py @@ -16,6 +16,7 @@ BinToPcd ''' from __future__ import print_function =20 +from builtins import range import sys import argparse import re @@ -100,7 +101,7 @@ if __name__ =3D=3D '__main__': help =3D "Increase output messages") parser.add_argument ("-q", "--quiet", dest =3D 'Quiet', action =3D "st= ore_true", help =3D "Reduce output messages") - parser.add_argument ("--debug", dest =3D 'Debug', type =3D int, metava= r =3D '[0-9]', choices =3D range (0, 10), default =3D 0, + parser.add_argument ("--debug", dest =3D 'Debug', type =3D int, metava= r=20 + =3D '[0-9]', choices =3D list(range(0, 10)), default =3D 0, help =3D "Set debug level") =20 # diff --git a/BaseTools/Scripts/ConvertMasmToNasm.py b/BaseTools/Scripts/Con= vertMasmToNasm.py index 5b83724b3124..e7b5b096fccc 100755 --- a/BaseTools/Scripts/ConvertMasmToNasm.py +++ b/BaseTools/Scripts/ConvertMasmToNasm.py @@ -17,6 +17,7 @@ from __future__ import print_function # # Import Module= s # +from builtins import range import argparse import io import os.path diff --git a/BaseTools/Scripts/FormatDosFiles.py b/BaseTools/Scripts/Format= DosFiles.py index 3b16af5a4413..ce9d829ee430 100644 --- a/BaseTools/Scripts/FormatDosFiles.py +++ b/BaseTools/Scripts/FormatDosFiles.py @@ -17,6 +17,7 @@ # Import Modules # from __future__ import print_function +from builtins import range import argparse import os import os.path @@ -75,7 +76,7 @@ if __name__ =3D=3D "__main__": help=3D'increase output messages') parser.add_argument('-q', '--quiet', dest=3D'Quiet', action=3D'store_t= rue', help=3D'reduce output messages') - parser.add_argument('--debug', dest=3D'Debug', type=3Dint, metavar=3D'= [0-9]', choices=3Drange(0, 10), default=3D0, + parser.add_argument('--debug', dest=3D'Debug', type=3Dint,=20 + metavar=3D'[0-9]', choices=3Dlist(range(0, 10)), default=3D0, help=3D'set debug level') parser.add_argument('--exclude', dest=3D'Exclude', nargs=3D'+', help= =3D"directory name or file name which will be excluded") args =3D parser.parse_args() diff --git a/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py b/Bas= eTools/Scripts/PackageDocumentTools/packagedoc_cli.py index 4deeee01a5e8..b45b5e69bc54 100644 --- a/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py +++ b/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py @@ -13,6 +13,7 @@ # =20 from __future__ import print_function +from builtins import range import os, sys, logging, traceback, subprocess from optparse import Optio= nParser =20 diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/base= model/efibinary.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlug= ins/basemodel/efibinary.py index 290287b817e7..5e5f6526d3a6 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/e= fibinary.py +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemode +++ l/efibinary.py @@ -12,6 +12,7 @@ # =20 from __future__ import print_function +from builtins import range import array import uuid import re diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/base= model/ini.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/ba= semodel/ini.py index ea83327052f2..d7a4a3e4c42a 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/i= ni.py +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemode +++ l/ini.py @@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. # =20 +from builtins import range from message import * import re import os diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2= /model/doxygengen.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPl= ugins/edk2/model/doxygengen.py index c22d362ff3e1..f5562a05b426 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/= doxygengen.py +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/mod +++ el/doxygengen.py @@ -16,6 +16,7 @@ """This file produce action class to generate doxygen document for edk2 co= debase. The action classes are shared by GUI and command line tools. """ +from builtins import range import plugins.EdkPlugins.basemodel.doxygen as doxygen import os try: @@ -386,7 +387,7 @@ class PackageDocumentAction(DoxygenAction): configFile.AddFile(path) =20 no =3D 0 - for no in xrange(len(lines)): + for no in range(len(lines)): if len(lines[no].strip()) =3D=3D 0: continue if lines[no].strip()[:2] in ['##', '//', '/*', '*/']: diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2= /model/doxygengen_spec.py b/BaseTools/Scripts/PackageDocumentTools/plugins/= EdkPlugins/edk2/model/doxygengen_spec.py index 4bae6968a96e..b8446032aa77 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/= doxygengen_spec.py +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/mod +++ el/doxygengen_spec.py @@ -13,6 +13,7 @@ # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, #= WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLI= ED. =20 +from builtins import range import plugins.EdkPlugins.basemodel.doxygen as doxygen import os try: @@ -388,7 +389,7 @@ class PackageDocumentAction(DoxygenAction): configFile.AddFile(path) return no =3D 0 - for no in xrange(len(lines)): + for no in range(len(lines)): if len(lines[no].strip()) =3D=3D 0: continue if lines[no].strip()[:2] in ['##', '//', '/*', '*/']: diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck= .py index 43bfc2495c6b..51d4adf08b60 100755 --- a/BaseTools/Scripts/PatchCheck.py +++ b/BaseTools/Scripts/PatchCheck.py @@ -15,6 +15,7 @@ =20 from __future__ import print_function =20 +from builtins import range VersionNumber =3D '0.1' __copyright__ =3D "Copyright (c) 2015 - 2016, Intel Corporation All right= s reserved." =20 @@ -26,7 +27,7 @@ import subprocess import sys =20 class Verbose: - SILENT, ONELINE, NORMAL =3D range(3) + SILENT, ONELINE, NORMAL =3D list(range(3)) level =3D NORMAL =20 class CommitMessageCheck: @@ -234,7 +235,7 @@ class CommitMessageCheck: break last_sig_line =3D line.strip() =20 -(START, PRE_PATCH, PATCH) =3D range(3) +(START, PRE_PATCH, PATCH) =3D list(range(3)) =20 class GitDiffCheck: """Checks the contents of a git diff.""" diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/= Python/AutoGen/AutoGen.py index d7485909414d..cfe3b8118716 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -16,6 +16,7 @@ ## Import Modules # from __future__ import print_function +from builtins import range import Common.LongFilePathOs as os import re import os.path as path diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py b/BaseTools/Sou= rce/Python/AutoGen/BuildEngine.py index cab4c993dc44..4d81ffa3436f 100644 --- a/BaseTools/Source/Python/AutoGen/BuildEngine.py +++ b/BaseTools/Source/Python/AutoGen/BuildEngine.py @@ -15,6 +15,7 @@ # Import Modules # from __future__ import print_function +from builtins import range import Common.LongFilePathOs as os import re import copy diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Pyt= hon/AutoGen/GenC.py index ae3af085a16b..2f10b3787a2d 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -13,6 +13,7 @@ =20 ## Import Modules # +from builtins import range import string import collections import struct diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source= /Python/AutoGen/GenPcdDb.py index 25e4f7246e3a..d2958384a97f 100644 --- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py +++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py @@ -10,6 +10,7 @@ # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, #= WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLI= ED. # +from builtins import range from StringIO import StringIO from Common.Misc import * from Common.StringUtils import StringToArray @@ -257,7 +258,7 @@ class DbI= temList: # Variable length, need to calculate one by one # assert(Index < len(self.RawDataList)) - for ItemIndex in xrange(Index): + for ItemIndex in range(Index): Offset +=3D len(self.RawDataList[ItemIndex]) else: Offset =3D self.ItemSize * Index @@ -344,7 +345,7 @@ class DbC= omItemList (DbItemList): assert(False) else: assert(Index < len(self.RawDataList)) - for ItemIndex in xrange(Index): + for ItemIndex in range(Index): Offset +=3D len(self.RawDataList[ItemIndex]) * self.ItemSi= ze =20 =20 return Offset @@ -410,7 +411,7 @@ class DbStringHeadTableItemList(DbItemList): # Variable length, need to calculate one by one # assert(Index < len(self.RawDataList)) - for ItemIndex in xrange(Index): + for ItemIndex in range(Index): Offset +=3D len(self.RawDataList[ItemIndex]) else: for innerIndex in range(Index): @@ -494,14 +495,14 @@ class DbStringItemList (DbComItemList): assert(len(RawDataList) =3D=3D len(LenList)) DataList =3D [] # adjust DataList according to the LenList - for Index in xrange(len(RawDataList)): + for Index in range(len(RawDataList)): Len =3D LenList[Index] RawDatas =3D RawDataList[Index] assert(Len >=3D len(RawDatas)) ActualDatas =3D [] - for i in xrange(len(RawDatas)): + for i in range(len(RawDatas)): ActualDatas.append(RawDatas[i]) - for i in xrange(len(RawDatas), Len): + for i in range(len(RawDatas), Len): ActualDatas.append(0) DataList.append(ActualDatas) self.LenList =3D LenList @@ -510,7 +511,7 @@ class DbStringItemList (DbComItemList): Offset =3D 0 =20 assert(Index < len(self.LenList)) - for ItemIndex in xrange(Index): + for ItemIndex in range(Index): Offset +=3D self.LenList[ItemIndex] =20 return Offset @@ -698,7 +699,7 @@ def BuildExDataBase(Dict): =20 # Get offset of SkuId table in the database=20 SkuIdTableOffset =3D FixedHeaderLen - for DbIndex in xrange(len(DbTotal)): + for DbIndex in range(len(DbTotal)): if DbTotal[DbIndex] is SkuidValue: break SkuIdTableOffset +=3D DbItemTotal[DbIndex].GetListSize() @@ -710,7 +711,7 @@ def BuildExDataBase(Dict): for (LocalTokenNumberTableIndex, (Offset, Table)) in enumerate(LocalTo= kenNumberTable): DbIndex =3D 0 DbOffset =3D FixedHeaderLen - for DbIndex in xrange(len(DbTotal)): + for DbIndex in range(len(DbTotal)): if DbTotal[DbIndex] is Table: DbOffset +=3D DbItemTotal[DbIndex].GetInterOffset(Offset) break @@ -736,7 +737,7 @@ def BuildExDataBase(Dict): (VariableHeadGuidIndex, VariableHeadStringIndex, SKUVariableOf= fset, VariableOffset, VariableRefTable, VariableAttribute) =3D VariableEntr= yPerSku[:] DbIndex =3D 0 DbOffset =3D FixedHeaderLen - for DbIndex in xrange(len(DbTotal)): + for DbIndex in range(len(DbTotal)): if DbTotal[DbIndex] is VariableRefTable: DbOffset +=3D DbItemTotal[DbIndex].GetInterOffset(Vari= ableOffset) break @@ -756,7 +757,7 @@ def BuildExDataBase(Dict): =20 # calculate various table offset now DbTotalLength =3D FixedHeaderLen - for DbIndex in xrange(len(DbItemTotal)): + for DbIndex in range(len(DbItemTotal)): if DbItemTotal[DbIndex] is DbLocalTokenNumberTable: LocalTokenNumberTableOffset =3D DbTotalLength elif DbItemTotal[DbIndex] is DbExMapTable: diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/P= ython/AutoGen/GenVar.py index 3675be8de994..faaa955431d5 100644 --- a/BaseTools/Source/Python/AutoGen/GenVar.py +++ b/BaseTools/Source/Python/AutoGen/GenVar.py @@ -14,6 +14,7 @@ # # # Import Modules # +from builtins import range from struct import pack,unpack import collections import copy @@ -92,7 +93,7 @@ class VariableMgr(object): for current_valuedict_key in ordered_valuedict_keys: if current_valuedict_key < len(var_value): raise - for _ in xrange(current_valuedict_key - len(var_value)): + for _ in range(current_valuedict_key - len(var_value)): var_value.append('0x00') var_value +=3D valuedict[current_valuedict_key] return var_value diff --git a/BaseTools/Source/Python/AutoGen/InfSectionParser.py b/BaseTool= s/Source/Python/AutoGen/InfSectionParser.py index 2cd5a6667a02..3d74e91f1f78 100644 --- a/BaseTools/Source/Python/AutoGen/InfSectionParser.py +++ b/BaseTools/Source/Python/AutoGen/InfSectionParser.py @@ -14,6 +14,7 @@ ## Import Modules # =20 +from builtins import range import Common.EdkLogger as EdkLogger from Common.BuildToolError import * from Common.DataType import * diff --git a/BaseTools/Source/Python/AutoGen/StrGather.py b/BaseTools/Sourc= e/Python/AutoGen/StrGather.py index ce8866f480d5..844d2d8d8856 100644 --- a/BaseTools/Source/Python/AutoGen/StrGather.py +++ b/BaseTools/Source/Python/AutoGen/StrGather.py @@ -14,6 +14,7 @@ ## # Import Modules # +from builtins import range import re import Common.EdkLogger as EdkLogger from Common.BuildToolError import * diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py b/BaseTools/= Source/Python/AutoGen/UniClassObject.py index 3a931c6f2766..438f3394d55b 100644 --- a/BaseTools/Source/Python/AutoGen/UniClassObject.py +++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py @@ -17,6 +17,7 @@ # Import Modules # from __future__ import print_function +from builtins import range import Common.LongFilePathOs as os, codecs, re import distutils.util imp= ort Common.EdkLogger as EdkLogger diff --git a/BaseTools/Source/Python/Auto= Gen/ValidCheckingInfoObject.py b/BaseTools/Source/Python/AutoGen/ValidCheck= ingInfoObject.py index 64d4965e9662..20356c6bcfab 100644 --- a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py +++ b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py @@ -14,6 +14,7 @@ # # # Import Modules # +from builtins import range import os from Common.RangeExpression import RangeExpression from Common.Misc impor= t * diff --git a/BaseTools/Source/Python/BPDG/GenVpd.py b/BaseTools/Source/= Python/BPDG/GenVpd.py index 69a9665f5a76..999cadf3437d 100644 --- a/BaseTools/Source/Python/BPDG/GenVpd.py +++ b/BaseTools/Source/Python/BPDG/GenVpd.py @@ -13,6 +13,7 @@ # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. # =20 +from builtins import range import Common.LongFilePathOs as os import StringIO import StringTable as st @@ -229,7 +230,7 @@ class PcdEntry: =20 ReturnArray =3D array.array('B') =20 - for Index in xrange(len(ValueList)): + for Index in range(len(ValueList)): Value =3D None if ValueList[Index].lower().startswith('0x'): # translate hex value @@ -255,7 +256,7 @@ class PcdEntry: =20 ReturnArray.append(Value) =20 - for Index in xrange(len(ValueList), Size): + for Index in range(len(ValueList), Size): ReturnArray.append(0) =20 self.PcdValue =3D ReturnArray.tolist() @@ -290,7 +291,7 @@ class P= cdEntry: "Invalid unicode character %s in unicode s= tring %s(File: %s Line: %s)" % \ (Value, UnicodeString, self.FileName, self= .Lineno)) =20 - for Index in xrange(len(UnicodeString) * 2, Size): + for Index in range(len(UnicodeString) * 2, Size): ReturnArray.append(0) =20 self.PcdValue =3D ReturnArray.tolist() diff --git a/BaseTools/Sour= ce/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.= py index c63030a16e6e..a4afe1783e33 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -13,6 +13,7 @@ ## Import Modules # from __future__ import print_function +from builtins import range from Common.GlobalData import * from CommonDataClass.Exceptions import BadExpression from CommonDataClass= .Exceptions import WrnExpression diff --git a/BaseTools/Source/Python/Commo= n/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 01171adb9b9e..ebf706a55d7e 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -14,6 +14,7 @@ ## # Import Modules # +from builtins import range import Common.LongFilePathOs as os import sys import string @@ -1634,7 +1635,7 @@ def SplitOption(OptionString): def CommonPath(PathList): P1 =3D min(PathList).split(os.path.sep) P2 =3D max(PathList).split(os.path.sep) - for Index in xrange(min(len(P1), len(P2))): + for Index in range(min(len(P1), len(P2))): if P1[Index] !=3D P2[Index]: return os.path.sep.join(P1[:Index]) return os.path.sep.join(P1) diff --git a/BaseTools/Source/Python/Common/Parsing.py b/BaseTools/Source/P= ython/Common/Parsing.py index 527852a50c09..717bc569d1c9 100644 --- a/BaseTools/Source/Python/Common/Parsing.py +++ b/BaseTools/Source/Python/Common/Parsing.py @@ -14,6 +14,7 @@ ## # Import Modules # +from builtins import range from StringUtils import * from CommonDataClass.DataClass import * from DataType import * diff --git= a/BaseTools/Source/Python/Common/RangeExpression.py b/BaseTools/Source/Pyt= hon/Common/RangeExpression.py index 4c29bc9ee4bd..284ee9c16334 100644 --- a/BaseTools/Source/Python/Common/RangeExpression.py +++ b/BaseTools/Source/Python/Common/RangeExpression.py @@ -13,6 +13,7 @@ # # Import Modules # from __future__ import print_function +from builtins import range from Common.GlobalData import * from CommonDataClass.Exceptions import BadExpression from CommonDataClass= .Exceptions import WrnExpression diff --git a/BaseTools/Source/Python/Commo= n/StringUtils.py b/BaseTools/Source/Python/Common/StringUtils.py index 2292a263b985..833bdcf5614b 100644 --- a/BaseTools/Source/Python/Common/StringUtils.py +++ b/BaseTools/Source/Python/Common/StringUtils.py @@ -14,6 +14,7 @@ ## # Import Modules # +from builtins import range import re import DataType import Common.LongFilePathOs as os diff --git a/BaseTools/Source/Python/Common/ToolDefClassObject.py b/BaseToo= ls/Source/Python/Common/ToolDefClassObject.py index dd985ab30359..3a1cb13ff690 100644 --- a/BaseTools/Source/Python/Common/ToolDefClassObject.py +++ b/BaseTools/Source/Python/Common/ToolDefClassObject.py @@ -14,6 +14,7 @@ ## # Import Modules # +from builtins import range import Common.LongFilePathOs as os import re import EdkLogger diff --git a/BaseTools/Source/Python/Ecc/Check.py b/BaseTools/Source/Python= /Ecc/Check.py index ea739043e0bc..4a60e9bab0e4 100644 --- a/BaseTools/Source/Python/Ecc/Check.py +++ b/BaseTools/Source/Python/Ecc/Check.py @@ -10,6 +10,7 @@ # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, #= WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLI= ED. # +from builtins import range import Common.LongFilePathOs as os import re from CommonDataClass.DataClass import * diff --git a/BaseTools/Source/Pyth= on/Ecc/MetaDataParser.py b/BaseTools/Source/Python/Ecc/MetaDataParser.py index 82ede3eb330c..9b8b96aa4b43 100644 --- a/BaseTools/Source/Python/Ecc/MetaDataParser.py +++ b/BaseTools/Source/Python/Ecc/MetaDataParser.py @@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. # =20 +from builtins import range import Common.LongFilePathOs as os from CommonDataClass.DataClass import * from EccToolError import * @@ -11= 2,7 +113,7 @@ def ParseHeaderCommentSection(CommentList, FileName =3D None)= : # Last =3D 0 HeaderCommentStage =3D HEADER_COMMENT_NOT_STARTED - for Index in xrange(len(CommentList)-1, 0, -1): + for Index in range(len(CommentList)-1, 0, -1): Line =3D CommentList[Index][0] if _IsCopyrightLine(Line): Last =3D Index diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.p= y b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py index fd96bb9a3c0b..d22945434711 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py @@ -14,6 +14,7 @@ ## # Import Modules # +from builtins import range import Common.LongFilePathOs as os import re import time diff --git a/BaseTools/Source/Python/Eot/Eot.py b/BaseTools/Source/Python/E= ot/Eot.py index dfd1146af749..1862d71f7342 100644 --- a/BaseTools/Source/Python/Eot/Eot.py +++ b/BaseTools/Source/Python/Eot/Eot.py @@ -14,6 +14,7 @@ ## # Import Modules # +from builtins import range import Common.LongFilePathOs as os, time, glob import Common.EdkLogger as= EdkLogger import EotGlobalData diff --git a/BaseTools/Source/Python/Eot/I= nfParserLite.py b/BaseTools/Source/Python/Eot/InfParserLite.py index 24f0d50246e5..5a2eab9b0413 100644 --- a/BaseTools/Source/Python/Eot/InfParserLite.py +++ b/BaseTools/Source/Python/Eot/InfParserLite.py @@ -15,6 +15,7 @@ # Import Modules # from __future__ import print_function +from builtins import range import Common.LongFilePathOs as os import Common.EdkLogger as EdkLogger from Common.DataType import * diff --git a/BaseTools/Source/Python/GenFds/AprioriSection.py b/BaseTools/S= ource/Python/GenFds/AprioriSection.py index 6b81b42620d7..decc0dd7c98d 100644 --- a/BaseTools/Source/Python/GenFds/AprioriSection.py +++ b/BaseTools/Source/Python/GenFds/AprioriSection.py @@ -15,6 +15,7 @@ ## # Import Modules # +from builtins import range from struct import * import Common.LongFilePathOs as os import StringIO diff --git a/BaseTools/Source/Python/GenFds/FfsFileStatement.py b/BaseTools= /Source/Python/GenFds/FfsFileStatement.py index ba8e0465ef34..c3bccb47be2c 100644 --- a/BaseTools/Source/Python/GenFds/FfsFileStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsFileStatement.py @@ -15,6 +15,7 @@ ## # Import Modules # +from builtins import range import Ffs import Rule import Common.LongFilePathOs as os diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python= /GenFds/Fv.py index 6714838f6fc9..21c2579f0b51 100644 --- a/BaseTools/Source/Python/GenFds/Fv.py +++ b/BaseTools/Source/Python/GenFds/Fv.py @@ -15,6 +15,7 @@ ## # Import Modules # +from builtins import range import Common.LongFilePathOs as os import subprocess import StringIO diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Py= thon/GenFds/GenFds.py index 1552ab4ee3a8..6b6511915eb3 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -16,6 +16,7 @@ # Import Modules # from __future__ import print_function +from builtins import range from optparse import OptionParser import sys import Common.LongFilePathOs as os diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseT= ools/Source/Python/GenFds/GenFdsGlobalVariable.py index 73b52030d929..3388d5b098a8 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -16,6 +16,7 @@ # Import Modules # from __future__ import print_function +from builtins import range import Common.LongFilePathOs as os import sys import subprocess diff --git a/BaseTools/Source/Python/GenFds/Region.py b/BaseTools/Source/Py= thon/GenFds/Region.py index 9d632b6321e2..a662692ad5d4 100644 --- a/BaseTools/Source/Python/GenFds/Region.py +++ b/BaseTools/Source/Python/GenFds/Region.py @@ -15,6 +15,7 @@ ## # Import Modules # +from builtins import range from struct import * from GenFdsGlobalVariable import GenFdsGlobalVariable import StringIO @@ = -57,7 +58,7 @@ class Region(RegionClassObject): PadByte =3D pack('B', 0xFF) else: PadByte =3D pack('B', 0) - PadData =3D ''.join(PadByte for i in xrange(0, Size)) + PadData =3D ''.join(PadByte for i in range(0, Size)) Buffer.write(PadData) =20 ## AddToBuffer() diff --git a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py b/BaseT= ools/Source/Python/PatchPcdValue/PatchPcdValue.py index cf2fc7c4f70a..0ba4a94950c6 100644 --- a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py +++ b/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py @@ -14,6 +14,7 @@ ## # Import Modules # +from builtins import range import Common.LongFilePathOs as os from Common.LongFilePathSupport import OpenLongFilePath as open import sy= s diff --git a/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py b/BaseTools/S= ource/Python/Pkcs7Sign/Pkcs7Sign.py index 11d11700ed99..becf3e8eb9e8 100644 --- a/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py +++ b/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py @@ -21,6 +21,7 @@ Pkcs7Sign ''' from __future__ import print_function =20 +from builtins import range import os import sys import argparse @@ -88,7 +89,7 @@ if __name__ =3D=3D '__main__': parser.add_argument("--signature-size", dest=3D'SignatureSizeStr', type= =3Dstr, help=3D"specify the signature size for decode process.") parser.add_argument("-v", "--verbose", dest=3D'Verbose', action=3D"store= _true", help=3D"increase output messages") parser.add_argument("-q", "--quiet", dest=3D'Quiet', action=3D"store_tru= e", help=3D"reduce output messages") - parser.add_argument("--debug", dest=3D'Debug', type=3Dint, metavar=3D'[0= -9]', choices=3Drange(0,10), default=3D0, help=3D"set debug level") + parser.add_argument("--debug", dest=3D'Debug', type=3Dint,=20 + metavar=3D'[0-9]', choices=3Dlist(range(0,10)), default=3D0, help=3D"set = debug=20 + level") parser.add_argument(metavar=3D"input_file", dest=3D'InputFile', type=3Da= rgparse.FileType('rb'), help=3D"specify the input filename") =20 # diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Generat= eKeys.py b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateK= eys.py index ca4f64864790..ca0093bf117e 100644 --- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.p= y +++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKey +++ s.py @@ -24,6 +24,7 @@ Rsa2048Sha256GenerateKeys ''' from __future__ import print_function =20 +from builtins import range import os import sys import argparse @@ -51,7 +52,7 @@ if __name__ =3D=3D '__main__': parser.add_argument("--public-key-hash-c", dest=3D'PublicKeyHashCFile', = type=3Dargparse.FileType('wb'), help=3D"specify the public key hash filenam= e that is SHA 256 hash of 2048 bit RSA public key in C structure format") parser.add_argument("-v", "--verbose", dest=3D'Verbose', action=3D"store= _true", help=3D"increase output messages") parser.add_argument("-q", "--quiet", dest=3D'Quiet', action=3D"store_tru= e", help=3D"reduce output messages") - parser.add_argument("--debug", dest=3D'Debug', type=3Dint, metavar=3D'[0= -9]', choices=3Drange(0,10), default=3D0, help=3D"set debug level") + parser.add_argument("--debug", dest=3D'Debug', type=3Dint,=20 + metavar=3D'[0-9]', choices=3Dlist(range(0,10)), default=3D0, help=3D"set = debug=20 + level") =20 # # Parse command line arguments diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py= b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py index 2e164c4a2da6..ff9721d0deae 100644 --- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py +++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py @@ -19,6 +19,7 @@ Rsa2048Sha256Sign ''' from __future__ import print_function =20 +from builtins import range import os import sys import argparse @@ -71,7 +72,7 @@ if __name__ =3D=3D '__main__': parser.add_argument("--private-key", dest=3D'PrivateKeyFile', type=3Darg= parse.FileType('rb'), help=3D"specify the private key filename. If not spe= cified, a test signing key is used.") parser.add_argument("-v", "--verbose", dest=3D'Verbose', action=3D"store= _true", help=3D"increase output messages") parser.add_argument("-q", "--quiet", dest=3D'Quiet', action=3D"store_tru= e", help=3D"reduce output messages") - parser.add_argument("--debug", dest=3D'Debug', type=3Dint, metavar=3D'[0= -9]', choices=3Drange(0,10), default=3D0, help=3D"set debug level") + parser.add_argument("--debug", dest=3D'Debug', type=3Dint,=20 + metavar=3D'[0-9]', choices=3Dlist(range(0,10)), default=3D0, help=3D"set = debug=20 + level") parser.add_argument(metavar=3D"input_file", dest=3D'InputFile', type=3Da= rgparse.FileType('rb'), help=3D"specify the input filename") =20 # diff --git a/BaseTools/Source/Python/Trim/Trim.py b/BaseTools/Source/Python= /Trim/Trim.py index b512d15243f8..1a690cde5933 100644 --- a/BaseTools/Source/Python/Trim/Trim.py +++ b/BaseTools/Source/Python/Trim/Trim.py @@ -14,6 +14,7 @@ ## # Import Modules # +from builtins import range import Common.LongFilePathOs as os import sys import re diff --git a/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py b/BaseTo= ols/Source/Python/UPT/GenMetaFile/GenInfFile.py index bfd422b196ba..448b85700948 100644 --- a/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py +++ b/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py @@ -15,6 +15,7 @@ ''' GenInf ''' +from builtins import range import os import stat import codecs @@ -409,7 +410,7 @@ def GenLibraryClasses(ModuleObject): Statement +=3D '|' + FFE ModuleList =3D LibraryClass.GetSupModuleList() ArchList =3D LibraryClass.GetSupArchList() - for Index in xrange(0, len(ArchList)): + for Index in range(0, len(ArchList)): ArchList[Index] =3D ConvertArchForInstall(ArchList[Index]) ArchList.sort() SortedArch =3D ' '.join(ArchList) @@ -574,7 +575,7 @@ def GenU= serExtensions(ModuleObject): # if not Statement: # continue ArchList =3D UserExtension.GetSupArchList() - for Index in xrange(0, len(ArchList)): + for Index in range(0, len(ArchList)): ArchList[Index] =3D ConvertArchForInstall(ArchList[Index]) ArchList.sort() KeyList =3D [] diff --git a/BaseTools/Source/Python/UPT/Library/CommentParsing.py b/BaseTo= ols/Source/Python/UPT/Library/CommentParsing.py index 8ee788bd7724..3ad69ebc1902 100644 --- a/BaseTools/Source/Python/UPT/Library/CommentParsing.py +++ b/BaseTools/Source/Python/UPT/Library/CommentParsing.py @@ -19,6 +19,7 @@ CommentParsing ## # Import Modules # +from builtins import range import re =20 from Library.StringUtils import GetSplitValueList @@ -74,7 +75,7 @@ def Pa= rseHeaderCommentSection(CommentList, FileName =3D None, IsBinaryHeader =3D = Fal # first find the last copyright line # Last =3D 0 - for Index in xrange(len(CommentList)-1, 0, -1): + for Index in range(len(CommentList)-1, 0, -1): Line =3D CommentList[Index][0] if _IsCopyrightLine(Line): Last =3D Index diff --git a/BaseTools/Source/Python/UPT/Library/Misc.py b/BaseTools/Source= /Python/UPT/Library/Misc.py index e16d309ef883..733abc6ff5de 100644 --- a/BaseTools/Source/Python/UPT/Library/Misc.py +++ b/BaseTools/Source/Python/UPT/Library/Misc.py @@ -19,6 +19,7 @@ Misc ## # Import Modules # +from builtins import range import os.path from os import access from os import F_OK @@ -437,7 +438,7 @@ class Sdict(IterableUserDict): def CommonPath(PathList): Path1 =3D min(PathList).split(os.path.sep) Path2 =3D max(PathList).split(os.path.sep) - for Index in xrange(min(len(Path1), len(Path2))): + for Index in range(min(len(Path1), len(Path2))): if Path1[Index] !=3D Path2[Index]: return os.path.sep.join(Path1[:Index]) return os.path.sep.join(Path1) @@ -890,7 +891,7 @@ def ProcessEdkComment(LineList): if FindEdkBlockComment: if FirstPos =3D=3D -1: FirstPos =3D StartPos - for Index in xrange(StartPos, EndPos+1): + for Index in range(StartPos, EndPos+1): LineList[Index] =3D '' FindEdkBlockComment =3D False elif Line.find("//") !=3D -1 and not Line.startswith("#"): diff --git a/BaseTools/Source/Python/UPT/Library/Parsing.py b/BaseTools/Sou= rce/Python/UPT/Library/Parsing.py index 22030e7587c1..22faabfa4bb0 100644 --- a/BaseTools/Source/Python/UPT/Library/Parsing.py +++ b/BaseTools/Source/Python/UPT/Library/Parsing.py @@ -20,6 +20,7 @@ Parsing ## # Import Modules # +from builtins import range import os.path import re =20 @@ -973,7 +974,7 @@ def GenSection(SectionName, SectionDict, SplitArch=3DTr= ue, NeedBlankLine=3DFalse): ArchList =3D GetSplitValueList(SectionAttrs, DataType.= TAB_COMMENT_SPLIT) else: ArchList =3D [SectionAttrs] - for Index in xrange(0, len(ArchList)): + for Index in range(0, len(ArchList)): ArchList[Index] =3D ConvertArchForInstall(ArchList[Index]) Section =3D '[' + SectionName + '.' + (', ' + SectionName + '.= ').join(ArchList) + ']' else: diff --git a/BaseTools/Source/Python/UPT/Library/StringUtils.py b/BaseTools= /Source/Python/UPT/Library/StringUtils.py index a7a7b8667143..dccaff744617 100644 --- a/BaseTools/Source/Python/UPT/Library/StringUtils.py +++ b/BaseTools/Source/Python/UPT/Library/StringUtils.py @@ -18,6 +18,7 @@ StringUtils ## # Import Modules # +from builtins import range import re import os.path from string import strip diff --git a/BaseTools/Source/Python/UPT/Library/UniClassObject.py b/BaseTo= ols/Source/Python/UPT/Library/UniClassObject.py index a464cbf702f7..7e4362fd8ddd 100644 --- a/BaseTools/Source/Python/UPT/Library/UniClassObject.py +++ b/BaseTools/Source/Python/UPT/Library/UniClassObject.py @@ -19,6 +19,7 @@ from __future__ import print_function ## # Import Modul= es # +from builtins import range import os, codecs, re import distutils.util from Logger import ToolError @@ -513,7 +514,7 @@ class UniFileClassObject(object): FileIn[LineCount-1] =3D Line FileIn[LineCount] =3D '\r\n' LineCount -=3D 1 - for Index in xrange (LineCount + 1, len (FileIn) - 1): + for Index in range (LineCount + 1, len (FileIn) - 1): if (Index =3D=3D len(FileIn) -1): FileIn[Index] =3D '\r\n' else: diff --git a/BaseTools/Source/Python/UPT/Parser/DecParserMisc.py b/BaseTool= s/Source/Python/UPT/Parser/DecParserMisc.py index 22a50680fb8f..14539b0bd6c1 100644 --- a/BaseTools/Source/Python/UPT/Parser/DecParserMisc.py +++ b/BaseTools/Source/Python/UPT/Parser/DecParserMisc.py @@ -17,6 +17,7 @@ DecParserMisc =20 ## Import modules # +from builtins import range import os import Logger.Log as Logger from Logger.ToolError import FILE_PARSE_FAILURE diff --git a/BaseTools/Sou= rce/Python/UPT/Parser/InfSectionParser.py b/BaseTools/Source/Python/UPT/Par= ser/InfSectionParser.py index 8ba4c3fc0819..9e0a74c31d75 100644 --- a/BaseTools/Source/Python/UPT/Parser/InfSectionParser.py +++ b/BaseTools/Source/Python/UPT/Parser/InfSectionParser.py @@ -18,6 +18,7 @@ InfSectionParser ## # Import Modules # +from builtins import range from copy import deepcopy import re =20 @@ -455,7 +456,7 @@ class InfSectionParser(InfDefinSectionParser, Arch =3D Match.groups(1)[0].upper() ArchList.append(Arch) CommentSoFar =3D '' - for Index in xrange(1, len(List)): + for Index in range(1, len(List)): Result =3D ParseComment(List[Index], DT.ALL_USAGE_TOKENS, = TokenDict, [], False) Usage =3D Result[0] Type =3D Result[1] diff --git a/BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py b/Ba= seTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py index 074aa311f31d..4c28b7f5d22a 100644 --- a/BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py +++ b/BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py @@ -20,6 +20,7 @@ from __future__ import print_function ## # Import Modul= es # +from builtins import range import os.path from os import sep import platform diff --git a/BaseTools/Source/Python/UPT/UPT.py b/BaseTools/Source/Python/U= PT/UPT.py index 2644dbed31e9..930f0c1b9d54 100644 --- a/BaseTools/Source/Python/UPT/UPT.py +++ b/BaseTools/Source/Python/UPT/UPT.py @@ -19,6 +19,7 @@ UPT =20 ## import modules # +from builtins import range import locale import sys encoding =3D locale.getdefaultlocale()[1] diff --git a/BaseTools/Source/Py= thon/UPT/UnitTest/InfBinarySectionTest.py b/BaseTools/Source/Python/UPT/Uni= tTest/InfBinarySectionTest.py index 626f17426de7..2c21823194e2 100644 --- a/BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py +++ b/BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. =20 from __future__ import print_function +from builtins import range import os #import Object.Parser.InfObject as InfObject from Object.Parser.InfCommon= Object import CurrentLine diff --git a/BaseTools/Source/Python/UPT/Xml/IniT= oXml.py b/BaseTools/Source/Python/UPT/Xml/IniToXml.py index aa6f23011b17..529668895eb3 100644 --- a/BaseTools/Source/Python/UPT/Xml/IniToXml.py +++ b/BaseTools/Source/Python/UPT/Xml/IniToXml.py @@ -16,6 +16,7 @@ IniToXml ''' =20 +from builtins import range import os.path import re from time import strftime diff --git a/BaseTools/Source/Python/UPT/Xml/XmlParser.py b/BaseTools/Sourc= e/Python/UPT/Xml/XmlParser.py index dba3b7f5892c..dccc7a88f1d9 100644 --- a/BaseTools/Source/Python/UPT/Xml/XmlParser.py +++ b/BaseTools/Source/Python/UPT/Xml/XmlParser.py @@ -19,6 +19,7 @@ XmlParser ## # Import Modules # +from builtins import range import re =20 from Library.Xml.XmlRoutines import XmlNode diff --git a/BaseTools/Source/= Python/UPT/Xml/XmlParserMisc.py b/BaseTools/Source/Python/UPT/Xml/XmlParser= Misc.py index 7e3dc94edf64..28b146ff9183 100644 --- a/BaseTools/Source/Python/UPT/Xml/XmlParserMisc.py +++ b/BaseTools/Source/Python/UPT/Xml/XmlParserMisc.py @@ -15,6 +15,7 @@ ''' XmlParserMisc ''' +from builtins import range from Object.POM.CommonObject import TextObject from Logger.StringTable im= port ERR_XML_PARSER_REQUIRED_ITEM_MISSING from Logger.ToolError import PARSER_ERROR @@ -53,7 +54,7 @@ def ConvertVar= iableName(VariableName): if SecondByte !=3D 0: return None =20 - if FirstByte not in xrange(0x20, 0x7F): + if FirstByte not in range(0x20, 0x7F): return None TransferedStr +=3D ('%c')%FirstByte Index =3D Index + 2 diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/= Source/Python/Workspace/DscBuildData.py index a80c07bc1e55..462b06944a94 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -18,6 +18,7 @@ # into PlatformBuildClassObject form for easier use for AutoGen. # from __future__ import print_function +from builtins import range from Common.StringUtils import * from Common.DataType import * from Common.Misc import * diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/= Source/Python/Workspace/InfBuildData.py index 165e03f78964..658f86ac891c 100644 --- a/BaseTools/Source/Python/Workspace/InfBuildData.py +++ b/BaseTools/Source/Python/Workspace/InfBuildData.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. # =20 +from builtins import range from Common.StringUtils import * from Common.DataType import * from Common.Misc import * diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTool= s/Source/Python/Workspace/MetaFileParser.py index 2815c83af1b3..baa5ddbb3917 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -16,6 +16,7 @@ # Import Modules # from __future__ import print_function +from builtins import range import Common.LongFilePathOs as os import re import time diff --git a/BaseTools/Tests/TestTools.py b/BaseTools/Tests/TestTools.py in= dex be7b4ad42856..37338fd60db7 100644 --- a/BaseTools/Tests/TestTools.py +++ b/BaseTools/Tests/TestTools.py @@ -16,6 +16,7 @@ from __future__ import print_function ## # Import Modul= es # +from builtins import range import base64 import os import os.path @@ -162,7 +163,7 @@ class BaseToolsTest(unittest.TestCase): if maxlen is None: maxlen =3D minlen return ''.join( [chr(random.randint(0,255)) - for x in xrange(random.randint(minlen, maxlen)) + for x in range(random.randint(minlen, maxlen)) ]) =20 def setUp(self): diff --git a/BaseTools/Tests/TianoCompress.py b/BaseTools/Tests/TianoCompre= ss.py index f6a4a6ae9c5d..65f783d1be9e 100644 --- a/BaseTools/Tests/TianoCompress.py +++ b/BaseTools/Tests/TianoCompress.py @@ -16,6 +16,7 @@ # Import Modules # from __future__ import print_function +from builtins import range import os import random import sys diff --git a/BaseTools/gcc/mingw-gcc-build.py b/BaseTools/gcc/mingw-gcc-bui= ld.py index 643fec58a457..f7d0308bd9fa 100755 --- a/BaseTools/gcc/mingw-gcc-build.py +++ b/BaseTools/gcc/mingw-gcc-build.py @@ -18,6 +18,7 @@ =20 =20 from __future__ import print_function +from builtins import range from optparse import OptionParser import os import shutil -- 2.17.1