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/FormatDosFiles.py | 3 ++-
BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py | 1 +
BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py | 1 +
BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py | 1 +
BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/doxygengen.py | 3 ++-
BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/doxygengen_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
+from builtins import range
import sys
import argparse
import re
@@ -100,7 +101,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/FormatDosFiles.py b/BaseTools/Scripts/FormatDosFiles.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__ == "__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')
parser.add_argument('--exclude', dest='Exclude', nargs='+', help="directory name or file name which will be excluded")
args = parser.parse_args()
diff --git a/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py b/BaseTools/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 @@
#
from __future__ import print_function
+from builtins import range
import os, sys, logging, traceback, subprocess
from optparse import OptionParser
diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py
index 290287b817e7..5e5f6526d3a6 100644
--- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py
+++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py
@@ -12,6 +12,7 @@
#
from __future__ import print_function
+from builtins import range
import array
import uuid
import re
diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py
index ea83327052f2..d7a4a3e4c42a 100644
--- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py
+++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py
@@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
+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/EdkPlugins/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/model/doxygengen.py
@@ -16,6 +16,7 @@
"""This file produce action class to generate doxygen document for edk2 codebase.
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)
no = 0
- for no in xrange(len(lines)):
+ for no in range(len(lines)):
if len(lines[no].strip()) == 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/model/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 IMPLIED.
+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 = 0
- for no in xrange(len(lines)):
+ for no in range(len(lines)):
if len(lines[no].strip()) == 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 @@
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 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/Source/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/Python/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 @@
## 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 IMPLIED.
#
+from builtins import range
from StringIO import StringIO
from Common.Misc import *
from Common.StringUtils import StringToArray
@@ -257,7 +258,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:
Offset = self.ItemSize * Index
@@ -344,7 +345,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
@@ -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 += len(self.RawDataList[ItemIndex])
else:
for innerIndex in range(Index):
@@ -494,14 +495,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
@@ -510,7 +511,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
@@ -698,7 +699,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()
@@ -710,7 +711,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
@@ -736,7 +737,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
@@ -756,7 +757,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 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 += valuedict[current_valuedict_key]
return var_value
diff --git a/BaseTools/Source/Python/AutoGen/InfSectionParser.py b/BaseTools/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
#
+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 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
import Common.EdkLogger as EdkLogger
diff --git a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.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 import *
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 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/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/Common/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 = 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 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/Python/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/Common/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/BaseTools/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 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 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/Eot/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/InfParserLite.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/Source/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/Python/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/BaseTools/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/Python/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 = 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 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 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 ca4f64864790..ca0093bf117e 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 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
+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 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/BaseTools/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 += '|' + 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 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
from Library.StringUtils 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 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 = 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 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
@@ -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/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/BaseTools/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 Modules
#
+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] = 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 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
@@ -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 2644dbed31e9..930f0c1b9d54 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 aa6f23011b17..529668895eb3 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 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
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 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 IMPLIED.
#
+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/BaseTools/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
index be7b4ad42856..37338fd60db7 100644
--- a/BaseTools/Tests/TestTools.py
+++ b/BaseTools/Tests/TestTools.py
@@ -16,6 +16,7 @@ from __future__ import print_function
##
# Import Modules
#
+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.17.1
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
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] Sent: Thursday, June 21, 2018 12:44 PM To: edk2-devel@lists.01.org Cc: Zhu, Yonghong <yonghong.zhu@intel.com>; Gao, Liming <liming.gao@intel.com> Subject: [PATCH v3 05/20] BaseTools: Use the python3-range functions 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/FormatDosFiles.py | 3 ++- BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py | 1 + BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py | 1 + BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py | 1 + BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/doxygengen.py | 3 ++- BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/doxygengen_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 +from builtins import range import sys import argparse import re @@ -100,7 +101,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/FormatDosFiles.py b/BaseTools/Scripts/FormatDosFiles.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__ == "__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') parser.add_argument('--exclude', dest='Exclude', nargs='+', help="directory name or file name which will be excluded") args = parser.parse_args() diff --git a/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py b/BaseTools/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 @@ # from __future__ import print_function +from builtins import range import os, sys, logging, traceback, subprocess from optparse import OptionParser diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py index 290287b817e7..5e5f6526d3a6 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemode +++ l/efibinary.py @@ -12,6 +12,7 @@ # from __future__ import print_function +from builtins import range import array import uuid import re diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py index ea83327052f2..d7a4a3e4c42a 100644 --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.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 IMPLIED. # +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/EdkPlugins/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 codebase. 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) no = 0 - for no in xrange(len(lines)): + for no in range(len(lines)): if len(lines[no].strip()) == 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 IMPLIED. +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 = 0 - for no in xrange(len(lines)): + for no in range(len(lines)): if len(lines[no].strip()) == 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 @@ 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 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/Source/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/Python/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 @@ ## 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 IMPLIED. # +from builtins import range from StringIO import StringIO from Common.Misc import * from Common.StringUtils import StringToArray @@ -257,7 +258,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: Offset = self.ItemSize * Index @@ -344,7 +345,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 @@ -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 += len(self.RawDataList[ItemIndex]) else: for innerIndex in range(Index): @@ -494,14 +495,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 @@ -510,7 +511,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 @@ -698,7 +699,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() @@ -710,7 +711,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 @@ -736,7 +737,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 @@ -756,7 +757,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 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 += valuedict[current_valuedict_key] return var_value diff --git a/BaseTools/Source/Python/AutoGen/InfSectionParser.py b/BaseTools/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 # +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 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 import Common.EdkLogger as EdkLogger diff --git a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.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 import * 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 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/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/Common/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 = 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 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/Python/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/Common/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/BaseTools/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 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 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/Eot/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/InfParserLite.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/Source/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/Python/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/BaseTools/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/Python/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 = 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 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 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 ca4f64864790..ca0093bf117e 100644 --- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py +++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKey +++ s.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 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 +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 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/BaseTools/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 += '|' + 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 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 from Library.StringUtils 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 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 = 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 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 @@ -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/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/BaseTools/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 Modules # +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] = 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 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 @@ -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 2644dbed31e9..930f0c1b9d54 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 aa6f23011b17..529668895eb3 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 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 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 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 IMPLIED. # +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/BaseTools/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 index be7b4ad42856..37338fd60db7 100644 --- a/BaseTools/Tests/TestTools.py +++ b/BaseTools/Tests/TestTools.py @@ -16,6 +16,7 @@ from __future__ import print_function ## # Import Modules # +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.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
On Thu, Jun 21, 2018 at 12:40:29PM +0000, Zhu, Yonghong wrote: > 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. > Urhh, I thought it's a "built-in" module but it's actually from python-future. I'll revert this patch and post a new patchset. BTW, would you might review the first patch? It's just a typo fix and I just caught it while running the futurize script, so the patch is actually independent from this patch series. Thanks, Gary Lin > Best Regards, > Zhu Yonghong > > > -----Original Message----- > From: Gary Lin [mailto:glin@suse.com] > Sent: Thursday, June 21, 2018 12:44 PM > To: edk2-devel@lists.01.org > Cc: Zhu, Yonghong <yonghong.zhu@intel.com>; Gao, Liming <liming.gao@intel.com> > Subject: [PATCH v3 05/20] BaseTools: Use the python3-range functions > > 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/FormatDosFiles.py | 3 ++- > BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py | 1 + > BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py | 1 + > BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py | 1 + > BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/doxygengen.py | 3 ++- > BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/doxygengen_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 > > +from builtins import range > import sys > import argparse > import re > @@ -100,7 +101,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/FormatDosFiles.py b/BaseTools/Scripts/FormatDosFiles.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__ == "__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') > parser.add_argument('--exclude', dest='Exclude', nargs='+', help="directory name or file name which will be excluded") > args = parser.parse_args() > diff --git a/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py b/BaseTools/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 @@ > # > > from __future__ import print_function > +from builtins import range > import os, sys, logging, traceback, subprocess from optparse import OptionParser > > diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py > index 290287b817e7..5e5f6526d3a6 100644 > --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py > +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemode > +++ l/efibinary.py > @@ -12,6 +12,7 @@ > # > > from __future__ import print_function > +from builtins import range > import array > import uuid > import re > diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py > index ea83327052f2..d7a4a3e4c42a 100644 > --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.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 IMPLIED. > # > > +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/EdkPlugins/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 codebase. > 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) > > no = 0 > - for no in xrange(len(lines)): > + for no in range(len(lines)): > if len(lines[no].strip()) == 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 IMPLIED. > > +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 = 0 > - for no in xrange(len(lines)): > + for no in range(len(lines)): > if len(lines[no].strip()) == 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 @@ > > 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 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/Source/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/Python/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 @@ > > ## 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 IMPLIED. > # > +from builtins import range > from StringIO import StringIO > from Common.Misc import * > from Common.StringUtils import StringToArray @@ -257,7 +258,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: > Offset = self.ItemSize * Index @@ -344,7 +345,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 > @@ -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 += len(self.RawDataList[ItemIndex]) > else: > for innerIndex in range(Index): > @@ -494,14 +495,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 > @@ -510,7 +511,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 > @@ -698,7 +699,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() > @@ -710,7 +711,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 > @@ -736,7 +737,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 > @@ -756,7 +757,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 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 += valuedict[current_valuedict_key] > return var_value > diff --git a/BaseTools/Source/Python/AutoGen/InfSectionParser.py b/BaseTools/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 > # > > +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 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 import Common.EdkLogger as EdkLogger diff --git a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.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 import * 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 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/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/Common/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 = 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 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/Python/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/Common/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/BaseTools/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 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 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/Eot/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/InfParserLite.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/Source/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/Python/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/BaseTools/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/Python/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 = 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 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 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 ca4f64864790..ca0093bf117e 100644 > --- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py > +++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKey > +++ s.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 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 > > +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 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/BaseTools/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 += '|' + 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 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 > > from Library.StringUtils 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 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 = 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 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 > > @@ -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/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/BaseTools/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 Modules # > +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] = 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 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 > > @@ -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 2644dbed31e9..930f0c1b9d54 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 aa6f23011b17..529668895eb3 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 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 > > 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 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 IMPLIED. > # > > +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/BaseTools/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 index be7b4ad42856..37338fd60db7 100644 > --- a/BaseTools/Tests/TestTools.py > +++ b/BaseTools/Tests/TestTools.py > @@ -16,6 +16,7 @@ from __future__ import print_function ## # Import Modules # > +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.17.1 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel > _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
Hi Gary, Patch 03 used some Tab characters, Patch 17 has some Trailing whitespace. You can use the BaseTools\Scripts\PatchCheck.py to check its format. I try to build OVMF platform, it directly report error: from .BuildReport import BuildReport ValueError: Attempted relative import in non-package Best Regards, Zhu Yonghong -----Original Message----- From: Gary Lin [mailto:glin@suse.com] Sent: Friday, June 22, 2018 10:04 AM To: Zhu, Yonghong <yonghong.zhu@intel.com> Cc: edk2-devel@lists.01.org; Gao, Liming <liming.gao@intel.com> Subject: Re: [edk2] [PATCH v3 05/20] BaseTools: Use the python3-range functions On Thu, Jun 21, 2018 at 12:40:29PM +0000, Zhu, Yonghong wrote: > 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. > Urhh, I thought it's a "built-in" module but it's actually from python-future. I'll revert this patch and post a new patchset. BTW, would you might review the first patch? It's just a typo fix and I just caught it while running the futurize script, so the patch is actually independent from this patch series. Thanks, Gary Lin > Best Regards, > Zhu Yonghong > > > -----Original Message----- > From: Gary Lin [mailto:glin@suse.com] > Sent: Thursday, June 21, 2018 12:44 PM > To: edk2-devel@lists.01.org > Cc: Zhu, Yonghong <yonghong.zhu@intel.com>; Gao, Liming <liming.gao@intel.com> > Subject: [PATCH v3 05/20] BaseTools: Use the python3-range functions > > 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/FormatDosFiles.py | 3 ++- > BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py | 1 + > BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py | 1 + > BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py | 1 + > BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/doxygengen.py | 3 ++- > BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/doxygengen_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 > > +from builtins import range > import sys > import argparse > import re > @@ -100,7 +101,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/FormatDosFiles.py b/BaseTools/Scripts/FormatDosFiles.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__ == "__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') > parser.add_argument('--exclude', dest='Exclude', nargs='+', help="directory name or file name which will be excluded") > args = parser.parse_args() > diff --git a/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py b/BaseTools/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 @@ > # > > from __future__ import print_function > +from builtins import range > import os, sys, logging, traceback, subprocess from optparse import OptionParser > > diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py > index 290287b817e7..5e5f6526d3a6 100644 > --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py > +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemode > +++ l/efibinary.py > @@ -12,6 +12,7 @@ > # > > from __future__ import print_function > +from builtins import range > import array > import uuid > import re > diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py > index ea83327052f2..d7a4a3e4c42a 100644 > --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.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 IMPLIED. > # > > +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/EdkPlugins/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 codebase. > 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) > > no = 0 > - for no in xrange(len(lines)): > + for no in range(len(lines)): > if len(lines[no].strip()) == 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 IMPLIED. > > +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 = 0 > - for no in xrange(len(lines)): > + for no in range(len(lines)): > if len(lines[no].strip()) == 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 @@ > > 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 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/Source/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/Python/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 @@ > > ## 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 IMPLIED. > # > +from builtins import range > from StringIO import StringIO > from Common.Misc import * > from Common.StringUtils import StringToArray @@ -257,7 +258,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: > Offset = self.ItemSize * Index @@ -344,7 +345,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 > @@ -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 += len(self.RawDataList[ItemIndex]) > else: > for innerIndex in range(Index): > @@ -494,14 +495,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 > @@ -510,7 +511,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 > @@ -698,7 +699,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() > @@ -710,7 +711,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 > @@ -736,7 +737,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 > @@ -756,7 +757,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 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 += valuedict[current_valuedict_key] > return var_value > diff --git a/BaseTools/Source/Python/AutoGen/InfSectionParser.py b/BaseTools/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 > # > > +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 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 import Common.EdkLogger as EdkLogger diff --git a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.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 import * 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 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/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/Common/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 = 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 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/Python/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/Common/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/BaseTools/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 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 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/Eot/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/InfParserLite.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/Source/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/Python/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/BaseTools/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/Python/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 = 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 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 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 ca4f64864790..ca0093bf117e 100644 > --- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py > +++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKey > +++ s.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 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 > > +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 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/BaseTools/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 += '|' + 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 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 > > from Library.StringUtils 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 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 = 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 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 > > @@ -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/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/BaseTools/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 Modules # > +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] = 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 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 > > @@ -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 2644dbed31e9..930f0c1b9d54 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 aa6f23011b17..529668895eb3 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 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 > > 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 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 IMPLIED. > # > > +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/BaseTools/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 index be7b4ad42856..37338fd60db7 100644 > --- a/BaseTools/Tests/TestTools.py > +++ b/BaseTools/Tests/TestTools.py > @@ -16,6 +16,7 @@ from __future__ import print_function ## # Import Modules # > +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.17.1 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel > _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
On Fri, Jun 22, 2018 at 05:29:21AM +0000, Zhu, Yonghong wrote: > Hi Gary, > > Patch 03 used some Tab characters, Patch 17 has some Trailing whitespace. You can use the BaseTools\Scripts\PatchCheck.py to check its format. > Ok, will fix them in the next version. > I try to build OVMF platform, it directly report error: > from .BuildReport import BuildReport > ValueError: Attempted relative import in non-package > I didn't see this in my system. Will investigate what's wrong. Thanks, Gary Lin > Best Regards, > Zhu Yonghong > > -----Original Message----- > From: Gary Lin [mailto:glin@suse.com] > Sent: Friday, June 22, 2018 10:04 AM > To: Zhu, Yonghong <yonghong.zhu@intel.com> > Cc: edk2-devel@lists.01.org; Gao, Liming <liming.gao@intel.com> > Subject: Re: [edk2] [PATCH v3 05/20] BaseTools: Use the python3-range functions > > On Thu, Jun 21, 2018 at 12:40:29PM +0000, Zhu, Yonghong wrote: > > 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. > > > Urhh, I thought it's a "built-in" module but it's actually from > python-future. > > I'll revert this patch and post a new patchset. > BTW, would you might review the first patch? It's just a typo fix and I > just caught it while running the futurize script, so the patch is > actually independent from this patch series. > > Thanks, > > Gary Lin > > > Best Regards, > > Zhu Yonghong > > > > > > -----Original Message----- > > From: Gary Lin [mailto:glin@suse.com] > > Sent: Thursday, June 21, 2018 12:44 PM > > To: edk2-devel@lists.01.org > > Cc: Zhu, Yonghong <yonghong.zhu@intel.com>; Gao, Liming <liming.gao@intel.com> > > Subject: [PATCH v3 05/20] BaseTools: Use the python3-range functions > > > > 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/FormatDosFiles.py | 3 ++- > > BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py | 1 + > > BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py | 1 + > > BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py | 1 + > > BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/doxygengen.py | 3 ++- > > BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/edk2/model/doxygengen_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 > > > > +from builtins import range > > import sys > > import argparse > > import re > > @@ -100,7 +101,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/FormatDosFiles.py b/BaseTools/Scripts/FormatDosFiles.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__ == "__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') > > parser.add_argument('--exclude', dest='Exclude', nargs='+', help="directory name or file name which will be excluded") > > args = parser.parse_args() > > diff --git a/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py b/BaseTools/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 @@ > > # > > > > from __future__ import print_function > > +from builtins import range > > import os, sys, logging, traceback, subprocess from optparse import OptionParser > > > > diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py > > index 290287b817e7..5e5f6526d3a6 100644 > > --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py > > +++ b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemode > > +++ l/efibinary.py > > @@ -12,6 +12,7 @@ > > # > > > > from __future__ import print_function > > +from builtins import range > > import array > > import uuid > > import re > > diff --git a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.py > > index ea83327052f2..d7a4a3e4c42a 100644 > > --- a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/ini.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 IMPLIED. > > # > > > > +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/EdkPlugins/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 codebase. > > 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) > > > > no = 0 > > - for no in xrange(len(lines)): > > + for no in range(len(lines)): > > if len(lines[no].strip()) == 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 IMPLIED. > > > > +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 = 0 > > - for no in xrange(len(lines)): > > + for no in range(len(lines)): > > if len(lines[no].strip()) == 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 @@ > > > > 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 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/Source/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/Python/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 @@ > > > > ## 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 IMPLIED. > > # > > +from builtins import range > > from StringIO import StringIO > > from Common.Misc import * > > from Common.StringUtils import StringToArray @@ -257,7 +258,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: > > Offset = self.ItemSize * Index @@ -344,7 +345,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 > > @@ -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 += len(self.RawDataList[ItemIndex]) > > else: > > for innerIndex in range(Index): > > @@ -494,14 +495,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 > > @@ -510,7 +511,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 > > @@ -698,7 +699,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() > > @@ -710,7 +711,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 > > @@ -736,7 +737,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 > > @@ -756,7 +757,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 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 += valuedict[current_valuedict_key] > > return var_value > > diff --git a/BaseTools/Source/Python/AutoGen/InfSectionParser.py b/BaseTools/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 > > # > > > > +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 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 import Common.EdkLogger as EdkLogger diff --git a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.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 import * 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 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/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/Common/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 = 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 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/Python/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/Common/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/BaseTools/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 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 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/Eot/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/InfParserLite.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/Source/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/Python/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/BaseTools/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/Python/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 = 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 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 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 ca4f64864790..ca0093bf117e 100644 > > --- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py > > +++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKey > > +++ s.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 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 > > > > +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 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/BaseTools/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 += '|' + 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 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 > > > > from Library.StringUtils 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 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 = 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 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 > > > > @@ -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/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/BaseTools/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 Modules # > > +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] = 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 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 > > > > @@ -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 2644dbed31e9..930f0c1b9d54 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 aa6f23011b17..529668895eb3 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 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 > > > > 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 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 IMPLIED. > > # > > > > +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/BaseTools/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 index be7b4ad42856..37338fd60db7 100644 > > --- a/BaseTools/Tests/TestTools.py > > +++ b/BaseTools/Tests/TestTools.py > > @@ -16,6 +16,7 @@ from __future__ import print_function ## # Import Modules # > > +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.17.1 > > > > _______________________________________________ > > edk2-devel mailing list > > edk2-devel@lists.01.org > > https://lists.01.org/mailman/listinfo/edk2-devel > > > _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
On Fri, Jun 22, 2018 at 04:21:23PM +0800, Gary Lin wrote: > On Fri, Jun 22, 2018 at 05:29:21AM +0000, Zhu, Yonghong wrote: > > Hi Gary, > > > > Patch 03 used some Tab characters, Patch 17 has some Trailing whitespace. You can use the BaseTools\Scripts\PatchCheck.py to check its format. > > > Ok, will fix them in the next version. > > > I try to build OVMF platform, it directly report error: > > from .BuildReport import BuildReport > > ValueError: Attempted relative import in non-package > > > I didn't see this in my system. Will investigate what's wrong. > Hi Yonghong, The error showed when I reverted patch 16. Would you mind to check whether patch 16 was applied or not? Thanks, Gary Lin > Thanks, > > Gary Lin > > > Best Regards, > > Zhu Yonghong > > > > -----Original Message----- > > From: Gary Lin [mailto:glin@suse.com] > > Sent: Friday, June 22, 2018 10:04 AM > > To: Zhu, Yonghong <yonghong.zhu@intel.com> > > Cc: edk2-devel@lists.01.org; Gao, Liming <liming.gao@intel.com> > > Subject: Re: [edk2] [PATCH v3 05/20] BaseTools: Use the python3-range functions > > > > On Thu, Jun 21, 2018 at 12:40:29PM +0000, Zhu, Yonghong wrote: > > > 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. > > > > > Urhh, I thought it's a "built-in" module but it's actually from > > python-future. > > > > I'll revert this patch and post a new patchset. > > BTW, would you might review the first patch? It's just a typo fix and I > > just caught it while running the futurize script, so the patch is > > actually independent from this patch series. > > > > Thanks, > > > > Gary Lin > > > > > Best Regards, > > > Zhu Yonghong > > > > > > > > > -----Original Message----- > > > From: Gary Lin [mailto:glin@suse.com] > > > Sent: Thursday, June 21, 2018 12:44 PM > > > To: edk2-devel@lists.01.org > > > Cc: Zhu, Yonghong <yonghong.zhu@intel.com>; Gao, Liming <liming.gao@intel.com> > > > Subject: [PATCH v3 05/20] BaseTools: Use the python3-range functions > > > > > > 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> _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
Hi Gary, My test env is Windows. I applied Patch 16, and seems this patch only for Linux. Best Regards, Zhu Yonghong -----Original Message----- From: Gary Lin [mailto:glin@suse.com] Sent: Friday, June 22, 2018 4:46 PM To: Zhu, Yonghong <yonghong.zhu@intel.com> Cc: edk2-devel@lists.01.org; Gao, Liming <liming.gao@intel.com> Subject: Re: [edk2] [PATCH v3 05/20] BaseTools: Use the python3-range functions On Fri, Jun 22, 2018 at 04:21:23PM +0800, Gary Lin wrote: > On Fri, Jun 22, 2018 at 05:29:21AM +0000, Zhu, Yonghong wrote: > > Hi Gary, > > > > Patch 03 used some Tab characters, Patch 17 has some Trailing whitespace. You can use the BaseTools\Scripts\PatchCheck.py to check its format. > > > Ok, will fix them in the next version. > > > I try to build OVMF platform, it directly report error: > > from .BuildReport import BuildReport > > ValueError: Attempted relative import in non-package > > > I didn't see this in my system. Will investigate what's wrong. > Hi Yonghong, The error showed when I reverted patch 16. Would you mind to check whether patch 16 was applied or not? Thanks, Gary Lin > Thanks, > > Gary Lin > > > Best Regards, > > Zhu Yonghong > > > > -----Original Message----- > > From: Gary Lin [mailto:glin@suse.com] > > Sent: Friday, June 22, 2018 10:04 AM > > To: Zhu, Yonghong <yonghong.zhu@intel.com> > > Cc: edk2-devel@lists.01.org; Gao, Liming <liming.gao@intel.com> > > Subject: Re: [edk2] [PATCH v3 05/20] BaseTools: Use the > > python3-range functions > > > > On Thu, Jun 21, 2018 at 12:40:29PM +0000, Zhu, Yonghong wrote: > > > 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. > > > > > Urhh, I thought it's a "built-in" module but it's actually from > > python-future. > > > > I'll revert this patch and post a new patchset. > > BTW, would you might review the first patch? It's just a typo fix > > and I just caught it while running the futurize script, so the patch > > is actually independent from this patch series. > > > > Thanks, > > > > Gary Lin > > > > > Best Regards, > > > Zhu Yonghong > > > > > > > > > -----Original Message----- > > > From: Gary Lin [mailto:glin@suse.com] > > > Sent: Thursday, June 21, 2018 12:44 PM > > > To: edk2-devel@lists.01.org > > > Cc: Zhu, Yonghong <yonghong.zhu@intel.com>; Gao, Liming > > > <liming.gao@intel.com> > > > Subject: [PATCH v3 05/20] BaseTools: Use the python3-range > > > functions > > > > > > 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> _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
On Fri, Jun 22, 2018 at 08:53:04AM +0000, Zhu, Yonghong wrote: > Hi Gary, > > My test env is Windows. I applied Patch 16, and seems this patch only for Linux. > Ah, right. The patch is Linux only, and sadly I only have Linux. I guess the similar change may work for windows. Could you try to modify build.bat and GenFds.bat in BaseTools\BinWrappers\WindowsLike\ as the following? @setlocal @set ToolName=%~n0% @set PYTHONPATH=%PYTHONPATH%;%BASE_TOOLS_PATH%\Source\Python @%PYTHON_HOME%\python.exe -m %ToolName%.%ToolName% %* I'm not sure whether it should be '-m' or '/m' though. The goal is treat build and GenFds as modules to avoid the error you saw. Thanks, Gary Lin > Best Regards, > Zhu Yonghong > > > -----Original Message----- > From: Gary Lin [mailto:glin@suse.com] > Sent: Friday, June 22, 2018 4:46 PM > To: Zhu, Yonghong <yonghong.zhu@intel.com> > Cc: edk2-devel@lists.01.org; Gao, Liming <liming.gao@intel.com> > Subject: Re: [edk2] [PATCH v3 05/20] BaseTools: Use the python3-range functions > > On Fri, Jun 22, 2018 at 04:21:23PM +0800, Gary Lin wrote: > > On Fri, Jun 22, 2018 at 05:29:21AM +0000, Zhu, Yonghong wrote: > > > Hi Gary, > > > > > > Patch 03 used some Tab characters, Patch 17 has some Trailing whitespace. You can use the BaseTools\Scripts\PatchCheck.py to check its format. > > > > > Ok, will fix them in the next version. > > > > > I try to build OVMF platform, it directly report error: > > > from .BuildReport import BuildReport > > > ValueError: Attempted relative import in non-package > > > > > I didn't see this in my system. Will investigate what's wrong. > > > Hi Yonghong, > > The error showed when I reverted patch 16. Would you mind to check whether patch 16 was applied or not? > > Thanks, > > Gary Lin > > > Thanks, > > > > Gary Lin > > > > > Best Regards, > > > Zhu Yonghong > > > > > > -----Original Message----- > > > From: Gary Lin [mailto:glin@suse.com] > > > Sent: Friday, June 22, 2018 10:04 AM > > > To: Zhu, Yonghong <yonghong.zhu@intel.com> > > > Cc: edk2-devel@lists.01.org; Gao, Liming <liming.gao@intel.com> > > > Subject: Re: [edk2] [PATCH v3 05/20] BaseTools: Use the > > > python3-range functions > > > > > > On Thu, Jun 21, 2018 at 12:40:29PM +0000, Zhu, Yonghong wrote: > > > > 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. > > > > > > > Urhh, I thought it's a "built-in" module but it's actually from > > > python-future. > > > > > > I'll revert this patch and post a new patchset. > > > BTW, would you might review the first patch? It's just a typo fix > > > and I just caught it while running the futurize script, so the patch > > > is actually independent from this patch series. > > > > > > Thanks, > > > > > > Gary Lin > > > > > > > Best Regards, > > > > Zhu Yonghong > > > > > > > > > > > > -----Original Message----- > > > > From: Gary Lin [mailto:glin@suse.com] > > > > Sent: Thursday, June 21, 2018 12:44 PM > > > > To: edk2-devel@lists.01.org > > > > Cc: Zhu, Yonghong <yonghong.zhu@intel.com>; Gao, Liming > > > > <liming.gao@intel.com> > > > > Subject: [PATCH v3 05/20] BaseTools: Use the python3-range > > > > functions > > > > > > > > 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> > _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
Yes, after modify build.bat and GenFds.bat, I can avoid the previous error, but a new error: build.py... d:\git\edk2_new\OvmfPkg\OvmfPkg.fdf.inc(83): error 3000: Invalid syntax/format <type 'long'> near line 83, column 0: SET gUefiOvmfPkgTokenSpaceGuid.Pcd OvmfFlashNvStorageEventLogBase = gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorag eVariableBase + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize Best Regards, Zhu Yonghong -----Original Message----- From: Gary Lin [mailto:glin@suse.com] Sent: Friday, June 22, 2018 5:13 PM To: Zhu, Yonghong <yonghong.zhu@intel.com> Cc: edk2-devel@lists.01.org; Gao, Liming <liming.gao@intel.com> Subject: Re: [edk2] [PATCH v3 05/20] BaseTools: Use the python3-range functions On Fri, Jun 22, 2018 at 08:53:04AM +0000, Zhu, Yonghong wrote: > Hi Gary, > > My test env is Windows. I applied Patch 16, and seems this patch only for Linux. > Ah, right. The patch is Linux only, and sadly I only have Linux. I guess the similar change may work for windows. Could you try to modify build.bat and GenFds.bat in BaseTools\BinWrappers\WindowsLike\ as the following? @setlocal @set ToolName=%~n0% @set PYTHONPATH=%PYTHONPATH%;%BASE_TOOLS_PATH%\Source\Python @%PYTHON_HOME%\python.exe -m %ToolName%.%ToolName% %* I'm not sure whether it should be '-m' or '/m' though. The goal is treat build and GenFds as modules to avoid the error you saw. Thanks, Gary Lin > Best Regards, > Zhu Yonghong > > > -----Original Message----- > From: Gary Lin [mailto:glin@suse.com] > Sent: Friday, June 22, 2018 4:46 PM > To: Zhu, Yonghong <yonghong.zhu@intel.com> > Cc: edk2-devel@lists.01.org; Gao, Liming <liming.gao@intel.com> > Subject: Re: [edk2] [PATCH v3 05/20] BaseTools: Use the python3-range > functions > > On Fri, Jun 22, 2018 at 04:21:23PM +0800, Gary Lin wrote: > > On Fri, Jun 22, 2018 at 05:29:21AM +0000, Zhu, Yonghong wrote: > > > Hi Gary, > > > > > > Patch 03 used some Tab characters, Patch 17 has some Trailing whitespace. You can use the BaseTools\Scripts\PatchCheck.py to check its format. > > > > > Ok, will fix them in the next version. > > > > > I try to build OVMF platform, it directly report error: > > > from .BuildReport import BuildReport > > > ValueError: Attempted relative import in non-package > > > > > I didn't see this in my system. Will investigate what's wrong. > > > Hi Yonghong, > > The error showed when I reverted patch 16. Would you mind to check whether patch 16 was applied or not? > > Thanks, > > Gary Lin > > > Thanks, > > > > Gary Lin > > > > > Best Regards, > > > Zhu Yonghong > > > > > > -----Original Message----- > > > From: Gary Lin [mailto:glin@suse.com] > > > Sent: Friday, June 22, 2018 10:04 AM > > > To: Zhu, Yonghong <yonghong.zhu@intel.com> > > > Cc: edk2-devel@lists.01.org; Gao, Liming <liming.gao@intel.com> > > > Subject: Re: [edk2] [PATCH v3 05/20] BaseTools: Use the > > > python3-range functions > > > > > > On Thu, Jun 21, 2018 at 12:40:29PM +0000, Zhu, Yonghong wrote: > > > > 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. > > > > > > > Urhh, I thought it's a "built-in" module but it's actually from > > > python-future. > > > > > > I'll revert this patch and post a new patchset. > > > BTW, would you might review the first patch? It's just a typo fix > > > and I just caught it while running the futurize script, so the > > > patch is actually independent from this patch series. > > > > > > Thanks, > > > > > > Gary Lin > > > > > > > Best Regards, > > > > Zhu Yonghong > > > > > > > > > > > > -----Original Message----- > > > > From: Gary Lin [mailto:glin@suse.com] > > > > Sent: Thursday, June 21, 2018 12:44 PM > > > > To: edk2-devel@lists.01.org > > > > Cc: Zhu, Yonghong <yonghong.zhu@intel.com>; Gao, Liming > > > > <liming.gao@intel.com> > > > > Subject: [PATCH v3 05/20] BaseTools: Use the python3-range > > > > functions > > > > > > > > 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> > _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
© 2016 - 2025 Red Hat, Inc.