summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/UPT/Parser
diff options
context:
space:
mode:
authorLiming Gao <liming.gao@intel.com>2018-10-15 08:27:53 +0800
committerLiming Gao <liming.gao@intel.com>2018-10-15 08:29:14 +0800
commit1ccc4d895dd8d659d016efcd6ef8a48749aba1d0 (patch)
tree0d5f58643cc72275887d3bb322813609906a9334 /BaseTools/Source/Python/UPT/Parser
parent678f85131238622e576705117e299d81cff755c9 (diff)
downloadedk2-1ccc4d895dd8d659d016efcd6ef8a48749aba1d0.tar.gz
edk2-1ccc4d895dd8d659d016efcd6ef8a48749aba1d0.tar.bz2
edk2-1ccc4d895dd8d659d016efcd6ef8a48749aba1d0.zip
Revert BaseTools: PYTHON3 migration
This reverts commit 6693f359b3c213513c5096a06c6f67244a44dc52.. 678f85131238622e576705117e299d81cff755c9. 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>
Diffstat (limited to 'BaseTools/Source/Python/UPT/Parser')
-rw-r--r--BaseTools/Source/Python/UPT/Parser/DecParser.py8
-rw-r--r--BaseTools/Source/Python/UPT/Parser/DecParserMisc.py4
-rw-r--r--BaseTools/Source/Python/UPT/Parser/InfAsBuiltProcess.py2
-rw-r--r--BaseTools/Source/Python/UPT/Parser/InfParser.py4
-rw-r--r--BaseTools/Source/Python/UPT/Parser/InfSectionParser.py6
5 files changed, 12 insertions, 12 deletions
diff --git a/BaseTools/Source/Python/UPT/Parser/DecParser.py b/BaseTools/Source/Python/UPT/Parser/DecParser.py
index 51dc4b2bd2..a88b51d055 100644
--- a/BaseTools/Source/Python/UPT/Parser/DecParser.py
+++ b/BaseTools/Source/Python/UPT/Parser/DecParser.py
@@ -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)
diff --git a/BaseTools/Source/Python/UPT/Parser/DecParserMisc.py b/BaseTools/Source/Python/UPT/Parser/DecParserMisc.py
index cd4d87224d..c5c35ede78 100644
--- a/BaseTools/Source/Python/UPT/Parser/DecParserMisc.py
+++ b/BaseTools/Source/Python/UPT/Parser/DecParserMisc.py
@@ -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
diff --git a/BaseTools/Source/Python/UPT/Parser/InfAsBuiltProcess.py b/BaseTools/Source/Python/UPT/Parser/InfAsBuiltProcess.py
index 3c313a089d..029a436cec 100644
--- a/BaseTools/Source/Python/UPT/Parser/InfAsBuiltProcess.py
+++ b/BaseTools/Source/Python/UPT/Parser/InfAsBuiltProcess.py
@@ -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:
diff --git a/BaseTools/Source/Python/UPT/Parser/InfParser.py b/BaseTools/Source/Python/UPT/Parser/InfParser.py
index d17d2c887b..cd99262e03 100644
--- a/BaseTools/Source/Python/UPT/Parser/InfParser.py
+++ b/BaseTools/Source/Python/UPT/Parser/InfParser.py
@@ -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
diff --git a/BaseTools/Source/Python/UPT/Parser/InfSectionParser.py b/BaseTools/Source/Python/UPT/Parser/InfSectionParser.py
index 44243b467b..1f254058d1 100644
--- a/BaseTools/Source/Python/UPT/Parser/InfSectionParser.py
+++ b/BaseTools/Source/Python/UPT/Parser/InfSectionParser.py
@@ -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]