BaseTools: Fix old python2 idioms
authorGary Lin <glin@suse.com>
Mon, 25 Jun 2018 10:31:35 +0000 (18:31 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Wed, 27 Jun 2018 08:33:27 +0000 (16:33 +0800)
Based on "futurize -f lib2to3.fixes.fix_idioms"

* Change some type comparisons to isinstance() calls:
    type(x) == T -> isinstance(x, T)
    type(x) is T -> isinstance(x, T)
    type(x) != T -> not isinstance(x, T)
    type(x) is not T -> not isinstance(x, T)

* Change "while 1:" into "while True:".

* Change both

    v = list(EXPR)
    v.sort()
    foo(v)

and the more general

    v = EXPR
    v.sort()
    foo(v)

into

    v = sorted(EXPR)
    foo(v)

Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
31 files changed:
BaseTools/Scripts/MemoryProfileSymbolGen.py
BaseTools/Scripts/UpdateBuildVersions.py
BaseTools/Source/Python/AutoGen/BuildEngine.py
BaseTools/Source/Python/AutoGen/GenDepex.py
BaseTools/Source/Python/Common/Expression.py
BaseTools/Source/Python/Common/Misc.py
BaseTools/Source/Python/Common/RangeExpression.py
BaseTools/Source/Python/Common/StringUtils.py
BaseTools/Source/Python/Common/ToolDefClassObject.py
BaseTools/Source/Python/Common/VpdInfoFile.py
BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py
BaseTools/Source/Python/Eot/Parser.py
BaseTools/Source/Python/GenFds/FdfParser.py
BaseTools/Source/Python/GenFds/GenFds.py
BaseTools/Source/Python/TargetTool/TargetTool.py
BaseTools/Source/Python/UPT/GenMetaFile/GenDecFile.py
BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py
BaseTools/Source/Python/UPT/Library/Misc.py
BaseTools/Source/Python/UPT/Library/ParserValidate.py
BaseTools/Source/Python/UPT/Library/StringUtils.py
BaseTools/Source/Python/UPT/Library/Xml/XmlRoutines.py
BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py
BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py
BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignmentMisc.py
BaseTools/Source/Python/Workspace/BuildClassObject.py
BaseTools/Source/Python/Workspace/DscBuildData.py
BaseTools/Source/Python/Workspace/MetaFileParser.py
BaseTools/Source/Python/build/BuildReport.py
BaseTools/Source/Python/build/build.py
BaseTools/gcc/mingw-gcc-build.py

index 1dbb116bba0d8fc57e0a902f26db35b1ba7a4245..eaae0283c51d07e67075e897dbce626186b4f9ff 100644 (file)
@@ -264,7 +264,7 @@ def main():
         return 1\r
 \r
     try:\r
-        while 1:\r
+        while True:\r
             line = file.readline()\r
             if not line:\r
                 break\r
index fb61b89bfb4c55c9012160e56f0509abf0bae35e..269435bfa4cba59cfcb8b63f66bd4a58d7bf7ae5 100755 (executable)
@@ -253,7 +253,7 @@ def GetSvnRevision(opts):
     StatusCmd = "svn st -v --depth infinity --non-interactive"\r
     contents = ShellCommandResults(StatusCmd, opts)\r
     os.chdir(Cwd)\r
-    if type(contents) is ListType:\r
+    if isinstance(contents, ListType):\r
         for line in contents:\r
             if line.startswith("M "):\r
                 Modified = True\r
@@ -263,7 +263,7 @@ def GetSvnRevision(opts):
     InfoCmd = "svn info %s" % SrcPath.replace("\\", "/").strip()\r
     Revision = 0\r
     contents = ShellCommandResults(InfoCmd, opts)\r
-    if type(contents) is IntType:\r
+    if isinstance(contents, IntType):\r
         return 0, Modified\r
     for line in contents:\r
         line = line.strip()\r
@@ -284,7 +284,7 @@ def CheckSvn(opts):
     VerCmd = "svn --version"\r
     contents = ShellCommandResults(VerCmd, opts)\r
     opts.silent = OriginalSilent\r
-    if type(contents) is IntType:\r
+    if isinstance(contents, IntType):\r
         if opts.verbose:\r
             sys.stdout.write("SVN does not appear to be available.\n")\r
             sys.stdout.flush()\r
index cab4c993dc4485e61bb4555dcd2cb3eeb168e725..e205589c6bd1110e1cb1f929fc30a77ccdee9bd7 100644 (file)
@@ -68,7 +68,7 @@ class TargetDescBlock(object):
         return hash(self.Target.Path)\r
 \r
     def __eq__(self, Other):\r
-        if type(Other) == type(self):\r
+        if isinstance(Other, type(self)):\r
             return Other.Target.Path == self.Target.Path\r
         else:\r
             return str(Other) == self.Target.Path\r
index b69788c37e08ab2b06e9f733c336361efbc073af..e89191a72b9fcc2c408bc252ddae16c1a3e78a19 100644 (file)
@@ -140,7 +140,7 @@ class DependencyExpression:
     def __init__(self, Expression, ModuleType, Optimize=False):\r
         self.ModuleType = ModuleType\r
         self.Phase = gType2Phase[ModuleType]\r
-        if type(Expression) == type([]):\r
+        if isinstance(Expression, type([])):\r
             self.ExpressionString = " ".join(Expression)\r
             self.TokenList = Expression\r
         else:\r
index 9ff4f104256e7d84e5ae955a371eb3cd3e62850d..e1a2c155b7f3d94afa62997413d8a1f6f6b43480 100644 (file)
@@ -245,12 +245,12 @@ class ValueExpression(BaseExpression):
         WrnExp = None\r
 \r
         if Operator not in {"==", "!=", ">=", "<=", ">", "<", "in", "not in"} and \\r
-            (type(Oprand1) == type('') or type(Oprand2) == type('')):\r
+            (isinstance(Oprand1, type('')) or isinstance(Oprand2, type(''))):\r
             raise BadExpression(ERR_STRING_EXPR % Operator)\r
         if Operator in {'in', 'not in'}:\r
-            if type(Oprand1) != type(''):\r
+            if not isinstance(Oprand1, type('')):\r
                 Oprand1 = IntToStr(Oprand1)\r
-            if type(Oprand2) != type(''):\r
+            if not isinstance(Oprand2, type('')):\r
                 Oprand2 = IntToStr(Oprand2)\r
         TypeDict = {\r
             type(0)  : 0,\r
@@ -261,18 +261,18 @@ class ValueExpression(BaseExpression):
 \r
         EvalStr = ''\r
         if Operator in {"!", "NOT", "not"}:\r
-            if type(Oprand1) == type(''):\r
+            if isinstance(Oprand1, type('')):\r
                 raise BadExpression(ERR_STRING_EXPR % Operator)\r
             EvalStr = 'not Oprand1'\r
         elif Operator in {"~"}:\r
-            if type(Oprand1) == type(''):\r
+            if isinstance(Oprand1, type('')):\r
                 raise BadExpression(ERR_STRING_EXPR % Operator)\r
             EvalStr = '~ Oprand1'\r
         else:\r
             if Operator in {"+", "-"} and (type(True) in {type(Oprand1), type(Oprand2)}):\r
                 # Boolean in '+'/'-' will be evaluated but raise warning\r
                 WrnExp = WrnExpression(WRN_BOOL_EXPR)\r
-            elif type('') in {type(Oprand1), type(Oprand2)} and type(Oprand1)!= type(Oprand2):\r
+            elif type('') in {type(Oprand1), type(Oprand2)} and not isinstance(Oprand1, type(Oprand2)):\r
                 # == between string and number/boolean will always return False, != return True\r
                 if Operator == "==":\r
                     WrnExp = WrnExpression(WRN_EQCMP_STR_OTHERS)\r
@@ -293,11 +293,11 @@ class ValueExpression(BaseExpression):
                     pass\r
                 else:\r
                     raise BadExpression(ERR_EXPR_TYPE)\r
-            if type(Oprand1) == type('') and type(Oprand2) == type(''):\r
+            if isinstance(Oprand1, type('')) and isinstance(Oprand2, type('')):\r
                 if (Oprand1.startswith('L"') and not Oprand2.startswith('L"')) or \\r
                     (not Oprand1.startswith('L"') and Oprand2.startswith('L"')):\r
                     raise BadExpression(ERR_STRING_CMP % (Oprand1, Operator, Oprand2))\r
-            if 'in' in Operator and type(Oprand2) == type(''):\r
+            if 'in' in Operator and isinstance(Oprand2, type('')):\r
                 Oprand2 = Oprand2.split()\r
             EvalStr = 'Oprand1 ' + Operator + ' Oprand2'\r
 \r
@@ -325,7 +325,7 @@ class ValueExpression(BaseExpression):
     def __init__(self, Expression, SymbolTable={}):\r
         super(ValueExpression, self).__init__(self, Expression, SymbolTable)\r
         self._NoProcess = False\r
-        if type(Expression) != type(''):\r
+        if not isinstance(Expression, type('')):\r
             self._Expr = Expression\r
             self._NoProcess = True\r
             return\r
@@ -373,7 +373,7 @@ class ValueExpression(BaseExpression):
                 Token = self._GetToken()\r
             except BadExpression:\r
                 pass\r
-            if type(Token) == type('') and Token.startswith('{') and Token.endswith('}') and self._Idx >= self._Len:\r
+            if isinstance(Token, type('')) and Token.startswith('{') and Token.endswith('}') and self._Idx >= self._Len:\r
                 return self._Expr\r
 \r
             self._Idx = 0\r
@@ -381,7 +381,7 @@ class ValueExpression(BaseExpression):
 \r
         Val = self._ConExpr()\r
         RealVal = Val\r
-        if type(Val) == type(''):\r
+        if isinstance(Val, type('')):\r
             if Val == 'L""':\r
                 Val = False\r
             elif not Val:\r
@@ -640,7 +640,7 @@ class ValueExpression(BaseExpression):
                 Ex.Pcd = self._Token\r
                 raise Ex\r
             self._Token = ValueExpression(self._Symb[self._Token], self._Symb)(True, self._Depth+1)\r
-            if type(self._Token) != type(''):\r
+            if not isinstance(self._Token, type('')):\r
                 self._LiteralToken = hex(self._Token)\r
                 return\r
 \r
@@ -735,7 +735,7 @@ class ValueExpression(BaseExpression):
                 if Ch == ')':\r
                     TmpValue = self._Expr[Idx :self._Idx - 1]\r
                     TmpValue = ValueExpression(TmpValue)(True)\r
-                    TmpValue = '0x%x' % int(TmpValue) if type(TmpValue) != type('') else TmpValue\r
+                    TmpValue = '0x%x' % int(TmpValue) if not isinstance(TmpValue, type('')) else TmpValue\r
                     break\r
             self._Token, Size = ParseFieldValue(Prefix + '(' + TmpValue + ')')\r
             return  self._Token\r
@@ -824,7 +824,7 @@ class ValueExpressionEx(ValueExpression):
                 PcdValue = PcdValue.strip()\r
                 if PcdValue.startswith('{') and PcdValue.endswith('}'):\r
                     PcdValue = SplitPcdValueString(PcdValue[1:-1])\r
-                if type(PcdValue) == type([]):\r
+                if isinstance(PcdValue, type([])):\r
                     TmpValue = 0\r
                     Size = 0\r
                     ValueType = ''\r
@@ -863,7 +863,7 @@ class ValueExpressionEx(ValueExpression):
                         else:\r
                             ItemValue = ParseFieldValue(Item)[0]\r
 \r
-                        if type(ItemValue) == type(''):\r
+                        if isinstance(ItemValue, type('')):\r
                             ItemValue = int(ItemValue, 0)\r
 \r
                         TmpValue = (ItemValue << (Size * 8)) | TmpValue\r
@@ -873,7 +873,7 @@ class ValueExpressionEx(ValueExpression):
                         TmpValue, Size = ParseFieldValue(PcdValue)\r
                     except BadExpression as Value:\r
                         raise BadExpression("Type: %s, Value: %s, %s" % (self.PcdType, PcdValue, Value))\r
-                if type(TmpValue) == type(''):\r
+                if isinstance(TmpValue, type('')):\r
                     try:\r
                         TmpValue = int(TmpValue)\r
                     except:\r
@@ -996,7 +996,7 @@ class ValueExpressionEx(ValueExpression):
                                     TmpValue = ValueExpressionEx(Item, ValueType, self._Symb)(True)\r
                                 else:\r
                                     TmpValue = ValueExpressionEx(Item, self.PcdType, self._Symb)(True)\r
-                                Item = '0x%x' % TmpValue if type(TmpValue) != type('') else TmpValue\r
+                                Item = '0x%x' % TmpValue if not isinstance(TmpValue, type('')) else TmpValue\r
                                 if ItemSize == 0:\r
                                     ItemValue, ItemSize = ParseFieldValue(Item)\r
                                     if Item[0] not in {'"', 'L', '{'} and ItemSize > 1:\r
index fd53b6b046c4442ea066f2c7e4cd3bf3e80d3be5..55e3c6f2281b4d3ede9e4687ee014475e9176d66 100644 (file)
@@ -1291,9 +1291,9 @@ def ParseDevPathValue (Value):
     return '{' + out + '}', Size\r
 \r
 def ParseFieldValue (Value):\r
-    if type(Value) == type(0):\r
+    if isinstance(Value, type(0)):\r
         return Value, (Value.bit_length() + 7) / 8\r
-    if type(Value) != type(''):\r
+    if not isinstance(Value, type('')):\r
         raise BadExpression('Type %s is %s' %(Value, type(Value)))\r
     Value = Value.strip()\r
     if Value.startswith(TAB_UINT8) and Value.endswith(')'):\r
@@ -1584,8 +1584,7 @@ def CheckPcdDatum(Type, Value):
             Printset.add(TAB_PRINTCHAR_BS)\r
             Printset.add(TAB_PRINTCHAR_NUL)\r
             if not set(Value).issubset(Printset):\r
-                PrintList = list(Printset)\r
-                PrintList.sort()\r
+                PrintList = sorted(Printset)\r
                 return False, "Invalid PCD string value of type [%s]; must be printable chars %s." % (Type, PrintList)\r
     elif Type == 'BOOLEAN':\r
         if Value not in ['TRUE', 'True', 'true', '0x1', '0x01', '1', 'FALSE', 'False', 'false', '0x0', '0x00', '0']:\r
@@ -1747,7 +1746,7 @@ class PathClass(object):
     # @retval True  The two PathClass are the same\r
     #\r
     def __eq__(self, Other):\r
-        if type(Other) == type(self):\r
+        if isinstance(Other, type(self)):\r
             return self.Path == Other.Path\r
         else:\r
             return self.Path == str(Other)\r
@@ -1760,7 +1759,7 @@ class PathClass(object):
     # @retval -1    The first PathClass is less than the second PathClass\r
     # @retval 1     The first PathClass is Bigger than the second PathClass\r
     def __cmp__(self, Other):\r
-        if type(Other) == type(self):\r
+        if isinstance(Other, type(self)):\r
             OtherKey = Other.Path\r
         else:\r
             OtherKey = str(Other)\r
@@ -2010,7 +2009,7 @@ class SkuClass():
             return ["DEFAULT"]\r
         skulist = [sku]\r
         nextsku = sku\r
-        while 1:\r
+        while True:\r
             nextsku = self.GetNextSkuId(nextsku)\r
             skulist.append(nextsku)\r
             if nextsku == "DEFAULT":\r
index 1cf975ba7bef626404f5f8a346c0951839863f80..014c75b8cebde26893395b38f15203da6e00d662 100644 (file)
@@ -97,7 +97,7 @@ class XOROperatorObject(object):
     def __init__(self):     \r
         pass\r
     def Calculate(self, Operand, DataType, SymbolTable): \r
-        if type(Operand) == type('') and not Operand.isalnum():\r
+        if isinstance(Operand, type('')) and not Operand.isalnum():\r
             Expr = "XOR ..."\r
             raise BadExpression(ERR_SNYTAX % Expr)\r
         rangeId = str(uuid.uuid1())\r
@@ -111,7 +111,7 @@ class LEOperatorObject(object):
     def __init__(self):     \r
         pass\r
     def Calculate(self, Operand, DataType, SymbolTable): \r
-        if type(Operand) == type('') and not Operand.isalnum():\r
+        if isinstance(Operand, type('')) and not Operand.isalnum():\r
             Expr = "LE ..."\r
             raise BadExpression(ERR_SNYTAX % Expr)\r
         rangeId1 = str(uuid.uuid1())\r
@@ -123,7 +123,7 @@ class LTOperatorObject(object):
     def __init__(self):     \r
         pass\r
     def Calculate(self, Operand, DataType, SymbolTable):\r
-        if type(Operand) == type('') and not Operand.isalnum():\r
+        if isinstance(Operand, type('')) and not Operand.isalnum():\r
             Expr = "LT ..." \r
             raise BadExpression(ERR_SNYTAX % Expr) \r
         rangeId1 = str(uuid.uuid1())\r
@@ -136,7 +136,7 @@ class GEOperatorObject(object):
     def __init__(self):     \r
         pass\r
     def Calculate(self, Operand, DataType, SymbolTable): \r
-        if type(Operand) == type('') and not Operand.isalnum():\r
+        if isinstance(Operand, type('')) and not Operand.isalnum():\r
             Expr = "GE ..."\r
             raise BadExpression(ERR_SNYTAX % Expr)\r
         rangeId1 = str(uuid.uuid1())\r
@@ -149,7 +149,7 @@ class GTOperatorObject(object):
     def __init__(self):     \r
         pass\r
     def Calculate(self, Operand, DataType, SymbolTable): \r
-        if type(Operand) == type('') and not Operand.isalnum():\r
+        if isinstance(Operand, type('')) and not Operand.isalnum():\r
             Expr = "GT ..."\r
             raise BadExpression(ERR_SNYTAX % Expr)\r
         rangeId1 = str(uuid.uuid1())\r
@@ -162,7 +162,7 @@ class EQOperatorObject(object):
     def __init__(self):     \r
         pass\r
     def Calculate(self, Operand, DataType, SymbolTable): \r
-        if type(Operand) == type('') and not Operand.isalnum():\r
+        if isinstance(Operand, type('')) and not Operand.isalnum():\r
             Expr = "EQ ..."\r
             raise BadExpression(ERR_SNYTAX % Expr)\r
         rangeId1 = str(uuid.uuid1())\r
@@ -350,7 +350,7 @@ class RangeExpression(BaseExpression):
     def __init__(self, Expression, PcdDataType, SymbolTable = {}):\r
         super(RangeExpression, self).__init__(self, Expression, PcdDataType, SymbolTable)\r
         self._NoProcess = False\r
-        if type(Expression) != type(''):\r
+        if not isinstance(Expression, type('')):\r
             self._Expr = Expression\r
             self._NoProcess = True\r
             return\r
@@ -571,7 +571,7 @@ class RangeExpression(BaseExpression):
                 Ex.Pcd = self._Token\r
                 raise Ex\r
             self._Token = RangeExpression(self._Symb[self._Token], self._Symb)(True, self._Depth + 1)\r
-            if type(self._Token) != type(''):\r
+            if not isinstance(self._Token, type('')):\r
                 self._LiteralToken = hex(self._Token)\r
                 return\r
 \r
index 25dd4b264c2fc0f0cfb16ac90e58b7fda5f28f69..3f6bae3bdc39c740eb43ff7dc5151baded35eba9 100644 (file)
@@ -251,7 +251,7 @@ def SplitModuleType(Key):
 def ReplaceMacros(StringList, MacroDefinitions={}, SelfReplacement=False):\r
     NewList = []\r
     for String in StringList:\r
-        if type(String) == type(''):\r
+        if isinstance(String, type('')):\r
             NewList.append(ReplaceMacro(String, MacroDefinitions, SelfReplacement))\r
         else:\r
             NewList.append(String)\r
@@ -793,7 +793,7 @@ def RemoveBlockComment(Lines):
 # Get String of a List\r
 #\r
 def GetStringOfList(List, Split=' '):\r
-    if type(List) != type([]):\r
+    if not isinstance(List, type([])):\r
         return List\r
     Str = ''\r
     for Item in List:\r
index fb95a0353cefd590438e4a1503abe08970e70ed7..7cc7e22839e159ce86b6a46159bd021cb628cab2 100644 (file)
@@ -158,7 +158,7 @@ class ToolDefClassObject(object):
                             if ErrorCode != 0:\r
                                 EdkLogger.error("tools_def.txt parser", FILE_NOT_FOUND, ExtraData=IncFile)\r
 \r
-                    if type(IncFileTmp) is PathClass:\r
+                    if isinstance(IncFileTmp, PathClass):\r
                         IncFile = IncFileTmp.Path\r
                     else:\r
                         IncFile = IncFileTmp\r
index 93175d41e9f7a0638f6caebc90459fa4873e79f7..b98c021b57770a45cb9cd78f224ad54542c92883 100644 (file)
@@ -127,8 +127,7 @@ class VpdInfoFile:
                             "Invalid parameter FilePath: %s." % FilePath)        \r
 \r
         Content = FILE_COMMENT_TEMPLATE\r
-        Pcds = self._VpdArray.keys()\r
-        Pcds.sort()\r
+        Pcds = sorted(self._VpdArray.keys())\r
         for Pcd in Pcds:\r
             i = 0\r
             PcdTokenCName = Pcd.TokenCName\r
index b3b0ede7e8f32cdf859f92cc540d9bb2ed75ae86..a41223f285fffcd39d0f1d4e9125a787ca24abcf 100644 (file)
@@ -68,7 +68,7 @@ def ParseMacro(Parser):
         self._ItemType = MODEL_META_DATA_DEFINE\r
         # DEFINE defined macros\r
         if Type == TAB_DSC_DEFINES_DEFINE:\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
@@ -83,7 +83,7 @@ def ParseMacro(Parser):
                 SectionLocalMacros = self._SectionsMacroDict[SectionDictKey]\r
                 SectionLocalMacros[Name] = Value\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
@@ -215,7 +215,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
@@ -257,7 +257,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
@@ -355,7 +355,7 @@ class MetaFileParser(object):
             if os.path.exists(UniFile):\r
                 self._UniObj = UniParser(UniFile, IsExtraUni=False, IsModuleUni=False)\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
@@ -370,7 +370,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
index 811106133cb4ad3a4dccf5a27c79a105298aa09c..1e45806fa65738320e5e2e36a8ece14fb3b15299 100644 (file)
@@ -35,7 +35,7 @@ def CreateXmlElement(Name, String, NodeList, AttributeList):
         Element.appendChild(Doc.createTextNode(String))\r
     \r
     for Item in NodeList:\r
-        if type(Item) == type([]):\r
+        if isinstance(Item, type([])):\r
             Key = Item[0]\r
             Value = Item[1]\r
             if Key != '' and Key is not None and Value != '' and Value is not None:\r
index ff88e957ad0df6f99eb2045e17bafa96272ae0b1..0b720d5b2187c6962dc264a45fe8daec3f30c384 100644 (file)
@@ -730,7 +730,7 @@ def GetParameter(Parameter, Index = 1):
 #  @return: The name of parameter\r
 #\r
 def GetParameterName(Parameter):\r
-    if type(Parameter) == type('') and Parameter.startswith('&'):\r
+    if isinstance(Parameter, type('')) and Parameter.startswith('&'):\r
         return Parameter[1:].replace('{', '').replace('}', '').replace('\r', '').replace('\n', '').strip()\r
     else:\r
         return Parameter.strip()\r
index 74785e0a93fea036809820272a9763467211d8c2..b57ffc778f5e844cabe4fa5b4b774b87db1f7bcc 100644 (file)
@@ -905,7 +905,7 @@ class FdfParser:
         MacroDict.update(GlobalData.gCommandLineDefines)\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, {})\r
