diff options
author | Liming Gao <liming.gao@intel.com> | 2018-10-15 08:27:53 +0800 |
---|---|---|
committer | Liming Gao <liming.gao@intel.com> | 2018-10-15 08:29:14 +0800 |
commit | 1ccc4d895dd8d659d016efcd6ef8a48749aba1d0 (patch) | |
tree | 0d5f58643cc72275887d3bb322813609906a9334 /BaseTools/Source/Python/Common/StringUtils.py | |
parent | 678f85131238622e576705117e299d81cff755c9 (diff) | |
download | edk2-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/StringUtils.py')
-rw-r--r-- | BaseTools/Source/Python/Common/StringUtils.py | 19 |
1 files changed, 13 insertions, 6 deletions
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)
|