]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Workspace/MetaFileParser.py
BaseTools: Fix old python2 idioms
[mirror_edk2.git] / BaseTools / Source / Python / Workspace / MetaFileParser.py
index 4ab3c137dd7a37108487f1baf52fcc04f25e5366..8c860d594b4fe725ade3480b34ea7922be185090 100644 (file)
@@ -78,10 +78,10 @@ def ParseMacro(Parser):
             #\r
             # First judge whether this DEFINE is in conditional directive statements or not.\r
             #\r
-            if type(self) == DscParser and self._InDirective > -1:\r
+            if isinstance(self, DscParser) and self._InDirective > -1:\r
                 pass\r
             else:\r
-                if type(self) == DecParser:\r
+                if isinstance(self, DecParser):\r
                     if MODEL_META_DATA_HEADER in self._SectionType:\r
                         self._FileLocalMacros[Name] = Value\r
                     else:\r
@@ -92,7 +92,7 @@ def ParseMacro(Parser):
                     self._ConstructSectionMacroDict(Name, Value)\r
 \r
         # EDK_GLOBAL defined macros\r
-        elif type(self) != DscParser:\r
+        elif not isinstance(self, DscParser):\r
             EdkLogger.error('Parser', FORMAT_INVALID, "EDK_GLOBAL can only be used in .dsc file",\r
                             ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)\r
         elif self._SectionType != MODEL_META_DATA_HEADER:\r
@@ -233,7 +233,7 @@ class MetaFileParser(object):
     #   DataInfo = [data_type, scope1(arch), scope2(platform/moduletype)]\r
     #\r
     def __getitem__(self, DataInfo):\r
-        if type(DataInfo) != type(()):\r
+        if not isinstance(DataInfo, type(())):\r
             DataInfo = (DataInfo,)\r
 \r
         # Parse the file first, if necessary\r
@@ -275,7 +275,7 @@ class MetaFileParser(object):
         TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT)\r
         self._ValueList[0:len(TokenList)] = TokenList\r
         # Don't do macro replacement for dsc file at this point\r
-        if type(self) != DscParser:\r
+        if not isinstance(self, DscParser):\r
             Macros = self._Macros\r
             self._ValueList = [ReplaceMacro(Value, Macros) for Value in self._ValueList]\r
 \r
@@ -382,7 +382,7 @@ class MetaFileParser(object):
                 EdkLogger.error('Parser', FORMAT_INVALID, "Invalid version number",\r
                                 ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)\r
 \r
-        if type(self) == InfParser and self._Version < 0x00010005:\r
+        if isinstance(self, InfParser) and self._Version < 0x00010005:\r
             # EDK module allows using defines as macros\r
             self._FileLocalMacros[Name] = Value\r
         self._Defines[Name] = Value\r
@@ -398,7 +398,7 @@ class MetaFileParser(object):
             self._ValueList[1] = TokenList2[1]              # keys\r
         else:\r
             self._ValueList[1] = TokenList[0]\r
-        if len(TokenList) == 2 and type(self) != DscParser: # value\r
+        if len(TokenList) == 2 and not isinstance(self, DscParser): # value\r
             self._ValueList[2] = ReplaceMacro(TokenList[1], self._Macros)\r
 \r
         if self._ValueList[1].count('_') != 4:\r
@@ -426,7 +426,7 @@ class MetaFileParser(object):
         # DecParser SectionType is a list, will contain more than one item only in Pcd Section\r
         # As Pcd section macro usage is not alllowed, so here it is safe\r
         #\r
-        if type(self) == DecParser:\r
+        if isinstance(self, DecParser):\r
             SectionDictKey = self._SectionType[0], ScopeKey\r
         else:\r
             SectionDictKey = self._SectionType, ScopeKey\r
@@ -443,7 +443,7 @@ class MetaFileParser(object):
         SpeSpeMacroDict = {}\r
 \r
         ActiveSectionType = self._SectionType\r
-        if type(self) == DecParser:\r
+        if isinstance(self, DecParser):\r
             ActiveSectionType = self._SectionType[0]\r
 \r
         for (SectionType, Scope) in self._SectionsMacroDict:\r
@@ -1252,7 +1252,7 @@ class DscParser(MetaFileParser):
             Macros.update(self._Symbols)\r
         if GlobalData.BuildOptionPcd:\r
             for Item in GlobalData.BuildOptionPcd:\r
-                if type(Item) is tuple:\r
+                if isinstance(Item, tuple):\r
                     continue\r
                 PcdName, TmpValue = Item.split("=")\r
                 TmpValue = BuildOptionValue(TmpValue, self._GuidDict)\r