index 1552ab4ee3a8aa74a0def9f25a95b5be72be1850..912e6c58f4020936c9790cb70573054990373e3e 100644 (file)
@@ -785,7 +785,7 @@ class GenFds :
                         if not Name:\r
                             continue\r
 \r
-                        Name = ' '.join(Name) if type(Name) == type([]) else Name\r
+                        Name = ' '.join(Name) if isinstance(Name, type([])) else Name\r
                         GuidXRefFile.write("%s %s\n" %(FileStatementGuid, Name))\r
 \r
        # Append GUIDs, Protocols, and PPIs to the Xref file\r
index ed567b870816dc08578502240f315086f3d04344..26d2bb9ebfce1ab4bc8dc5b253d71201810ce949 100644 (file)
@@ -83,7 +83,7 @@ class TargetTool():
     def Print(self):\r
         errMsg  = ''\r
         for Key in self.TargetTxtDictionary:\r
-            if type(self.TargetTxtDictionary[Key]) == type([]):\r
+            if isinstance(self.TargetTxtDictionary[Key], type([])):\r
                 print("%-30s = %s" % (Key, ''.join(elem + ' ' for elem in self.TargetTxtDictionary[Key])))\r
             elif self.TargetTxtDictionary[Key] is None:\r
                 errMsg += "  Missing %s configuration information, please use TargetTool to set value!" % Key + os.linesep \r
