summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/UPT/Library/StringUtils.py
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/Library/StringUtils.py
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/Library/StringUtils.py')
-rw-r--r--BaseTools/Source/Python/UPT/Library/StringUtils.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/BaseTools/Source/Python/UPT/Library/StringUtils.py b/BaseTools/Source/Python/UPT/Library/StringUtils.py
index 011eb98ca6..2be382fa17 100644
--- a/BaseTools/Source/Python/UPT/Library/StringUtils.py
+++ b/BaseTools/Source/Python/UPT/Library/StringUtils.py
@@ -20,6 +20,7 @@ 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
@@ -43,7 +44,7 @@ gMACRO_PATTERN = re.compile("\$\(([_A-Z][_A-Z0-9]*)\)", re.UNICODE)
#
#
def GetSplitValueList(String, SplitTag=DataType.TAB_VALUE_SPLIT, MaxSplit= -1):
- return list(map(lambda l: l.strip(), String.split(SplitTag, MaxSplit)))
+ return map(lambda l: l.strip(), String.split(SplitTag, MaxSplit))
## MergeArches
#
@@ -434,7 +435,7 @@ def GetSingleValueOfKeyFromLines(Lines, Dictionary, CommentCharacter, KeySplitCh
#
LineList[1] = CleanString(LineList[1], CommentCharacter)
if ValueSplitFlag:
- Value = map(lambda x: x.strip(), LineList[1].split(ValueSplitCharacter))
+ Value = map(strip, LineList[1].split(ValueSplitCharacter))
else:
Value = CleanString(LineList[1], CommentCharacter).splitlines()
@@ -501,7 +502,7 @@ def PreCheck(FileName, FileContent, SupSectionTag):
#
# Regenerate FileContent
#
- NewFileContent = NewFileContent + Line + '\n'
+ NewFileContent = NewFileContent + Line + '\r\n'
if IsFailed:
Logger.Error("Parser", FORMAT_INVALID, Line=LineNo, File=FileName, RaiseError=Logger.IS_RAISE_ERROR)
@@ -679,7 +680,9 @@ def GetHelpTextList(HelpTextClassList):
# @param String: the source string
#
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)
@@ -937,14 +940,14 @@ def SplitPcdEntry(String):
def IsMatchArch(Arch1, Arch2):
if 'COMMON' in Arch1 or 'COMMON' in Arch2:
return True
- if isinstance(Arch1, str) and isinstance(Arch2, str):
+ if isinstance(Arch1, basestring) and isinstance(Arch2, basestring):
if Arch1 == Arch2:
return True
- if isinstance(Arch1, str) and isinstance(Arch2, list):
+ if isinstance(Arch1, basestring) and isinstance(Arch2, list):
return Arch1 in Arch2
- if isinstance(Arch2, str) and isinstance(Arch1, list):
+ if isinstance(Arch2, basestring) and isinstance(Arch1, list):
return Arch2 in Arch1
if isinstance(Arch1, list) and isinstance(Arch2, list):