summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/Common
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/Common
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/Common')
-rw-r--r--BaseTools/Source/Python/Common/Database.py1
-rw-r--r--BaseTools/Source/Python/Common/EdkLogger.py1
-rw-r--r--BaseTools/Source/Python/Common/Expression.py17
-rw-r--r--BaseTools/Source/Python/Common/LongFilePathOs.py4
-rw-r--r--BaseTools/Source/Python/Common/LongFilePathSupport.py14
-rw-r--r--BaseTools/Source/Python/Common/Misc.py85
-rw-r--r--BaseTools/Source/Python/Common/Parsing.py1
-rw-r--r--BaseTools/Source/Python/Common/PyUtility.pydbin0 -> 6144 bytes
-rw-r--r--BaseTools/Source/Python/Common/RangeExpression.py3
-rw-r--r--BaseTools/Source/Python/Common/StringUtils.py19
-rw-r--r--BaseTools/Source/Python/Common/TargetTxtClassObject.py2
-rw-r--r--BaseTools/Source/Python/Common/ToolDefClassObject.py1
-rw-r--r--BaseTools/Source/Python/Common/VpdInfoFile.py11
13 files changed, 92 insertions, 67 deletions
diff --git a/BaseTools/Source/Python/Common/Database.py b/BaseTools/Source/Python/Common/Database.py
index 0888edf37a..1c543aeb41 100644
--- a/BaseTools/Source/Python/Common/Database.py
+++ b/BaseTools/Source/Python/Common/Database.py
@@ -14,6 +14,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
import sqlite3
import Common.LongFilePathOs as os
diff --git a/BaseTools/Source/Python/Common/EdkLogger.py b/BaseTools/Source/Python/Common/EdkLogger.py
index d70b24e642..af7707482c 100644
--- a/BaseTools/Source/Python/Common/EdkLogger.py
+++ b/BaseTools/Source/Python/Common/EdkLogger.py
@@ -12,6 +12,7 @@
#
## Import modules
+from __future__ import absolute_import
import Common.LongFilePathOs as os, sys, logging
import traceback
from .BuildToolError import *
diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py
index 5e4e66a10e..ff9271031b 100644
--- a/BaseTools/Source/Python/Common/Expression.py
+++ b/BaseTools/Source/Python/Common/Expression.py
@@ -12,6 +12,8 @@
## Import Modules
#
+from __future__ import print_function
+from __future__ import absolute_import
from Common.GlobalData import *
from CommonDataClass.Exceptions import BadExpression
from CommonDataClass.Exceptions import WrnExpression
@@ -204,7 +206,7 @@ SupportedInMacroList = ['TARGET', 'TOOL_CHAIN_TAG', 'ARCH', 'FAMILY']
class BaseExpression(object):
def __init__(self, *args, **kwargs):
- super().__init__()
+ super(BaseExpression, self).__init__()
# Check if current token matches the operators given from parameter
def _IsOperator(self, OpSet):
@@ -324,7 +326,7 @@ class ValueExpression(BaseExpression):
return Val
def __init__(self, Expression, SymbolTable={}):
- super().__init__(self, Expression, SymbolTable)
+ super(ValueExpression, self).__init__(self, Expression, SymbolTable)
self._NoProcess = False
if not isinstance(Expression, type('')):
self._Expr = Expression
@@ -425,13 +427,6 @@ class ValueExpression(BaseExpression):
else:
Val = Val3
continue
- #
- # PEP 238 -- Changing the Division Operator
- # x/y to return a reasonable approximation of the mathematical result of the division ("true division")
- # x//y to return the floor ("floor division")
- #
- if Op == '/':
- Op = '//'
try:
Val = self.Eval(Op, Val, EvalFunc())
except WrnExpression as Warn:
@@ -905,7 +900,7 @@ class ValueExpressionEx(ValueExpression):
if TmpValue.bit_length() == 0:
PcdValue = '{0x00}'
else:
- for I in range((TmpValue.bit_length() + 7) // 8):
+ for I in range((TmpValue.bit_length() + 7) / 8):
TmpList.append('0x%02x' % ((TmpValue >> I * 8) & 0xff))
PcdValue = '{' + ', '.join(TmpList) + '}'
except:
@@ -1033,7 +1028,7 @@ class ValueExpressionEx(ValueExpression):
if __name__ == '__main__':
pass
while True:
- input = input('Input expr: ')
+ input = raw_input('Input expr: ')
if input in 'qQ':
break
try:
diff --git a/BaseTools/Source/Python/Common/LongFilePathOs.py b/BaseTools/Source/Python/Common/LongFilePathOs.py
index 12796b2682..53528546b7 100644
--- a/BaseTools/Source/Python/Common/LongFilePathOs.py
+++ b/BaseTools/Source/Python/Common/LongFilePathOs.py
@@ -11,9 +11,11 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
+from __future__ import absolute_import
import os
from . import LongFilePathOsPath
from Common.LongFilePathSupport import LongFilePath
+from Common.LongFilePathSupport import UniToStr
import time
path = LongFilePathOsPath
@@ -62,7 +64,7 @@ def listdir(path):
List = []
uList = os.listdir(u"%s" % LongFilePath(path))
for Item in uList:
- List.append(Item)
+ List.append(UniToStr(Item))
return List
environ = os.environ
diff --git a/BaseTools/Source/Python/Common/LongFilePathSupport.py b/BaseTools/Source/Python/Common/LongFilePathSupport.py
index 7eb141053a..b3e3c8ea64 100644
--- a/BaseTools/Source/Python/Common/LongFilePathSupport.py
+++ b/BaseTools/Source/Python/Common/LongFilePathSupport.py
@@ -1,7 +1,7 @@
## @file
# Override built in function file.open to provide support for long file path
#
-# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -49,3 +49,15 @@ def CopyLongFilePath(src, dst):
with open(LongFilePath(src), 'rb') as fsrc:
with open(LongFilePath(dst), 'wb') as fdst:
shutil.copyfileobj(fsrc, fdst)
+
+## Convert a python unicode string to a normal string
+#
+# Convert a python unicode string to a normal string
+# UniToStr(u'I am a string') is 'I am a string'
+#
+# @param Uni: The python unicode string
+#
+# @retval: The formatted normal string
+#
+def UniToStr(Uni):
+ return repr(Uni)[2:-1]
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 2ac592d26b..0efd8b05a8 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -14,6 +14,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.LongFilePathOs as os
import sys
import string
@@ -24,8 +25,8 @@ import pickle
import array
import shutil
from struct import pack
-from collections import UserDict as IterableUserDict
-from collections import OrderedDict
+from UserDict import IterableUserDict
+from UserList import UserList
from Common import EdkLogger as EdkLogger
from Common import GlobalData as GlobalData
@@ -454,16 +455,13 @@ def RemoveDirectory(Directory, Recursively=False):
# @retval False If the file content is the same
#
def SaveFileOnChange(File, Content, IsBinaryFile=True):
+ if not IsBinaryFile:
+ Content = Content.replace("\n", os.linesep)
+
if os.path.exists(File):
try:
- if isinstance(Content, bytes):
- with open(File, "rb") as f:
- if Content == f.read():
- return False
- else:
- with open(File, "r") as f:
- if Content == f.read():
- return False
+ if Content == open(File, "rb").read():
+ return False
except:
EdkLogger.error(None, FILE_OPEN_FAILURE, ExtraData=File)
@@ -477,12 +475,19 @@ def SaveFileOnChange(File, Content, IsBinaryFile=True):
EdkLogger.error(None, PERMISSION_FAILURE, "Do not have write permission on directory %s" % DirName)
try:
- if isinstance(Content, bytes):
- with open(File, "wb") as Fd:
+ if GlobalData.gIsWindows:
+ try:
+ from .PyUtility import SaveFileToDisk
+ if not SaveFileToDisk(File, Content):
+ EdkLogger.error(None, FILE_CREATE_FAILURE, ExtraData=File)
+ except:
+ Fd = open(File, "wb")
Fd.write(Content)
+ Fd.close()
else:
- with open(File, "w") as Fd:
- Fd.write(Content)
+ Fd = open(File, "wb")
+ Fd.write(Content)
+ Fd.close()
except IOError as X:
EdkLogger.error(None, FILE_CREATE_FAILURE, ExtraData='IOError %s' % X)
@@ -641,7 +646,7 @@ def RealPath2(File, Dir='', OverrideDir=''):
#
def GuidValue(CName, PackageList, Inffile = None):
for P in PackageList:
- GuidKeys = list(P.Guids.keys())
+ GuidKeys = P.Guids.keys()
if Inffile and P._PrivateGuids:
if not Inffile.startswith(P.MetaFile.Dir):
GuidKeys = [x for x in P.Guids if x not in P._PrivateGuids]
@@ -660,7 +665,7 @@ def GuidValue(CName, PackageList, Inffile = None):
#
def ProtocolValue(CName, PackageList, Inffile = None):
for P in PackageList:
- ProtocolKeys = list(P.Protocols.keys())
+ ProtocolKeys = P.Protocols.keys()
if Inffile and P._PrivateProtocols:
if not Inffile.startswith(P.MetaFile.Dir):
ProtocolKeys = [x for x in P.Protocols if x not in P._PrivateProtocols]
@@ -679,7 +684,7 @@ def ProtocolValue(CName, PackageList, Inffile = None):
#
def PpiValue(CName, PackageList, Inffile = None):
for P in PackageList:
- PpiKeys = list(P.Ppis.keys())
+ PpiKeys = P.Ppis.keys()
if Inffile and P._PrivatePpis:
if not Inffile.startswith(P.MetaFile.Dir):
PpiKeys = [x for x in P.Ppis if x not in P._PrivatePpis]
@@ -975,7 +980,7 @@ class sdict(IterableUserDict):
## append support
def append(self, sdict):
- for key in sdict.keys():
+ for key in sdict:
if key not in self._key_list:
self._key_list.append(key)
IterableUserDict.__setitem__(self, key, sdict[key])
@@ -1015,11 +1020,11 @@ class sdict(IterableUserDict):
## Keys interation support
def iterkeys(self):
- return self.keys()
+ return iter(self.keys())
## Values interation support
def itervalues(self):
- return self.values()
+ return iter(self.values())
## Return value related to a key, and remove the (key, value) from the dict
def pop(self, key, *dv):
@@ -1028,7 +1033,7 @@ class sdict(IterableUserDict):
value = self[key]
self.__delitem__(key)
elif len(dv) != 0 :
- value = dv[0]
+ value = kv[0]
return value
## Return (key, value) pair, and remove the (key, value) from the dict
@@ -1292,12 +1297,12 @@ def ParseDevPathValue (Value):
if err:
raise BadExpression("DevicePath: %s" % str(err))
Size = len(out.split())
- out = ','.join(out.decode(encoding='utf-8', errors='ignore').split())
+ out = ','.join(out.split())
return '{' + out + '}', Size
def ParseFieldValue (Value):
if isinstance(Value, type(0)):
- return Value, (Value.bit_length() + 7) // 8
+ return Value, (Value.bit_length() + 7) / 8
if not isinstance(Value, type('')):
raise BadExpression('Type %s is %s' %(Value, type(Value)))
Value = Value.strip()
@@ -1331,7 +1336,7 @@ def ParseFieldValue (Value):
if Value[0] == '"' and Value[-1] == '"':
Value = Value[1:-1]
try:
- Value = "{" + ','.join([str(i) for i in uuid.UUID(Value).bytes_le]) + "}"
+ Value = "'" + uuid.UUID(Value).get_bytes_le() + "'"
except ValueError as Message:
raise BadExpression(Message)
Value, Size = ParseFieldValue(Value)
@@ -1418,12 +1423,12 @@ def ParseFieldValue (Value):
raise BadExpression("invalid hex value: %s" % Value)
if Value == 0:
return 0, 1
- return Value, (Value.bit_length() + 7) // 8
+ return Value, (Value.bit_length() + 7) / 8
if Value[0].isdigit():
Value = int(Value, 10)
if Value == 0:
return 0, 1
- return Value, (Value.bit_length() + 7) // 8
+ return Value, (Value.bit_length() + 7) / 8
if Value.lower() == 'true':
return 1, 1
if Value.lower() == 'false':
@@ -1584,19 +1589,15 @@ def CheckPcdDatum(Type, Value):
return False, "Invalid value [%s] of type [%s]; must be one of TRUE, True, true, 0x1, 0x01, 1"\
", FALSE, False, false, 0x0, 0x00, 0" % (Value, Type)
elif Type in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64]:
+ if Value and int(Value, 0) < 0:
+ return False, "PCD can't be set to negative value[%s] for datum type [%s]" % (Value, Type)
try:
- Val = int(Value, 0)
+ Value = long(Value, 0)
+ if Value > MAX_VAL_TYPE[Type]:
+ return False, "Too large PCD value[%s] for datum type [%s]" % (Value, Type)
except:
- try:
- Val = int(Value.lstrip('0'))
- except:
- return False, "Invalid value [%s] of type [%s];" \
- " must be a hexadecimal, decimal or octal in C language format." % (Value, Type)
- if Val > MAX_VAL_TYPE[Type]:
- return False, "Too large PCD value[%s] for datum type [%s]" % (Value, Type)
- if Val < 0:
- return False, "PCD can't be set to negative value[%s] for datum type [%s]" % (Value, Type)
-
+ return False, "Invalid value [%s] of type [%s];"\
+ " must be a hexadecimal, decimal or octal in C language format." % (Value, Type)
else:
return True, "StructurePcd"
@@ -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 range(min(len(P1), len(P2))):
+ for Index in xrange(min(len(P1), len(P2))):
if P1[Index] != P2[Index]:
return os.path.sep.join(P1[:Index])
return os.path.sep.join(P1)
@@ -1859,7 +1860,7 @@ class PeImageClass():
ByteArray = array.array('B')
ByteArray.fromfile(PeObject, 4)
# PE signature should be 'PE\0\0'
- if ByteArray.tostring() != b'PE\0\0':
+ if ByteArray.tostring() != 'PE\0\0':
self.ErrorInfo = self.FileName + ' has no valid PE signature PE00'
return
@@ -1951,7 +1952,7 @@ class SkuClass():
ExtraData = "SKU-ID [%s] value %s exceeds the max value of UINT64"
% (SkuName, SkuId))
- self.AvailableSkuIds = OrderedDict()
+ self.AvailableSkuIds = sdict()
self.SkuIdSet = []
self.SkuIdNumberSet = []
self.SkuData = SkuIds
@@ -1961,7 +1962,7 @@ class SkuClass():
self.SkuIdSet = ['DEFAULT']
self.SkuIdNumberSet = ['0U']
elif SkuIdentifier == 'ALL':
- self.SkuIdSet = list(SkuIds.keys())
+ self.SkuIdSet = SkuIds.keys()
self.SkuIdNumberSet = [num[0].strip() + 'U' for num in SkuIds.values()]
else:
r = SkuIdentifier.split('|')
@@ -2081,7 +2082,7 @@ def PackRegistryFormatGuid(Guid):
# @retval Value The integer value that the input represents
#
def GetIntegerValue(Input):
- if isinstance(Input, int):
+ if type(Input) in (int, long):
return Input
String = Input
if String.endswith("U"):
diff --git a/BaseTools/Source/Python/Common/Parsing.py b/BaseTools/Source/Python/Common/Parsing.py
index ad90afab80..889251b699 100644
--- a/BaseTools/Source/Python/Common/Parsing.py
+++ b/BaseTools/Source/Python/Common/Parsing.py
@@ -14,6 +14,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
from .StringUtils import *
from CommonDataClass.DataClass import *
from .DataType import *
diff --git a/BaseTools/Source/Python/Common/PyUtility.pyd b/BaseTools/Source/Python/Common/PyUtility.pyd
new file mode 100644
index 0000000000..856b508e4e
--- /dev/null
+++ b/BaseTools/Source/Python/Common/PyUtility.pyd
Binary files differ
diff --git a/BaseTools/Source/Python/Common/RangeExpression.py b/BaseTools/Source/Python/Common/RangeExpression.py
index f6c4dcd666..407dc06ccf 100644
--- a/BaseTools/Source/Python/Common/RangeExpression.py
+++ b/BaseTools/Source/Python/Common/RangeExpression.py
@@ -12,6 +12,7 @@
# # Import Modules
#
+from __future__ import print_function
from Common.GlobalData import *
from CommonDataClass.Exceptions import BadExpression
from CommonDataClass.Exceptions import WrnExpression
@@ -347,7 +348,7 @@ class RangeExpression(BaseExpression):
def __init__(self, Expression, PcdDataType, SymbolTable = {}):
- super().__init__(self, Expression, PcdDataType, SymbolTable)
+ super(RangeExpression, self).__init__(self, Expression, PcdDataType, SymbolTable)
self._NoProcess = False
if not isinstance(Expression, type('')):
self._Expr = Expression
diff --git a/BaseTools/Source/Python/Common/StringUtils.py b/BaseTools/Source/Python/Common/StringUtils.py
index 794f4573fe..d5afde7a95 100644
--- a/BaseTools/Source/Python/Common/StringUtils.py
+++ b/BaseTools/Source/Python/Common/StringUtils.py
@@ -14,6 +14,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
import re
from . import DataType
import Common.LongFilePathOs as os
@@ -98,7 +99,7 @@ def GetSplitValueList(String, SplitTag=DataType.TAB_VALUE_SPLIT, MaxSplit= -1):
# @retval list() A list for splitted string
#
def GetSplitList(String, SplitStr=DataType.TAB_VALUE_SPLIT, MaxSplit= -1):
- return list(map(lambda l: l.strip(), String.split(SplitStr, MaxSplit)))
+ return map(lambda l: l.strip(), String.split(SplitStr, MaxSplit))
## MergeArches
#
@@ -544,7 +545,7 @@ def GetSingleValueOfKeyFromLines(Lines, Dictionary, CommentCharacter, KeySplitCh
#
LineList[1] = CleanString(LineList[1], CommentCharacter)
if ValueSplitFlag:
- Value = list(map(string.strip, LineList[1].split(ValueSplitCharacter)))
+ Value = map(string.strip, LineList[1].split(ValueSplitCharacter))
else:
Value = CleanString(LineList[1], CommentCharacter).splitlines()
@@ -612,7 +613,7 @@ def PreCheck(FileName, FileContent, SupSectionTag):
#
# Regenerate FileContent
#
- NewFileContent = NewFileContent + Line + '\n'
+ NewFileContent = NewFileContent + Line + '\r\n'
if IsFailed:
EdkLogger.error("Parser", FORMAT_INVALID, Line=LineNo, File=FileName, RaiseError=EdkLogger.IsRaiseError)
@@ -750,7 +751,7 @@ def SplitString(String):
# @param StringList: A list for strings to be converted
#
def ConvertToSqlString(StringList):
- return list(map(lambda s: s.replace("'", "''"), StringList))
+ return map(lambda s: s.replace("'", "''"), StringList)
## Convert To Sql String
#
@@ -815,7 +816,11 @@ def GetHelpTextList(HelpTextClassList):
return List
def StringToArray(String):
- if String.startswith('L"'):
+ if isinstance(String, unicode):
+ if len(unicode) == 0:
+ return "{0x00,0x00}"
+ return "{%s,0x00,0x00}" % ",".join("0x%02x,0x00" % ord(C) for C in String)
+ elif String.startswith('L"'):
if String == "L\"\"":
return "{0x00,0x00}"
else:
@@ -838,7 +843,9 @@ def StringToArray(String):
return '{%s,0,0}' % ','.join(String.split())
def StringArrayLength(String):
- if String.startswith('L"'):
+ if isinstance(String, unicode):
+ return (len(String) + 1) * 2 + 1;
+ elif String.startswith('L"'):
return (len(String) - 3 + 1) * 2
elif String.startswith('"'):
return (len(String) - 2 + 1)
diff --git a/BaseTools/Source/Python/Common/TargetTxtClassObject.py b/BaseTools/Source/Python/Common/TargetTxtClassObject.py
index 35b170e086..55a2f56482 100644
--- a/BaseTools/Source/Python/Common/TargetTxtClassObject.py
+++ b/BaseTools/Source/Python/Common/TargetTxtClassObject.py
@@ -14,6 +14,8 @@
##
# Import Modules
#
+from __future__ import print_function
+from __future__ import absolute_import
import Common.LongFilePathOs as os
from . import EdkLogger
from . import DataType
diff --git a/BaseTools/Source/Python/Common/ToolDefClassObject.py b/BaseTools/Source/Python/Common/ToolDefClassObject.py
index 5a961c3d94..05a1ddfbcc 100644
--- a/BaseTools/Source/Python/Common/ToolDefClassObject.py
+++ b/BaseTools/Source/Python/Common/ToolDefClassObject.py
@@ -14,6 +14,7 @@
##
# Import Modules
#
+from __future__ import absolute_import
import Common.LongFilePathOs as os
import re
from . import EdkLogger
diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Source/Python/Common/VpdInfoFile.py
index 3fadd693ea..0485bf482e 100644
--- a/BaseTools/Source/Python/Common/VpdInfoFile.py
+++ b/BaseTools/Source/Python/Common/VpdInfoFile.py
@@ -15,6 +15,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 __future__ import print_function
import Common.LongFilePathOs as os
import re
import Common.EdkLogger as EdkLogger
@@ -91,18 +92,18 @@ class VpdInfoFile:
if (Vpd is None):
EdkLogger.error("VpdInfoFile", BuildToolError.ATTRIBUTE_UNKNOWN_ERROR, "Invalid VPD PCD entry.")
- if not (Offset >= "0" or Offset == "*"):
+ if not (Offset >= 0 or Offset == "*"):
EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID, "Invalid offset parameter: %s." % Offset)
if Vpd.DatumType == TAB_VOID:
- if Vpd.MaxDatumSize <= "0":
+ if Vpd.MaxDatumSize <= 0:
EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID,
"Invalid max datum size for VPD PCD %s.%s" % (Vpd.TokenSpaceGuidCName, Vpd.TokenCName))
elif Vpd.DatumType in TAB_PCD_NUMERIC_TYPES:
if not Vpd.MaxDatumSize:
Vpd.MaxDatumSize = MAX_SIZE_TYPE[Vpd.DatumType]
else:
- if Vpd.MaxDatumSize <= "0":
+ if Vpd.MaxDatumSize <= 0:
EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID,
"Invalid max datum size for VPD PCD %s.%s" % (Vpd.TokenSpaceGuidCName, Vpd.TokenCName))
@@ -126,7 +127,7 @@ class VpdInfoFile:
"Invalid parameter FilePath: %s." % FilePath)
Content = FILE_COMMENT_TEMPLATE
- Pcds = sorted(self._VpdArray.keys(), key=lambda x: x.TokenCName)
+ Pcds = sorted(self._VpdArray.keys())
for Pcd in Pcds:
i = 0
PcdTokenCName = Pcd.TokenCName
@@ -248,7 +249,7 @@ def CallExtenalBPDGTool(ToolPath, VpdFileName):
except Exception as X:
EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, ExtraData=str(X))
(out, error) = PopenObject.communicate()
- print(out.decode(encoding='utf-8', errors='ignore'))
+ print(out)
while PopenObject.returncode is None :
PopenObject.wait()