index 9397359367e7ae84124f87184f881e712cd15c30..a1a9d38087ee854fb465bf724eb79ce56fbf9525 100644 (file)
@@ -123,8 +123,7 @@ def GenPcd(Package, Content):
         if Pcd.GetSupModuleList():\r
             Statement += GenDecTailComment(Pcd.GetSupModuleList())\r
 \r
-        ArchList = Pcd.GetSupArchList()\r
-        ArchList.sort()\r
+        ArchList = sorted(Pcd.GetSupArchList())\r
         SortedArch = ' '.join(ArchList)\r
         if SortedArch in NewSectionDict:\r
             NewSectionDict[SortedArch] = \\r
@@ -205,8 +204,7 @@ def GenGuidProtocolPpi(Package, Content):
         #\r
         if Guid.GetSupModuleList():\r
             Statement += GenDecTailComment(Guid.GetSupModuleList())     \r
-        ArchList = Guid.GetSupArchList()\r
-        ArchList.sort()\r
+        ArchList = sorted(Guid.GetSupArchList())\r
         SortedArch = ' '.join(ArchList)\r
         if SortedArch in NewSectionDict:\r
             NewSectionDict[SortedArch] = \\r
@@ -246,8 +244,7 @@ def GenGuidProtocolPpi(Package, Content):
         #\r
         if Protocol.GetSupModuleList():\r
             Statement += GenDecTailComment(Protocol.GetSupModuleList())\r
