summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/UPT/Library/StringUtils.py
diff options
context:
space:
mode:
authorZhijux Fan <zhijux.fan@intel.com>2018-12-17 15:18:01 +0800
committerFeng, Bob C <bob.c.feng@intel.com>2019-02-01 11:09:19 +0800
commit174a9d3cc8f74f7a731ac5f16ce6864c8eb359ec (patch)
tree097f344f323364c6cf0599eba5977863289b1654 /BaseTools/Source/Python/UPT/Library/StringUtils.py
parent1590d12315b0dd1f348554149257b09ad23f3e67 (diff)
downloadedk2-174a9d3cc8f74f7a731ac5f16ce6864c8eb359ec.tar.gz
edk2-174a9d3cc8f74f7a731ac5f16ce6864c8eb359ec.tar.bz2
edk2-174a9d3cc8f74f7a731ac5f16ce6864c8eb359ec.zip
BaseTools/UPT:merge UPT Tool use Python2 and Python3
In UPT Tool,merge python2 and python3 Cc: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/UPT/Library/StringUtils.py')
-rw-r--r--BaseTools/Source/Python/UPT/Library/StringUtils.py36
1 files changed, 18 insertions, 18 deletions
diff --git a/BaseTools/Source/Python/UPT/Library/StringUtils.py b/BaseTools/Source/Python/UPT/Library/StringUtils.py
index 2be382fa17..90946337d0 100644
--- a/BaseTools/Source/Python/UPT/Library/StringUtils.py
+++ b/BaseTools/Source/Python/UPT/Library/StringUtils.py
@@ -20,7 +20,6 @@ StringUtils
#
import re
import os.path
-from string import strip
import Logger.Log as Logger
import Library.DataType as DataType
from Logger.ToolError import FORMAT_INVALID
@@ -44,7 +43,7 @@ gMACRO_PATTERN = re.compile("\$\(([_A-Z][_A-Z0-9]*)\)", re.UNICODE)
#
#
def GetSplitValueList(String, SplitTag=DataType.TAB_VALUE_SPLIT, MaxSplit= -1):
- return map(lambda l: l.strip(), String.split(SplitTag, MaxSplit))
+ return list(map(lambda l: l.strip(), String.split(SplitTag, MaxSplit)))
## MergeArches
#
@@ -435,7 +434,7 @@ def GetSingleValueOfKeyFromLines(Lines, Dictionary, CommentCharacter, KeySplitCh
#
LineList[1] = CleanString(LineList[1], CommentCharacter)
if ValueSplitFlag:
- Value = map(strip, LineList[1].split(ValueSplitCharacter))
+ Value = list(map(lambda x: x.strip(), LineList[1].split(ValueSplitCharacter)))
else:
Value = CleanString(LineList[1], CommentCharacter).splitlines()
@@ -632,7 +631,7 @@ def SplitString(String):
# @param StringList: A list for strings to be converted
#
def ConvertToSqlString(StringList):
- return map(lambda s: s.replace("'", "''"), StringList)
+ return list(map(lambda s: s.replace("'", "''"), StringList))
## Convert To Sql String
#
@@ -940,23 +939,24 @@ def SplitPcdEntry(String):
def IsMatchArch(Arch1, Arch2):
if 'COMMON' in Arch1 or 'COMMON' in Arch2:
return True
- if isinstance(Arch1, basestring) and isinstance(Arch2, basestring):
- if Arch1 == Arch2:
- return True
-
- if isinstance(Arch1, basestring) and isinstance(Arch2, list):
- return Arch1 in Arch2
+ try:
+ if isinstance(Arch1, list) and isinstance(Arch2, list):
+ for Item1 in Arch1:
+ for Item2 in Arch2:
+ if Item1 == Item2:
+ return True
- if isinstance(Arch2, basestring) and isinstance(Arch1, list):
- return Arch2 in Arch1
+ elif isinstance(Arch1, list):
+ return Arch2 in Arch1
- if isinstance(Arch1, list) and isinstance(Arch2, list):
- for Item1 in Arch1:
- for Item2 in Arch2:
- if Item1 == Item2:
- return True
+ elif isinstance(Arch2, list):
+ return Arch1 in Arch2
- return False
+ else:
+ if Arch1 == Arch2:
+ return True
+ except:
+ return False
# Search all files in FilePath to find the FileName with the largest index
# Return the FileName with index +1 under the FilePath