Replace xrange() and range() with the newer range() function
Based on "futurize -f libfuturize.fixes.fix_xrange_with_import"
Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Gary Lin <glin@suse.com>
---
BaseTools/Scripts/BinToPcd.py | 3 ++-
BaseTools/Scripts/ConvertMasmToNasm.py | 1 +
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 | 1 +
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/DscClassObject.py | 1 +
BaseTools/Source/Python/Common/Expression.py | 1 +
BaseTools/Source/Python/Common/FdfClassObject.py | 1 +
BaseTools/Source/Python/Common/MigrationUtilities.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/String.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/FvImage.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/String.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 +
58 files changed, 91 insertions(+), 33 deletions(-)
diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.py
index 1867f35e148e..7d8cd0a5cc25 100644
--- a/BaseTools/Scripts/BinToPcd.py
+++ b/BaseTools/Scripts/BinToPcd.py
@@ -16,6 +16,7 @@ BinToPcd
'''
from __future__ import print_function
+from builtins import range
import sys
import argparse
import re
@@ -84,7 +85,7 @@ if __name__ == '__main__':
help = "Increase output messages")
parser.add_argument("-q", "--quiet", dest = 'Quiet', action = "store_true",
help = "Reduce output messages")
- parser.add_argument("--debug", dest = 'Debug', type = int, metavar = '[0-9]', choices = range(0,10), default = 0,
+ parser.add_argument("--debug", dest = 'Debug', type = int, metavar = '[0-9]', choices = list(range(0,10)), default = 0,
help = "Set debug level")
#
diff --git a/BaseTools/Scripts/ConvertMasmToNasm.py b/BaseTools/Scripts/ConvertMasmToNasm.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 Modules
#
+from builtins import range
import argparse
import io
import os.path
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 @@
from __future__ import print_function
+from builtins import range
VersionNumber = '0.1'
__copyright__ = "Copyright (c) 2015 - 2016, Intel Corporation All rights reserved."
@@ -26,7 +27,7 @@ import subprocess
import sys
class Verbose:
- SILENT, ONELINE, NORMAL = range(3)
+ SILENT, ONELINE, NORMAL = list(range(3))
level = NORMAL
class CommitMessageCheck:
@@ -234,7 +235,7 @@ class CommitMessageCheck:
break
last_sig_line = line.strip()
-(START, PRE_PATCH, PATCH) = range(3)
+(START, PRE_PATCH, PATCH) = list(range(3))
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 acf6dfd3487f..73ffff8a70d8 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -14,6 +14,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/Source/Python/AutoGen/BuildEngine.py
index f0a973c9f197..e8f6788cdc40 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/Python/AutoGen/GenC.py
index b8ba687bcda0..d68160deb4a1 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -13,6 +13,7 @@
## 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 82360ae57deb..b4955ea7ebab 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 IMPLIED.
#
+from builtins import range
from StringIO import StringIO
from Common.Misc import *
from Common.String import StringToArray
@@ -297,7 +298,7 @@ class 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 += len(self.RawDataList[ItemIndex])
else:
for Datas in self.RawDataList:
@@ -394,7 +395,7 @@ class DbComItemList (DbItemList):
assert(False)
else:
assert(Index < len(self.RawDataList))
- for ItemIndex in xrange(Index):
+ for ItemIndex in range(Index):
Offset += len(self.RawDataList[ItemIndex]) * self.ItemSize
return Offset
@@ -478,7 +479,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 += len(self.RawDataList[ItemIndex])
else:
for innerIndex in range(Index):
@@ -568,14 +569,14 @@ class DbStringItemList (DbComItemList):
assert(len(RawDataList) == len(LenList))
DataList = []
# adjust DataList according to the LenList
- for Index in xrange(len(RawDataList)):
+ for Index in range(len(RawDataList)):
Len = LenList[Index]
RawDatas = RawDataList[Index]
assert(Len >= len(RawDatas))
ActualDatas = []
- 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 = LenList
@@ -584,7 +585,7 @@ class DbStringItemList (DbComItemList):
Offset = 0
assert(Index < len(self.LenList))
- for ItemIndex in xrange(Index):
+ for ItemIndex in range(Index):
Offset += self.LenList[ItemIndex]
return Offset
@@ -772,7 +773,7 @@ def BuildExDataBase(Dict):
# Get offset of SkuId table in the database
SkuIdTableOffset = FixedHeaderLen
- for DbIndex in xrange(len(DbTotal)):
+ for DbIndex in range(len(DbTotal)):
if DbTotal[DbIndex] is SkuidValue:
break
SkuIdTableOffset += DbItemTotal[DbIndex].GetListSize()
@@ -784,7 +785,7 @@ def BuildExDataBase(Dict):
for (LocalTokenNumberTableIndex, (Offset, Table)) in enumerate(LocalTokenNumberTable):
DbIndex = 0
DbOffset = FixedHeaderLen
- for DbIndex in xrange(len(DbTotal)):
+ for DbIndex in range(len(DbTotal)):
if DbTotal[DbIndex] is Table:
DbOffset += DbItemTotal[DbIndex].GetInterOffset(Offset)
break
@@ -810,7 +811,7 @@ def BuildExDataBase(Dict):
(VariableHeadGuidIndex, VariableHeadStringIndex, SKUVariableOffset, VariableOffset, VariableRefTable, VariableAttribute) = VariableEntryPerSku[:]
DbIndex = 0
DbOffset = FixedHeaderLen
- for DbIndex in xrange(len(DbTotal)):
+ for DbIndex in range(len(DbTotal)):
if DbTotal[DbIndex] is VariableRefTable:
DbOffset += DbItemTotal[DbIndex].GetInterOffset(VariableOffset)
break
@@ -830,7 +831,7 @@ def BuildExDataBase(Dict):
# calculate various table offset now
DbTotalLength = FixedHeaderLen
- for DbIndex in xrange(len(DbItemTotal)):
+ for DbIndex in range(len(DbItemTotal)):
if DbItemTotal[DbIndex] is DbLocalTokenNumberTable:
LocalTokenNumberTableOffset = DbTotalLength
elif DbItemTotal[DbIndex] is DbExMapTable:
diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/Python/AutoGen/GenVar.py
index 1389d7ff6225..8e800c8bc914 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
diff --git a/BaseTools/Source/Python/AutoGen/InfSectionParser.py b/BaseTools/Source/Python/AutoGen/InfSectionParser.py
index cdc9e5e8a849..ee2aae3b70e0 100644
--- a/BaseTools/Source/Python/AutoGen/InfSectionParser.py
+++ b/BaseTools/Source/Python/AutoGen/InfSectionParser.py
@@ -14,6 +14,7 @@
## Import Modules
#
+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/Source/Python/AutoGen/StrGather.py
index ed33554cd7d2..718cd60514b4 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 264cf1546566..cab7623bc4e6 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
import Common.EdkLogger as EdkLogger
diff --git a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py
index 53da9b881f25..ff355d05d79f 100644
--- a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py
+++ b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py
@@ -15,6 +15,7 @@
# Import Modules
#
from __future__ import print_function
+from builtins import range
import os
from Common.RangeExpression import RangeExpression
from Common.Misc import *
diff --git a/BaseTools/Source/Python/BPDG/GenVpd.py b/BaseTools/Source/Python/BPDG/GenVpd.py
index cdfc420c66f7..daf11612d83b 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 IMPLIED.
#
+from builtins import range
import Common.LongFilePathOs as os
import StringIO
import StringTable as st
@@ -229,7 +230,7 @@ class PcdEntry:
ReturnArray = array.array('B')
- for Index in xrange(len(ValueList)):
+ for Index in range(len(ValueList)):
Value = None
if ValueList[Index].lower().startswith('0x'):
# translate hex value
@@ -255,7 +256,7 @@ class PcdEntry:
ReturnArray.append(Value)
- for Index in xrange(len(ValueList), Size):
+ for Index in range(len(ValueList), Size):
ReturnArray.append(0)
self.PcdValue = ReturnArray.tolist()
@@ -290,7 +291,7 @@ class PcdEntry:
"Invalid unicode character %s in unicode string %s(File: %s Line: %s)" % \
(Value, UnicodeString, self.FileName, self.Lineno))
- for Index in xrange(len(UnicodeString) * 2, Size):
+ for Index in range(len(UnicodeString) * 2, Size):
ReturnArray.append(0)
self.PcdValue = ReturnArray.tolist()
diff --git a/BaseTools/Source/Python/Common/DscClassObject.py b/BaseTools/Source/Python/Common/DscClassObject.py
index 3a27fbffc934..f42d247cad33 100644
--- a/BaseTools/Source/Python/Common/DscClassObject.py
+++ b/BaseTools/Source/Python/Common/DscClassObject.py
@@ -15,6 +15,7 @@
# Import Modules
#
from __future__ import print_function
+from builtins import range
import Common.LongFilePathOs as os
import EdkLogger as EdkLogger
import Database
diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py
index 145acfc072e7..f7dbb29ee882 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/Common/FdfClassObject.py b/BaseTools/Source/Python/Common/FdfClassObject.py
index 3e7d44954c88..7ec0235967b2 100644
--- a/BaseTools/Source/Python/Common/FdfClassObject.py
+++ b/BaseTools/Source/Python/Common/FdfClassObject.py
@@ -14,6 +14,7 @@
##
# Import Modules
#
+from builtins import range
from FdfParserLite import FdfParser
from Table.TableFdf import TableFdf
from CommonDataClass.DataClass import MODEL_FILE_FDF, MODEL_PCD, MODEL_META_DATA_COMPONENT
diff --git a/BaseTools/Source/Python/Common/MigrationUtilities.py b/BaseTools/Source/Python/Common/MigrationUtilities.py
index e9f1cabcb794..2385988247d4 100644
--- a/BaseTools/Source/Python/Common/MigrationUtilities.py
+++ b/BaseTools/Source/Python/Common/MigrationUtilities.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/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 97d76b66936e..6878522d59d5 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
@@ -1883,7 +1884,7 @@ def SplitOption(OptionString):
def CommonPath(PathList):
P1 = min(PathList).split(os.path.sep)
P2 = 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] != 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/Python/Common/Parsing.py
index 584fc7f3c3a0..9caa9424d8ed 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 String import *
from CommonDataClass.DataClass import *
from DataType import *
diff --git a/BaseTools/Source/Python/Common/RangeExpression.py b/BaseTools/Source/Python/Common/RangeExpression.py
index ee33ae3d3266..4357f240f423 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/Common/String.py b/BaseTools/Source/Python/Common/String.py
index 4a8c03e88e28..e6c7a3b74ee1 100644
--- a/BaseTools/Source/Python/Common/String.py
+++ b/BaseTools/Source/Python/Common/String.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/BaseTools/Source/Python/Common/ToolDefClassObject.py
index dc90b4783f2f..6dab179efc01 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 5864758950ce..92259999853c 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 IMPLIED.
#
+from builtins import range
import Common.LongFilePathOs as os
import re
from CommonDataClass.DataClass import *
diff --git a/BaseTools/Source/Python/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 IMPLIED.
#
+from builtins import range
import Common.LongFilePathOs as os
from CommonDataClass.DataClass import *
from EccToolError import *
@@ -112,7 +113,7 @@ def ParseHeaderCommentSection(CommentList, FileName = None):
#
Last = 0
HeaderCommentStage = HEADER_COMMENT_NOT_STARTED
- for Index in xrange(len(CommentList)-1, 0, -1):
+ for Index in range(len(CommentList)-1, 0, -1):
Line = CommentList[Index][0]
if _IsCopyrightLine(Line):
Last = Index
diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
index 2fef87c4180a..e04b67732141 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/FvImage.py b/BaseTools/Source/Python/Eot/FvImage.py
index 9d8f0864dc41..64a27217e4a8 100644
--- a/BaseTools/Source/Python/Eot/FvImage.py
+++ b/BaseTools/Source/Python/Eot/FvImage.py
@@ -14,6 +14,7 @@
## Import Modules
#
from __future__ import print_function
+from builtins import range
import Common.LongFilePathOs as os
import re
import sys
diff --git a/BaseTools/Source/Python/Eot/InfParserLite.py b/BaseTools/Source/Python/Eot/InfParserLite.py
index f624837f2587..4bdd60a6f71c 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/Source/Python/GenFds/AprioriSection.py
index 70e2e5a3baf2..27fe2619a35f 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 12ec95b56501..cbfea730ef18 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 be8b885d069e..615d9e39faf1 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/Python/GenFds/GenFds.py
index 4415b44ef77c..0aadbbd080b3 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/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
index 393820651a11..94b8fedb233b 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/Python/GenFds/Region.py
index c946758cf549..5b9b203cf475 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
@@ -56,7 +57,7 @@ class Region(RegionClassObject):
PadByte = pack('B', 0xFF)
else:
PadByte = pack('B', 0)
- PadData = ''.join(PadByte for i in xrange(0, Size))
+ PadData = ''.join(PadByte for i in range(0, Size))
Buffer.write(PadData)
## AddToBuffer()
diff --git a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py b/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py
index 882da81930da..9bb4d43a969f 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 sys
diff --git a/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py b/BaseTools/Source/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
+from builtins import range
import os
import sys
import argparse
@@ -88,7 +89,7 @@ if __name__ == '__main__':
parser.add_argument("--signature-size", dest='SignatureSizeStr', type=str, help="specify the signature size for decode process.")
parser.add_argument("-v", "--verbose", dest='Verbose', action="store_true", help="increase output messages")
parser.add_argument("-q", "--quiet", dest='Quiet', action="store_true", help="reduce output messages")
- parser.add_argument("--debug", dest='Debug', type=int, metavar='[0-9]', choices=range(0,10), default=0, help="set debug level")
+ parser.add_argument("--debug", dest='Debug', type=int, metavar='[0-9]', choices=list(range(0,10)), default=0, help="set debug level")
parser.add_argument(metavar="input_file", dest='InputFile', type=argparse.FileType('rb'), help="specify the input filename")
#
diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
index 2aa6877c92be..1641968ace0e 100644
--- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
+++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
@@ -24,6 +24,7 @@ Rsa2048Sha256GenerateKeys
'''
from __future__ import print_function
+from builtins import range
import os
import sys
import argparse
@@ -51,7 +52,7 @@ if __name__ == '__main__':
parser.add_argument("--public-key-hash-c", dest='PublicKeyHashCFile', type=argparse.FileType('wb'), help="specify the public key hash filename that is SHA 256 hash of 2048 bit RSA public key in C structure format")
parser.add_argument("-v", "--verbose", dest='Verbose', action="store_true", help="increase output messages")
parser.add_argument("-q", "--quiet", dest='Quiet', action="store_true", help="reduce output messages")
- parser.add_argument("--debug", dest='Debug', type=int, metavar='[0-9]', choices=range(0,10), default=0, help="set debug level")
+ parser.add_argument("--debug", dest='Debug', type=int, metavar='[0-9]', choices=list(range(0,10)), default=0, help="set debug level")
#
# Parse command line arguments
diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py
index 8c235ae51e7e..2a19ad973b91 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
+from builtins import range
import os
import sys
import argparse
@@ -71,7 +72,7 @@ if __name__ == '__main__':
parser.add_argument("--private-key", dest='PrivateKeyFile', type=argparse.FileType('rb'), help="specify the private key filename. If not specified, a test signing key is used.")
parser.add_argument("-v", "--verbose", dest='Verbose', action="store_true", help="increase output messages")
parser.add_argument("-q", "--quiet", dest='Quiet', action="store_true", help="reduce output messages")
- parser.add_argument("--debug", dest='Debug', type=int, metavar='[0-9]', choices=range(0,10), default=0, help="set debug level")
+ parser.add_argument("--debug", dest='Debug', type=int, metavar='[0-9]', choices=list(range(0,10)), default=0, help="set debug level")
parser.add_argument(metavar="input_file", dest='InputFile', type=argparse.FileType('rb'), help="specify the input filename")
#
diff --git a/BaseTools/Source/Python/Trim/Trim.py b/BaseTools/Source/Python/Trim/Trim.py
index 05ba86262133..94f6b1bc707a 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/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py
index d7eaf3ea1d12..517f2a6cdecd 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 += '|' + FFE
ModuleList = LibraryClass.GetSupModuleList()
ArchList = LibraryClass.GetSupArchList()
- for Index in xrange(0, len(ArchList)):
+ for Index in range(0, len(ArchList)):
ArchList[Index] = ConvertArchForInstall(ArchList[Index])
ArchList.sort()
SortedArch = ' '.join(ArchList)
@@ -574,7 +575,7 @@ def GenUserExtensions(ModuleObject):
# if not Statement:
# continue
ArchList = UserExtension.GetSupArchList()
- for Index in xrange(0, len(ArchList)):
+ for Index in range(0, len(ArchList)):
ArchList[Index] = ConvertArchForInstall(ArchList[Index])
ArchList.sort()
KeyList = []
diff --git a/BaseTools/Source/Python/UPT/Library/CommentParsing.py b/BaseTools/Source/Python/UPT/Library/CommentParsing.py
index 9cd7b60e16ab..b97a051137e1 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
from Library.String import GetSplitValueList
@@ -74,7 +75,7 @@ def ParseHeaderCommentSection(CommentList, FileName = None, IsBinaryHeader = Fal
# first find the last copyright line
#
Last = 0
- for Index in xrange(len(CommentList)-1, 0, -1):
+ for Index in range(len(CommentList)-1, 0, -1):
Line = CommentList[Index][0]
if _IsCopyrightLine(Line):
Last = Index
diff --git a/BaseTools/Source/Python/UPT/Library/Misc.py b/BaseTools/Source/Python/UPT/Library/Misc.py
index 0d92cb3767c6..24e0a20daf87 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 = min(PathList).split(os.path.sep)
Path2 = 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] != 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 == -1:
FirstPos = StartPos
- for Index in xrange(StartPos, EndPos+1):
+ for Index in range(StartPos, EndPos+1):
LineList[Index] = ''
FindEdkBlockComment = False
elif Line.find("//") != -1 and not Line.startswith("#"):
diff --git a/BaseTools/Source/Python/UPT/Library/Parsing.py b/BaseTools/Source/Python/UPT/Library/Parsing.py
index c34e7751442a..bac664506f4d 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
@@ -973,7 +974,7 @@ def GenSection(SectionName, SectionDict, SplitArch=True, NeedBlankLine=False):
ArchList = GetSplitValueList(SectionAttrs, DataType.TAB_COMMENT_SPLIT)
else:
ArchList = [SectionAttrs]
- for Index in xrange(0, len(ArchList)):
+ for Index in range(0, len(ArchList)):
ArchList[Index] = ConvertArchForInstall(ArchList[Index])
Section = '[' + SectionName + '.' + (', ' + SectionName + '.').join(ArchList) + ']'
else:
diff --git a/BaseTools/Source/Python/UPT/Library/String.py b/BaseTools/Source/Python/UPT/Library/String.py
index 278073e4a379..2f916324bd13 100644
--- a/BaseTools/Source/Python/UPT/Library/String.py
+++ b/BaseTools/Source/Python/UPT/Library/String.py
@@ -18,6 +18,7 @@ String
##
# 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/BaseTools/Source/Python/UPT/Library/UniClassObject.py
index 84958ae38cef..d07c26abd9c2 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 Modules
#
+from builtins import range
import os, codecs, re
import distutils.util
from Logger import ToolError
@@ -515,7 +516,7 @@ class UniFileClassObject(object):
FileIn[LineCount-1] = Line
FileIn[LineCount] = '\r\n'
LineCount -= 1
- for Index in xrange (LineCount + 1, len (FileIn) - 1):
+ for Index in range (LineCount + 1, len (FileIn) - 1):
if (Index == len(FileIn) -1):
FileIn[Index] = '\r\n'
else:
diff --git a/BaseTools/Source/Python/UPT/Parser/DecParserMisc.py b/BaseTools/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
## Import modules
#
+from builtins import range
import os
import Logger.Log as Logger
from Logger.ToolError import FILE_PARSE_FAILURE
diff --git a/BaseTools/Source/Python/UPT/Parser/InfSectionParser.py b/BaseTools/Source/Python/UPT/Parser/InfSectionParser.py
index 727164c2c244..ac821deded0a 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
@@ -455,7 +456,7 @@ class InfSectionParser(InfDefinSectionParser,
Arch = Match.groups(1)[0].upper()
ArchList.append(Arch)
CommentSoFar = ''
- for Index in xrange(1, len(List)):
+ for Index in range(1, len(List)):
Result = ParseComment(List[Index], DT.ALL_USAGE_TOKENS, TokenDict, [], False)
Usage = Result[0]
Type = Result[1]
diff --git a/BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py b/BaseTools/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 Modules
#
+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/UPT/UPT.py
index 0bfcc44e3f19..3296ee3d3d8f 100644
--- a/BaseTools/Source/Python/UPT/UPT.py
+++ b/BaseTools/Source/Python/UPT/UPT.py
@@ -19,6 +19,7 @@ UPT
## import modules
#
+from builtins import range
import locale
import sys
encoding = locale.getdefaultlocale()[1]
diff --git a/BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py b/BaseTools/Source/Python/UPT/UnitTest/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 IMPLIED.
from __future__ import print_function
+from builtins import range
import os
#import Object.Parser.InfObject as InfObject
from Object.Parser.InfCommonObject import CurrentLine
diff --git a/BaseTools/Source/Python/UPT/Xml/IniToXml.py b/BaseTools/Source/Python/UPT/Xml/IniToXml.py
index 037471056d81..79db9a31a28b 100644
--- a/BaseTools/Source/Python/UPT/Xml/IniToXml.py
+++ b/BaseTools/Source/Python/UPT/Xml/IniToXml.py
@@ -16,6 +16,7 @@
IniToXml
'''
+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/Source/Python/UPT/Xml/XmlParser.py
index 58959081d0ab..b4d52f7bdc1f 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
from Library.Xml.XmlRoutines import XmlNode
diff --git a/BaseTools/Source/Python/UPT/Xml/XmlParserMisc.py b/BaseTools/Source/Python/UPT/Xml/XmlParserMisc.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 import ERR_XML_PARSER_REQUIRED_ITEM_MISSING
from Logger.ToolError import PARSER_ERROR
@@ -53,7 +54,7 @@ def ConvertVariableName(VariableName):
if SecondByte != 0:
return None
- if FirstByte not in xrange(0x20, 0x7F):
+ if FirstByte not in range(0x20, 0x7F):
return None
TransferedStr += ('%c')%FirstByte
Index = Index + 2
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index a482c94b6fdc..e9fe533b3975 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.String 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 67c08ee47841..9fc2e681b73d 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 IMPLIED.
#
+from builtins import range
from Common.String import *
from Common.DataType import *
from Common.Misc import *
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index 9bcb017c0c45..4ad60498488b 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
index c52b8bd94234..1202289616ee 100644
--- a/BaseTools/Tests/TestTools.py
+++ b/BaseTools/Tests/TestTools.py
@@ -16,6 +16,7 @@
# Import Modules
#
from __future__ import print_function
+from builtins import range
import base64
import os
import os.path
@@ -162,7 +163,7 @@ class BaseToolsTest(unittest.TestCase):
if maxlen is None: maxlen = minlen
return ''.join(
[chr(random.randint(0,255))
- for x in xrange(random.randint(minlen, maxlen))
+ for x in range(random.randint(minlen, maxlen))
])
def setUp(self):
diff --git a/BaseTools/Tests/TianoCompress.py b/BaseTools/Tests/TianoCompress.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-build.py
index 643fec58a457..f7d0308bd9fa 100755
--- a/BaseTools/gcc/mingw-gcc-build.py
+++ b/BaseTools/gcc/mingw-gcc-build.py
@@ -18,6 +18,7 @@
from __future__ import print_function
+from builtins import range
from optparse import OptionParser
import os
import shutil
--
2.16.1
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
© 2016 - 2024 Red Hat, Inc.