-        ArchList = Protocol.GetSupArchList()\r
-        ArchList.sort()\r
+        ArchList = sorted(Protocol.GetSupArchList())\r
         SortedArch = ' '.join(ArchList)\r
         if SortedArch in NewSectionDict:\r
             NewSectionDict[SortedArch] = \\r
@@ -287,8 +284,7 @@ def GenGuidProtocolPpi(Package, Content):
         #\r
         if Ppi.GetSupModuleList():\r
             Statement += GenDecTailComment(Ppi.GetSupModuleList())\r
-        ArchList = Ppi.GetSupArchList()\r
-        ArchList.sort()\r
+        ArchList = sorted(Ppi.GetSupArchList())\r
         SortedArch = ' '.join(ArchList)\r
         if SortedArch in NewSectionDict:\r
             NewSectionDict[SortedArch] = \\r
@@ -463,8 +459,7 @@ def PackageToDec(Package, DistHeader = None):
         if LibraryClass.GetSupModuleList():\r
             Statement += \\r
             GenDecTailComment(LibraryClass.GetSupModuleList())\r
-        ArchList = LibraryClass.GetSupArchList()\r
-        ArchList.sort()\r
+        ArchList = sorted(LibraryClass.GetSupArchList())\r
         SortedArch = ' '.join(ArchList)\r
         if SortedArch in NewSectionDict:\r
             NewSectionDict[SortedArch] = \\r
