X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FCommon%2FStringUtils.py;h=723faac0f9f3da827b68e5703b272f9c297d4559;hb=543f5ac30facfbb40eafb2b4908649a427784080;hp=34361ecdd58c0bfacabda0e9a09797f060df1368;hpb=5a57246eab80f00ae2481970d12a2abc345a2730;p=mirror_edk2.git diff --git a/BaseTools/Source/Python/Common/StringUtils.py b/BaseTools/Source/Python/Common/StringUtils.py index 34361ecdd5..723faac0f9 100644 --- a/BaseTools/Source/Python/Common/StringUtils.py +++ b/BaseTools/Source/Python/Common/StringUtils.py @@ -251,7 +251,7 @@ def SplitModuleType(Key): def ReplaceMacros(StringList, MacroDefinitions={}, SelfReplacement=False): NewList = [] for String in StringList: - if type(String) == type(''): + if isinstance(String, type('')): NewList.append(ReplaceMacro(String, MacroDefinitions, SelfReplacement)) else: NewList.append(String) @@ -447,7 +447,7 @@ def GetMultipleValuesOfKeyFromLines(Lines, Key, KeyValues, CommentCharacter): for Line in LineList: Line = CleanString(Line, CommentCharacter) if Line != '' and Line[0] != CommentCharacter: - KeyValues += [Line] + KeyValues.append(Line) return True @@ -750,7 +750,7 @@ def SplitString(String): # @param StringList: A list for strings to be converted # def ConvertToSqlString(StringList): - return map(lambda s: s.replace("'", "''") , StringList) + return map(lambda s: s.replace("'", "''"), StringList) ## Convert To Sql String # @@ -793,7 +793,7 @@ def RemoveBlockComment(Lines): # Get String of a List # def GetStringOfList(List, Split=' '): - if type(List) != type([]): + if not isinstance(List, type([])): return List Str = '' for Item in List: @@ -839,7 +839,7 @@ def StringToArray(String): return "{%s,0x00}" % ",".join(C.strip() for C in String[1:-1].split(',')) else: return "{%s}" % ",".join(C.strip() for C in String[1:-1].split(',')) - + else: if len(String.split()) % 2: return '{%s,0}' % ','.join(String.split())