X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FCommon%2FString.py;h=5dc5b85dc5a459fb03358fd9ff07571cdc1de3b1;hb=7da06eeede10fc8b908327b375bcdf36707ff7b5;hp=5e50beff5cc39539a0eab1684d0281b0533b9918;hpb=ea927d2f3f2e34f4b26c10829f5887830cb0720e;p=mirror_edk2.git diff --git a/BaseTools/Source/Python/Common/String.py b/BaseTools/Source/Python/Common/String.py index 5e50beff5c..5dc5b85dc5 100644 --- a/BaseTools/Source/Python/Common/String.py +++ b/BaseTools/Source/Python/Common/String.py @@ -634,7 +634,7 @@ def PreCheck(FileName, FileContent, SupSectionTag): # @retval True The file type is correct # def CheckFileType(CheckFilename, ExtName, ContainerFilename, SectionName, Line, LineNo= -1): - if CheckFilename != '' and CheckFilename != None: + if CheckFilename != '' and CheckFilename is not None: (Root, Ext) = os.path.splitext(CheckFilename) if Ext.upper() != ExtName.upper(): ContainerFile = open(ContainerFilename, 'r').read() @@ -662,7 +662,7 @@ def CheckFileType(CheckFilename, ExtName, ContainerFilename, SectionName, Line, # def CheckFileExist(WorkspaceDir, CheckFilename, ContainerFilename, SectionName, Line, LineNo= -1): CheckFile = '' - if CheckFilename != '' and CheckFilename != None: + if CheckFilename != '' and CheckFilename is not None: CheckFile = WorkspaceFile(WorkspaceDir, CheckFilename) if not os.path.isfile(CheckFile): ContainerFile = open(ContainerFilename, 'r').read() @@ -817,34 +817,34 @@ def GetHelpTextList(HelpTextClassList): def StringToArray(String): 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]) + 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}" + return "{0x00,0x00}" else: - return "{%s, 0x00, 0x00}" % ", ".join(["0x%02x, 0x00" % ord(C) for C in String[2:-1]]) + return "{%s,0x00,0x00}" % ",".join(["0x%02x,0x00" % ord(C) for C in String[2:-1]]) elif String.startswith('"'): if String == "\"\"": return "{0x00,0x00}" else: StringLen = len(String[1:-1]) if StringLen % 2: - return "{%s, 0x00}" % ", ".join(["0x%02x" % ord(C) for C in String[1:-1]]) + return "{%s,0x00}" % ",".join(["0x%02x" % ord(C) for C in String[1:-1]]) else: - return "{%s, 0x00,0x00}" % ", ".join(["0x%02x" % ord(C) for C in String[1:-1]]) + return "{%s,0x00,0x00}" % ",".join(["0x%02x" % ord(C) for C in String[1:-1]]) elif String.startswith('{'): StringLen = len(String.split(",")) if StringLen % 2: - return "{%s, 0x00}" % ", ".join([ C for C in String[1:-1].split(',')]) + return "{%s,0x00}" % ",".join([ C.strip() for C in String[1:-1].split(',')]) else: - return "{%s}" % ", ".join([ C for C in String[1:-1].split(',')]) + return "{%s}" % ",".join([ C.strip() for C in String[1:-1].split(',')]) else: if len(String.split()) % 2: - return '{%s, 0}' % ', '.join(String.split()) + return '{%s,0}' % ','.join(String.split()) else: - return '{%s, 0,0}' % ', '.join(String.split()) + return '{%s,0,0}' % ','.join(String.split()) def StringArrayLength(String): if isinstance(String, unicode):