summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/GenFds
diff options
context:
space:
mode:
authorCarsey, Jaben </o=Intel/ou=Americas01/cn=Workers/cn=Carsey, Jaben>2018-03-30 08:19:30 +0800
committerYonghong Zhu <yonghong.zhu@intel.com>2018-04-03 17:37:33 +0800
commitcfbe3c3500a64e218e7d357dacb18d8b95eddfec (patch)
treefb5e71b59316627e6bc8362902b8ffc697cf3372 /BaseTools/Source/Python/GenFds
parent147a656b3414667aeafdad0a8fd5504ddad96367 (diff)
downloadedk2-cfbe3c3500a64e218e7d357dacb18d8b95eddfec.tar.gz
edk2-cfbe3c3500a64e218e7d357dacb18d8b95eddfec.tar.bz2
edk2-cfbe3c3500a64e218e7d357dacb18d8b95eddfec.zip
BaseTools: change hex parsing to use built in
use <char> in string.hexdigits instead of custom functions. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/GenFds')
-rw-r--r--BaseTools/Source/Python/GenFds/FdfParser.py26
1 files changed, 4 insertions, 22 deletions
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index b3f83c072a..4183f318b7 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -42,6 +42,7 @@ import ComponentStatement
import OptionRom
import OptRomInfStatement
import OptRomFileStatement
+import string
from GenFdsGlobalVariable import GenFdsGlobalVariable
from Common.BuildToolError import *
@@ -1192,32 +1193,13 @@ class FdfParser:
self.__GetOneChar()
- ## __HexDigit() method
- #
- # Whether char input is a Hex data bit
- #
- # @param self The object pointer
- # @param TempChar The char to test
- # @retval True The char is a Hex data bit
- # @retval False The char is NOT a Hex data bit
- #
- def __HexDigit(self, TempChar):
- if (TempChar >= 'a' and TempChar <= 'f') or (TempChar >= 'A' and TempChar <= 'F') \
- or (TempChar >= '0' and TempChar <= '9'):
- return True
- else:
- return False
-
def __IsHex(self, HexStr):
if not HexStr.upper().startswith("0X"):
return False
if len(self.__Token) <= 2:
return False
- charList = [c for c in HexStr[2 : ] if not self.__HexDigit( c)]
- if len(charList) == 0:
- return True
- else:
- return False
+ return True if all(x in string.hexdigits for x in HexStr[2:]) else False
+
## __GetNextHexNumber() method
#
# Get next HEX data before a seperator
@@ -4294,7 +4276,7 @@ class FdfParser:
raise Warning("expected Component type", self.FileName, self.CurrentLineNumber)
if self.__Token not in ("FIT", "PAL_B", "PAL_A", "OEM"):
if not self.__Token.startswith("0x") or len(self.__Token) < 3 or len(self.__Token) > 4 or \
- not self.__HexDigit(self.__Token[2]) or not self.__HexDigit(self.__Token[-1]):
+ not self.__Token[2] in string.hexdigits or not self.__Token[-1] in string.hexdigits:
raise Warning("Unknown location type '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
CompStatementObj.CompType = self.__Token