index b97b319e0956e7209484af0d77ca07805168e0be..9457f851f4ec21aac68905e1a1f0f6eeb12e0712 100644 (file)
@@ -493,8 +493,7 @@ def GenPackages(ModuleObject):
         Statement += RelaPath.replace('\\', '/')\r
         if FFE:\r
             Statement += '|' + FFE\r
-        ArchList = PackageDependency.GetSupArchList()\r
-        ArchList.sort()\r
+        ArchList = sorted(PackageDependency.GetSupArchList())\r
         SortedArch = ' '.join(ArchList)\r
         if SortedArch in NewSectionDict:\r
             NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [Statement]\r
@@ -513,8 +512,7 @@ def GenSources(ModuleObject):
         SourceFile = Source.GetSourceFile()\r
         Family = Source.GetFamily()\r
         FeatureFlag = Source.GetFeatureFlag()\r
-        SupArchList = Source.GetSupArchList()\r
-        SupArchList.sort()\r
+        SupArchList = sorted(Source.GetSupArchList())\r
         SortedArch = ' '.join(SupArchList)\r
         Statement = GenSourceStatement(ConvertPath(SourceFile), Family, FeatureFlag)\r
         if SortedArch in NewSectionDict:\r
@@ -722,8 +720,7 @@ def GenGuidSections(GuidObjList):
         #\r
         # merge duplicate items\r
         #\r
