]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Common/Parsing.py
BaseTools: Replace StandardError with Expression
[mirror_edk2.git] / BaseTools / Source / Python / Common / Parsing.py
index 584fc7f3c3a03645da1bdfc4bcfc531fc09f4ff9..527852a50c09ed57ee3c96e6e459ff6ac8923102 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file is used to define common parsing related functions used in parsing INF/DEC/DSC process\r
 #\r
-# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2008 - 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
@@ -14,7 +14,7 @@
 ##\r
 # Import Modules\r
 #\r
-from String import *\r
+from StringUtils import *\r
 from CommonDataClass.DataClass import *\r
 from DataType import *\r
 \r
@@ -37,16 +37,14 @@ def ParseDefineMacro2(Table, RecordSets, GlobalMacro):
     #\r
     # Overrided by Global Macros\r
     #\r
-    for Key in GlobalMacro.keys():\r
-        Macros[Key] = GlobalMacro[Key]\r
+    Macros.update(GlobalMacro)\r
 \r
     #\r
     # Replace the Macros\r
     #\r
-    for Key in RecordSets.keys():\r
-        if RecordSets[Key] != []:\r
-            for Item in RecordSets[Key]:\r
-                Item[0] = ReplaceMacro(Item[0], Macros)\r
+    for Value in (v for v in RecordSets.values() if v):\r
+        for Item in Value:\r
+            Item[0] = ReplaceMacro(Item[0], Macros)\r
 \r
 ## ParseDefineMacro\r
 #\r
@@ -79,8 +77,7 @@ def ParseDefineMacro(Table, GlobalMacro):
     #\r
     # Overrided by Global Macros\r
     #\r
-    for Key in GlobalMacro.keys():\r
-        Macros[Key] = GlobalMacro[Key]\r
+    Macros.update(GlobalMacro)\r
 \r
     #\r
     # Found all defined macro and replaced\r
@@ -299,7 +296,7 @@ def GetLibraryClassOfInf(Item, ContainerFile, WorkspaceDir, LineNo = -1):
 #\r
 def CheckPcdTokenInfo(TokenInfoString, Section, File, LineNo = -1):\r
     Format = '<TokenSpaceGuidCName>.<PcdCName>'\r
-    if TokenInfoString != '' and TokenInfoString != None:\r
+    if TokenInfoString != '' and TokenInfoString is not None:\r
         TokenInfoList = GetSplitValueList(TokenInfoString, TAB_SPLIT)\r
         if len(TokenInfoList) == 2:\r
             return True\r
@@ -550,7 +547,7 @@ def GetComponents(Lines, Key, KeyValues, CommentCharacter):
     LineList = Lines.split('\n')\r
     for Line in LineList:\r
         Line = CleanString(Line, CommentCharacter)\r
-        if Line == None or Line == '':\r
+        if Line is None or Line == '':\r
             continue\r
 \r
         if findBlock == False:\r