Revert BaseTools: PYTHON3 migration

This reverts commit 6693f359b3c213513c5096a06c6f67244a44dc52..
678f851312.

Python3 migration is the fundamental change. It requires every developer
to install Python3. Before this migration, the well communication and wide
verification must be done. But now, most people is not aware of this change,
and not try it. So, Python3 migration is reverted and be moved to edk2-staging
Python3 branch for the edk2 user evaluation.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Liming Gao
2018-10-15 08:27:53 +08:00
parent 678f851312
commit 1ccc4d895d
182 changed files with 48049 additions and 15099 deletions

View File

@@ -620,11 +620,11 @@ class _DecPcd(_DecBase):
if not IsValidToken(PCD_TOKEN_PATTERN, Token):
self._LoggerError(ST.ERR_DECPARSE_PCD_TOKEN % Token)
elif not Token.startswith('0x') and not Token.startswith('0X'):
if int(Token) > 4294967295:
if long(Token) > 4294967295:
self._LoggerError(ST.ERR_DECPARSE_PCD_TOKEN_INT % Token)
Token = hex(int(Token))
Token = hex(long(Token))[:-1]
IntToken = int(Token, 0)
IntToken = long(Token, 0)
if (Guid, IntToken) in self.TokenMap:
if self.TokenMap[Guid, IntToken] != CName:
self._LoggerError(ST.ERR_DECPARSE_PCD_TOKEN_UNIQUE%(Token))
@@ -752,7 +752,7 @@ class _DecUserExtension(_DecBase):
class Dec(_DecBase, _DecComments):
def __init__(self, DecFile, Parse = True):
try:
Content = ConvertSpecialChar(open(DecFile, 'r').readlines())
Content = ConvertSpecialChar(open(DecFile, 'rb').readlines())
except BaseException:
Logger.Error(TOOL_NAME, FILE_OPEN_FAILURE, File=DecFile,
ExtraData=ST.ERR_DECPARSE_FILEOPEN % DecFile)

View File

@@ -151,7 +151,7 @@ def IsValidNumValUint8(Token):
else:
Base = 10
try:
TokenValue = int(Token, Base)
TokenValue = long(Token, Base)
except BaseException:
Valid, Cause = IsValidLogicalExpr(Token, True)
if Cause:
@@ -262,7 +262,7 @@ def IsValidPcdDatum(Type, Value):
Value = Value.lstrip('0')
if not Value:
return True, ""
Value = int(Value, 0)
Value = long(Value, 0)
TypeLenMap = {
#
# 0x00 - 0xff

View File

@@ -205,7 +205,7 @@ def GetFileLineContent(FileName, WorkSpace, LineNo, OriginalString):
try:
FullFileName = FullFileName.replace('\\', '/')
Inputfile = open(FullFileName, "r")
Inputfile = open(FullFileName, "rb", 0)
try:
FileLinesList = Inputfile.readlines()
except BaseException:

View File

@@ -51,7 +51,7 @@ def OpenInfFile(Filename):
FileLinesList = []
try:
FInputfile = open(Filename, "r")
FInputfile = open(Filename, "rb", 0)
try:
FileLinesList = FInputfile.readlines()
except BaseException:
@@ -86,7 +86,7 @@ class InfParser(InfSectionParser):
#
# Call parent class construct function
#
super().__init__()
super(InfParser, self).__init__()
self.WorkspaceDir = WorkspaceDir
self.SupArchList = DT.ARCH_LIST

View File

@@ -206,7 +206,7 @@ class InfSectionParser(InfDefinSectionParser,
if FilePath in cls.MetaFiles:
return cls.MetaFiles[FilePath]
else:
ParserObject = super().__new__(cls)
ParserObject = super(InfSectionParser, cls).__new__(cls)
cls.MetaFiles[FilePath] = ParserObject
return ParserObject
@@ -227,7 +227,7 @@ class InfSectionParser(InfDefinSectionParser,
self.InfBuildOptionSection = InfBuildOptionsObject()
self.InfLibraryClassSection = InfLibraryClassObject()
self.InfPackageSection = InfPackageObject()
self.InfPcdSection = InfPcdObject(list(self.MetaFiles.keys())[0])
self.InfPcdSection = InfPcdObject(self.MetaFiles.keys()[0])
self.InfSourcesSection = InfSourcesObject()
self.InfUserExtensionSection = InfUserExtensionObject()
self.InfProtocolSection = InfProtocolObject()
@@ -455,7 +455,7 @@ class InfSectionParser(InfDefinSectionParser,
Arch = Match.groups(1)[0].upper()
ArchList.append(Arch)
CommentSoFar = ''
for Index in range(1, len(List)):
for Index in xrange(1, len(List)):
Result = ParseComment(List[Index], DT.ALL_USAGE_TOKENS, TokenDict, [], False)
Usage = Result[0]
Type = Result[1]