## @file\r
# This file is used to define common string related functions used in parsing process\r
#\r
-# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
# This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
# which accompanies this distribution. The full text of the license may be found at\r
# @param Arch: The Arch to be added or merged\r
#\r
def MergeArches(Dict, Key, Arch):\r
- if Key in Dict.keys():\r
+ if Key in Dict:\r
Dict[Key].append(Arch)\r
else:\r
Dict[Key] = Arch.split()\r
# @retval True The file type is correct\r
#\r
def CheckFileType(CheckFilename, ExtName, ContainerFilename, SectionName, Line, LineNo= -1):\r
- if CheckFilename != '' and CheckFilename != None:\r
+ if CheckFilename != '' and CheckFilename is not None:\r
(Root, Ext) = os.path.splitext(CheckFilename)\r
if Ext.upper() != ExtName.upper():\r
ContainerFile = open(ContainerFilename, 'r').read()\r
#\r
def CheckFileExist(WorkspaceDir, CheckFilename, ContainerFilename, SectionName, Line, LineNo= -1):\r
CheckFile = ''\r
- if CheckFilename != '' and CheckFilename != None:\r
+ if CheckFilename != '' and CheckFilename is not None:\r
CheckFile = WorkspaceFile(WorkspaceDir, CheckFilename)\r
if not os.path.isfile(CheckFile):\r
ContainerFile = open(ContainerFilename, 'r').read()\r
if isinstance(String, unicode):\r
if len(unicode) == 0:\r
return "{0x00,0x00}"\r
- return "{%s,0x00,0x00}" % ",".join(["0x%02x,0x00" % ord(C) for C in String])\r
+ return "{%s,0x00,0x00}" % ",".join("0x%02x,0x00" % ord(C) for C in String)\r
elif String.startswith('L"'):\r
if String == "L\"\"":\r
return "{0x00,0x00}"\r
else:\r
- return "{%s,0x00,0x00}" % ",".join(["0x%02x,0x00" % ord(C) for C in String[2:-1]])\r
+ return "{%s,0x00,0x00}" % ",".join("0x%02x,0x00" % ord(C) for C in String[2:-1])\r
elif String.startswith('"'):\r
if String == "\"\"":\r
return "{0x00,0x00}"\r
else:\r
StringLen = len(String[1:-1])\r
if StringLen % 2:\r
- return "{%s,0x00}" % ",".join(["0x%02x" % ord(C) for C in String[1:-1]])\r
+ return "{%s,0x00}" % ",".join("0x%02x" % ord(C) for C in String[1:-1])\r
else:\r
- return "{%s,0x00,0x00}" % ",".join(["0x%02x" % ord(C) for C in String[1:-1]])\r
+ return "{%s,0x00,0x00}" % ",".join("0x%02x" % ord(C) for C in String[1:-1])\r
elif String.startswith('{'):\r
StringLen = len(String.split(","))\r
if StringLen % 2:\r
- return "{%s,0x00}" % ",".join([ C.strip() for C in String[1:-1].split(',')])\r
+ return "{%s,0x00}" % ",".join(C.strip() for C in String[1:-1].split(','))\r
else:\r
- return "{%s}" % ",".join([ C.strip() for C in String[1:-1].split(',')])\r
+ return "{%s}" % ",".join(C.strip() for C in String[1:-1].split(','))\r
\r
else:\r
if len(String.split()) % 2:\r