]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/TargetTool/TargetTool.py
BaseTools: use set instead of list for a variable to be used with in
[mirror_edk2.git] / BaseTools / Source / Python / TargetTool / TargetTool.py
index bfdf763a7abc8d1771659fec52552d0e7b0eacc8..143b53ec35efb516647287608910a34de622c5c3 100644 (file)
@@ -80,12 +80,11 @@ class TargetTool():
             traceback.print_exception(last_type, last_value, last_tb)\r
 \r
     def Print(self):\r
-        KeyList = self.TargetTxtDictionary.keys()\r
         errMsg  = ''\r
-        for Key in KeyList:\r
+        for Key in self.TargetTxtDictionary:\r
             if type(self.TargetTxtDictionary[Key]) == type([]):\r
                 print "%-30s = %s" % (Key, ''.join(elem + ' ' for elem in self.TargetTxtDictionary[Key]))\r
-            elif self.TargetTxtDictionary[Key] == None:\r
+            elif self.TargetTxtDictionary[Key] is None:\r
                 errMsg += "  Missing %s configuration information, please use TargetTool to set value!" % Key + os.linesep \r
             else:\r
                 print "%-30s = %s" % (Key, self.TargetTxtDictionary[Key])\r
@@ -116,14 +115,14 @@ class TargetTool():
                                 Line = "%-30s = \n" % Key\r
                             else:\r
                                 ret = GetConfigureKeyValue(self, Key)\r
-                                if ret != None:\r
+                                if ret is not None:\r
                                     Line = ret\r
                             fw.write(Line)\r
             for key in self.TargetTxtDictionary.keys():\r
                 if key not in existKeys:\r
                     print "Warning: %s does not exist in original configuration file" % key\r
                     Line = GetConfigureKeyValue(self, key)\r
-                    if Line == None:\r
+                    if Line is None:\r
                         Line = "%-30s = " % key\r
                     fw.write(Line)\r
                 \r
@@ -138,14 +137,14 @@ class TargetTool():
 \r
 def GetConfigureKeyValue(self, Key):\r
     Line = None\r
-    if Key == TAB_TAT_DEFINES_ACTIVE_PLATFORM and self.Opt.DSCFILE != None:\r
+    if Key == TAB_TAT_DEFINES_ACTIVE_PLATFORM and self.Opt.DSCFILE is not None:\r
         dscFullPath = os.path.join(self.WorkSpace, self.Opt.DSCFILE)\r
         if os.path.exists(dscFullPath):\r
             Line = "%-30s = %s\n" % (Key, self.Opt.DSCFILE)\r
         else:\r
             EdkLogger.error("TagetTool", BuildToolError.FILE_NOT_FOUND, \r
                             "DSC file %s does not exist!" % self.Opt.DSCFILE, RaiseError=False)\r
-    elif Key == TAB_TAT_DEFINES_TOOL_CHAIN_CONF and self.Opt.TOOL_DEFINITION_FILE != None:\r
+    elif Key == TAB_TAT_DEFINES_TOOL_CHAIN_CONF and self.Opt.TOOL_DEFINITION_FILE is not None:\r
         tooldefFullPath = os.path.join(self.WorkSpace, self.Opt.TOOL_DEFINITION_FILE)\r
         if os.path.exists(tooldefFullPath):\r
             Line = "%-30s = %s\n" % (Key, self.Opt.TOOL_DEFINITION_FILE)\r
@@ -157,15 +156,15 @@ def GetConfigureKeyValue(self, Key):
         Line = "%-30s = %s\n" % (Key, 'Enable')\r
     elif self.Opt.NUM <= 1:\r
         Line = "%-30s = %s\n" % (Key, 'Disable')        \r
-    elif Key == TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER and self.Opt.NUM != None:\r
+    elif Key == TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER and self.Opt.NUM is not None:\r
         Line = "%-30s = %s\n" % (Key, str(self.Opt.NUM))\r
-    elif Key == TAB_TAT_DEFINES_TARGET and self.Opt.TARGET != None:\r
+    elif Key == TAB_TAT_DEFINES_TARGET and self.Opt.TARGET is not None:\r
         Line = "%-30s = %s\n" % (Key, ''.join(elem + ' ' for elem in self.Opt.TARGET))\r
-    elif Key == TAB_TAT_DEFINES_TARGET_ARCH and self.Opt.TARGET_ARCH != None:\r
+    elif Key == TAB_TAT_DEFINES_TARGET_ARCH and self.Opt.TARGET_ARCH is not None:\r
         Line = "%-30s = %s\n" % (Key, ''.join(elem + ' ' for elem in self.Opt.TARGET_ARCH))\r
-    elif Key == TAB_TAT_DEFINES_TOOL_CHAIN_TAG and self.Opt.TOOL_CHAIN_TAG != None:\r
+    elif Key == TAB_TAT_DEFINES_TOOL_CHAIN_TAG and self.Opt.TOOL_CHAIN_TAG is not None:\r
         Line = "%-30s = %s\n" % (Key, self.Opt.TOOL_CHAIN_TAG)\r
-    elif Key == TAB_TAT_DEFINES_BUILD_RULE_CONF and self.Opt.BUILD_RULE_FILE != None:\r
+    elif Key == TAB_TAT_DEFINES_BUILD_RULE_CONF and self.Opt.BUILD_RULE_FILE is not None:\r
         buildruleFullPath = os.path.join(self.WorkSpace, self.Opt.BUILD_RULE_FILE)\r
         if os.path.exists(buildruleFullPath):\r
             Line = "%-30s = %s\n" % (Key, self.Opt.BUILD_RULE_FILE)\r
@@ -223,7 +222,7 @@ def MyOptionParser():
 if __name__ == '__main__':\r
     EdkLogger.Initialize()\r
     EdkLogger.SetLevel(EdkLogger.QUIET)\r
-    if os.getenv('WORKSPACE') == None:\r
+    if os.getenv('WORKSPACE') is None:\r
         print "ERROR: WORKSPACE should be specified or edksetup script should be executed before run TargetTool"\r
         sys.exit(1)\r
         \r
@@ -231,15 +230,15 @@ if __name__ == '__main__':
     if len(args) != 1 or (args[0].lower() != 'print' and args[0].lower() != 'clean' and args[0].lower() != 'set'):\r
         print "The number of args isn't 1 or the value of args is invalid."\r
         sys.exit(1)\r
-    if opt.NUM != None and opt.NUM < 1:\r
+    if opt.NUM is not None and opt.NUM < 1:\r
         print "The MAX_CONCURRENT_THREAD_NUMBER must be larger than 0."\r
         sys.exit(1)\r
-    if opt.TARGET != None and len(opt.TARGET) > 1:\r
+    if opt.TARGET is not None and len(opt.TARGET) > 1:\r
         for elem in opt.TARGET:\r
             if elem == '0':\r
                 print "0 will clear the TARGET setting in target.txt and can't combine with other value."\r
                 sys.exit(1)\r
-    if opt.TARGET_ARCH != None and len(opt.TARGET_ARCH) > 1:\r
+    if opt.TARGET_ARCH is not None and len(opt.TARGET_ARCH) > 1:\r
         for elem in opt.TARGET_ARCH:\r
             if elem == '0':\r
                 print "0 will clear the TARGET_ARCH setting in target.txt and can't combine with other value."\r