BaseTools/UPT: Porting UPT Tool from Python2 to Python3
Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
@ -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 long(Token) > 4294967295:
|
||||
if int(Token) > 4294967295:
|
||||
self._LoggerError(ST.ERR_DECPARSE_PCD_TOKEN_INT % Token)
|
||||
Token = hex(long(Token))[:-1]
|
||||
Token = hex(int(Token))
|
||||
|
||||
IntToken = long(Token, 0)
|
||||
IntToken = int(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, 'rb').readlines())
|
||||
Content = ConvertSpecialChar(open(DecFile, 'r').readlines())
|
||||
except BaseException:
|
||||
Logger.Error(TOOL_NAME, FILE_OPEN_FAILURE, File=DecFile,
|
||||
ExtraData=ST.ERR_DECPARSE_FILEOPEN % DecFile)
|
||||
|
@ -151,7 +151,7 @@ def IsValidNumValUint8(Token):
|
||||
else:
|
||||
Base = 10
|
||||
try:
|
||||
TokenValue = long(Token, Base)
|
||||
TokenValue = int(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 = long(Value, 0)
|
||||
Value = int(Value, 0)
|
||||
TypeLenMap = {
|
||||
#
|
||||
# 0x00 - 0xff
|
||||
|
@ -205,7 +205,7 @@ def GetFileLineContent(FileName, WorkSpace, LineNo, OriginalString):
|
||||
|
||||
try:
|
||||
FullFileName = FullFileName.replace('\\', '/')
|
||||
Inputfile = open(FullFileName, "rb", 0)
|
||||
Inputfile = open(FullFileName, "r")
|
||||
try:
|
||||
FileLinesList = Inputfile.readlines()
|
||||
except BaseException:
|
||||
|
@ -51,7 +51,7 @@ def OpenInfFile(Filename):
|
||||
FileLinesList = []
|
||||
|
||||
try:
|
||||
FInputfile = open(Filename, "rb", 0)
|
||||
FInputfile = open(Filename, "r")
|
||||
try:
|
||||
FileLinesList = FInputfile.readlines()
|
||||
except BaseException:
|
||||
@ -86,7 +86,7 @@ class InfParser(InfSectionParser):
|
||||
#
|
||||
# Call parent class construct function
|
||||
#
|
||||
super(InfParser, self).__init__()
|
||||
super().__init__()
|
||||
|
||||
self.WorkspaceDir = WorkspaceDir
|
||||
self.SupArchList = DT.ARCH_LIST
|
||||
|
@ -206,7 +206,7 @@ class InfSectionParser(InfDefinSectionParser,
|
||||
if FilePath in cls.MetaFiles:
|
||||
return cls.MetaFiles[FilePath]
|
||||
else:
|
||||
ParserObject = super(InfSectionParser, cls).__new__(cls)
|
||||
ParserObject = super().__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(self.MetaFiles.keys()[0])
|
||||
self.InfPcdSection = InfPcdObject(list(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 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]
|
||||
|
Reference in New Issue
Block a user