-        ArchList = Guid.GetSupArchList()\r
-        ArchList.sort()\r
+        ArchList = sorted(Guid.GetSupArchList())\r
         SortedArch = ' '.join(ArchList)\r
         if (Statement, SortedArch) in GuidDict:\r
             PreviousComment = GuidDict[Statement, SortedArch]\r
@@ -782,8 +779,7 @@ def GenProtocolPPiSections(ObjList, IsProtocol):
         #\r
         # merge duplicate items\r
         #\r
-        ArchList = Object.GetSupArchList()\r
-        ArchList.sort()\r
+        ArchList = sorted(Object.GetSupArchList())\r
         SortedArch = ' '.join(ArchList)\r
         if (Statement, SortedArch) in Dict:\r
             PreviousComment = Dict[Statement, SortedArch]\r
@@ -857,8 +853,7 @@ def GenPcdSections(ModuleObject):
             #\r
             # Merge duplicate entries\r
             #\r
-            ArchList = Pcd.GetSupArchList()\r
-            ArchList.sort()\r
+            ArchList = sorted(Pcd.GetSupArchList())\r
             SortedArch = ' '.join(ArchList)\r
             if (Statement, SortedArch) in Dict:\r
                 PreviousComment = Dict[Statement, SortedArch]\r
@@ -1025,8 +1020,7 @@ def GenSpecialSections(ObjectList, SectionName, UserExtensionsContent=''):
         if CommentStr and not CommentStr.endswith('\n#\n'):\r
             CommentStr = CommentStr + '#\n'\r
         NewStateMent = CommentStr + Statement\r
-        SupArch = Obj.GetSupArchList()\r
-        SupArch.sort()\r
+        SupArch = sorted(Obj.GetSupArchList())\r
         SortedArch = ' '.join(SupArch)\r
         if SortedArch in NewSectionDict:\r
             NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [NewStateMent]\r
@@ -1104,8 +1098,7 @@ def GenBinaries(ModuleObject):
             FileName = ConvertPath(FileNameObj.GetFilename())\r
             FileType = FileNameObj.GetFileType()\r
             FFE = FileNameObj.GetFeatureFlag()\r
-            ArchList = FileNameObj.GetSupArchList()\r
-            ArchList.sort()\r
+            ArchList = sorted(FileNameObj.GetSupArchList())\r
             SortedArch = ' '.join(ArchList)\r
             Key = (FileName, FileType, FFE, SortedArch)\r
             if Key in BinariesDict:\r
index e16d309ef8838a52bb43ad061f96263976c968dd..28471d81238aeb283e4cea9a8a569e73d43e2966 100644 (file)
@@ -514,7 +514,7 @@ class PathClass(object):
     # Check whether PathClass are the same\r
     #\r
     def __eq__(self, Other):\r
-        if type(Other) == type(self):\r
+        if isinstance(Other, type(self)):\r
             return self.Path == Other.Path\r
         else:\r
             return self.Path == str(Other)\r
