]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/TargetTool/TargetTool.py
BaseTools: Refactor python except statements
[mirror_edk2.git] / BaseTools / Source / Python / TargetTool / TargetTool.py
index ede9713c9b8b558be6cd995d02d064b7bc2106b4..9fb89549cc29fed836f7585520327dedaf337542 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # Target Tool Parser\r
 #\r
-#  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -65,7 +65,7 @@ class TargetTool():
                 LineList = Line.split(KeySplitCharacter,1)\r
                 if len(LineList) >= 2:\r
                     Key = LineList[0].strip()\r
-                    if Key.startswith(CommentCharacter) == False and Key in self.TargetTxtDictionary.keys():\r
+                    if Key.startswith(CommentCharacter) == False and Key in self.TargetTxtDictionary:\r
                         if Key == TAB_TAT_DEFINES_ACTIVE_PLATFORM or Key == TAB_TAT_DEFINES_TOOL_CHAIN_CONF \\r
                           or Key == TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER \\r
                           or Key == TAB_TAT_DEFINES_ACTIVE_MODULE:\r
@@ -80,9 +80,8 @@ 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] is None:\r
@@ -106,7 +105,7 @@ class TargetTool():
                     LineList = Line.split(KeySplitCharacter,1)\r
                     if len(LineList) >= 2:\r
                         Key = LineList[0].strip()\r
-                        if Key.startswith(CommentCharacter) == False and Key in self.TargetTxtDictionary.keys():\r
+                        if Key.startswith(CommentCharacter) == False and Key in self.TargetTxtDictionary:\r
                             if Key not in existKeys:\r
                                 existKeys.append(Key)\r
                             else:\r
@@ -119,7 +118,7 @@ class TargetTool():
                                 if ret is not None:\r
                                     Line = ret\r
                             fw.write(Line)\r
-            for key in self.TargetTxtDictionary.keys():\r
+            for key in self.TargetTxtDictionary:\r
                 if key not in existKeys:\r
                     print "Warning: %s does not exist in original configuration file" % key\r
                     Line = GetConfigureKeyValue(self, key)\r
@@ -254,7 +253,7 @@ if __name__ == '__main__':
             FileHandle.RWFile('#', '=', 0)\r
         else:\r
             FileHandle.RWFile('#', '=', 1)\r
-    except Exception, e:\r
+    except Exception as e:\r
         last_type, last_value, last_tb = sys.exc_info()\r
         traceback.print_exception(last_type, last_value, last_tb)\r
 \r