@@ -819,11 +819,11 @@ def ConvertArchList(ArchList):
     if not ArchList:\r
         return NewArchList\r
 \r
-    if type(ArchList) == list:\r
+    if isinstance(ArchList, list):\r
         for Arch in ArchList:\r
             Arch = Arch.upper()\r
             NewArchList.append(Arch)\r
-    elif type(ArchList) == str:\r
+    elif isinstance(ArchList, str):\r
         ArchList = ArchList.upper()\r
         NewArchList.append(ArchList)\r
 \r
index 3f8ca9d609aec524cf9f2d999678230bc0ae2b90..dc93cedd917e604b607b3868b960fe88a4b09931 100644 (file)
@@ -341,7 +341,7 @@ def IsValidCFormatGuid(Guid):
                 #\r
                 # Index may out of bound\r
                 #\r
-                if type(List[Index]) != type(1) or \\r
+                if not isinstance(List[Index], type(1)) or \\r
                    len(Value) > List[Index] or len(Value) < 3:\r
                     return False\r
                 \r
index bd2cbe6120372a87e29a7e8f6e248b243733cda6..2be382fa1797041fee13bf8e31323311237496a6 100644 (file)
@@ -651,7 +651,7 @@ def ConvertToSqlString2(String):
 # @param Split: split character\r
 #\r
 def GetStringOfList(List, Split=' '):\r
-    if type(List) != type([]):\r
+    if not isinstance(List, type([])):\r
         return List\r
     Str = ''\r
     for Item in List:\r
index 1096bc5b18498c99ce37f24a22242932d8843df1..dbaee678af45a3906634e0870f0eee993049ef37 100644 (file)
@@ -40,7 +40,7 @@ def CreateXmlElement(Name, String, NodeList, AttributeList):
         Element.appendChild(Doc.createTextNode(String))\r
 \r
     for Item in NodeList:\r
-        if type(Item) == type([]):\r
+        if isinstance(Item, type([])):\r
             Key = Item[0]\r
             Value = Item[1]\r
             if Key != '' and Key is not None and Value != '' and Value is not None:\r
index e2908bcda98b97551bbd23354c13b5358cbb14c3..941dd4a39891c347d549a6c95ac566343d44696c 100644 (file)
@@ -409,8 +409,7 @@ class DecPomAlignment(PackageObject):
         # \r
         PackagePath = os.path.split(self.GetFullPath())[0]\r
         IncludePathList = \\r
-            [os.path.normpath(Path) + sep for Path in IncludesDict.keys()]\r
-        IncludePathList.sort()\r
+            sorted([os.path.normpath(Path) + sep for Path in IncludesDict.keys()])\r
         \r
         #\r
         # get a non-overlap set of include path, IncludePathList should be \r
index a5929e15de2d68d6677fce10ae4683b658f21cce..84f0d43f015ed4513e2771ef4d52564973afc0f8 100644 (file)
@@ -611,8 +611,7 @@ class InfPomAlignment(ModuleObject):
                 SourceFile = Item.GetSourceFileName()\r
                 Family = Item.GetFamily()\r
                 FeatureFlag = Item.GetFeatureFlagExp()\r
-                SupArchList = ConvertArchList(Item.GetSupArchList())\r
-                SupArchList.sort()\r
+                SupArchList = sorted(ConvertArchList(Item.GetSupArchList()))\r
                 Source = SourceFileObject()\r
                 Source.SetSourceFile(SourceFile)\r
                 Source.SetFamily(Family)\r
index cee42516231ccbaf3011b2379bf30928273b0ac3..3bb506bea660a92ca4e301a530597ad5eeb5bb15 100644 (file)
@@ -194,8 +194,7 @@ def GenBinaryData(BinaryData, BinaryObj, BinariesDict, AsBuildIns, BinaryFileObj
         # can be used for the attribute.\r
         # If both not have VALID_ARCHITECTURE comment and no architecturie specified, then keep it empty.\r
         #        \r
-        SupArchList = ConvertArchList(ItemObj.GetSupArchList())\r
-        SupArchList.sort()\r
+        SupArchList = sorted(ConvertArchList(ItemObj.GetSupArchList()))\r
         if len(SupArchList) == 1 and SupArchList[0] == 'COMMON':\r
             if not (len(OriSupArchList) == 1 or OriSupArchList[0] == 'COMMON'):\r
                 SupArchList = OriSupArchList\r
index 2569235fb8755413ac25435c8ac1de28e805a5f5..c188b47534f889f75bf8fa34b6cbb99bcc377efc 100644 (file)
@@ -217,7 +217,7 @@ class StructurePcd(PcdClassObject):
         self.DscRawValue = PcdObject.DscRawValue if PcdObject.DscRawValue else self.DscRawValue\r
         self.PcdValueFromComm = PcdObject.PcdValueFromComm if PcdObject.PcdValueFromComm else self.PcdValueFromComm\r
         self.DefinitionPosition = PcdObject.DefinitionPosition if PcdObject.DefinitionPosition else self.DefinitionPosition\r
-        if type(PcdObject) is StructurePcd:\r
+        if isinstance(PcdObject, StructurePcd):\r
             self.StructuredPcdIncludeFile = PcdObject.StructuredPcdIncludeFile if PcdObject.StructuredPcdIncludeFile else self.StructuredPcdIncludeFile\r
             self.PackageDecs = PcdObject.PackageDecs if PcdObject.PackageDecs else self.PackageDecs\r
             self.DefaultValues = PcdObject.DefaultValues if PcdObject.DefaultValues else self.DefaultValues\r
index 9e7b8a18c28bd5bfa1ca6cef2914320f554d5575..06732e6fade40845c51100bb738c899b8c05d4d3 100644 (file)
@@ -927,13 +927,13 @@ class DscBuildData(PlatformBuildClassObject):
             for pcdname in Pcds:\r
                 pcd = Pcds[pcdname]\r
                 Pcds[pcdname].SkuInfoList = {TAB_DEFAULT:pcd.SkuInfoList[skuid] for skuid in pcd.SkuInfoList if skuid in available_sku}\r
-                if type(pcd) is StructurePcd and pcd.SkuOverrideValues:\r
+                if isinstance(pcd, StructurePcd) and pcd.SkuOverrideValues:\r
                     Pcds[pcdname].SkuOverrideValues = {TAB_DEFAULT:pcd.SkuOverrideValues[skuid] for skuid in pcd.SkuOverrideValues if skuid in available_sku}\r
         else:\r
             for pcdname in Pcds:\r
                 pcd = Pcds[pcdname]\r
                 Pcds[pcdname].SkuInfoList = {skuid:pcd.SkuInfoList[skuid] for skuid in pcd.SkuInfoList if skuid in available_sku}\r
-                if type(pcd) is StructurePcd and pcd.SkuOverrideValues:\r
+                if isinstance(pcd, StructurePcd) and pcd.SkuOverrideValues:\r
                     Pcds[pcdname].SkuOverrideValues = {skuid:pcd.SkuOverrideValues[skuid] for skuid in pcd.SkuOverrideValues if skuid in available_sku}\r
         return Pcds\r
     def CompleteHiiPcdsDefaultStores(self, Pcds):\r
@@ -964,7 +964,7 @@ class DscBuildData(PlatformBuildClassObject):
     def __ParsePcdFromCommandLine(self):\r
         if GlobalData.BuildOptionPcd:\r
             for i, pcd in enumerate(GlobalData.BuildOptionPcd):\r
-                if type(pcd) is tuple:\r
+                if isinstance(pcd, tuple):\r
                     continue\r
                 (pcdname, pcdvalue) = pcd.split('=')\r
                 if not pcdvalue:\r
@@ -1320,7 +1320,7 @@ class DscBuildData(PlatformBuildClassObject):
                             File=self.MetaFile, Line = StrPcdSet[str_pcd][0][5])\r
         # Add the Structure PCD that only defined in DEC, don't have override in DSC file\r
         for Pcd in self.DecPcds:\r
-            if type (self._DecPcds[Pcd]) is StructurePcd:\r
+            if isinstance(self._DecPcds[Pcd], StructurePcd):\r
                 if Pcd not in S_pcd_set:\r
                     str_pcd_obj_str = StructurePcd()\r
                     str_pcd_obj_str.copy(self._DecPcds[Pcd])\r
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
index 454ea7d088b42f9c300605cc45f54bb93697bdc5..c9648a9299dd158086458cc3037654e366d2b1ab 100644 (file)
@@ -1865,8 +1865,7 @@ class FdRegionReport(object):
                 for Match in gOffsetGuidPattern.finditer(FvReport):\r
                     Guid = Match.group(2).upper()\r
                     OffsetInfo[Match.group(1)] = self._GuidsDb.get(Guid, Guid)\r
-                OffsetList = OffsetInfo.keys()\r
-                OffsetList.sort()\r
+                OffsetList = sorted(OffsetInfo.keys())\r
                 for Offset in OffsetList:\r
                     FileWrite (File, "%s %s" % (Offset, OffsetInfo[Offset]))\r
             except IOError:\r
index 49869d9ee4e63b333f93dfd4e9a775033850274d..bf1f853d56be0720c9bbdd0ed83da08abe1f59bc 100644 (file)
@@ -305,7 +305,7 @@ def LaunchCommand(Command, WorkingDir):
         if EndOfProcedure is not None:\r
             EndOfProcedure.set()\r
         if Proc is None:\r
-            if type(Command) != type(""):\r
+            if not isinstance(Command, type("")):\r
                 Command = " ".join(Command)\r
             EdkLogger.error("build", COMMAND_FAILURE, "Failed to start command", ExtraData="%s [%s]" % (Command, WorkingDir))\r
 \r
@@ -316,7 +316,7 @@ def LaunchCommand(Command, WorkingDir):
 \r
     # check the return code of the program\r
     if Proc.returncode != 0:\r
-        if type(Command) != type(""):\r
+        if not isinstance(Command, type("")):\r
             Command = " ".join(Command)\r
         # print out the Response file and its content when make failure\r
         RespFile = os.path.join(WorkingDir, 'OUTPUT', 'respfilelist.txt')\r
index 43f57af9036383026bff42a58c8ed3ac0e965e63..e940cdb73fcaad8df210e21b7fa81f2a68fec31e 100755 (executable)
@@ -257,9 +257,9 @@ class SourceFiles:
             replaceables = ('extract-dir', 'filename', 'url')
             for replaceItem in fdata:
                 if replaceItem in replaceables: continue
-                if type(fdata[replaceItem]) != str: continue
+                if not isinstance(fdata[replaceItem], str): continue\r
                 for replaceable in replaceables:
-                    if type(fdata[replaceable]) != str: continue
+                    if not isinstance(fdata[replaceable], str): continue\r
                     if replaceable in fdata:
                         fdata[replaceable] = \
                             fdata[replaceable].replace(