]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Trim/Trim.py
BaseTools: use set instead of list for a variable to be used with in
[mirror_edk2.git] / BaseTools / Source / Python / Trim / Trim.py
index d1e40b025caa0f3f0b86068caea5e626e2f10734..3eb7fa39209d74b6872d66c5fd4b63b84f03f8ca 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # Trim files preprocessed by compiler\r
 #\r
-# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 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
@@ -173,7 +173,7 @@ def TrimPreprocessedFile(Source, Target, ConvertHex, TrimLong):
         elif PreprocessedFile == "" or InjectedFile != PreprocessedFile:\r
             continue\r
 \r
-        if LineIndexOfOriginalFile == None:\r
+        if LineIndexOfOriginalFile is None:\r
             #\r
             # Any non-empty lines must be from original preprocessed file.\r
             # And this must be the first one.\r
@@ -193,7 +193,7 @@ def TrimPreprocessedFile(Source, Target, ConvertHex, TrimLong):
         # convert Decimal number format\r
         Line = gDecNumberPattern.sub(r"\1", Line)\r
 \r
-        if LineNumber != None:\r
+        if LineNumber is not None:\r
             EdkLogger.verbose("Got line directive: line=%d" % LineNumber)\r
             # in case preprocessor removed some lines, like blank or comment lines\r
             if LineNumber <= len(NewLines):\r
@@ -216,10 +216,10 @@ def TrimPreprocessedFile(Source, Target, ConvertHex, TrimLong):
         Brace = 0\r
         for Index in range(len(Lines)):\r
             Line = Lines[Index]\r
-            if MulPatternFlag == False and gTypedef_MulPattern.search(Line) == None:\r
-                if SinglePatternFlag == False and gTypedef_SinglePattern.search(Line) == None:\r
+            if MulPatternFlag == False and gTypedef_MulPattern.search(Line) is None:\r
+                if SinglePatternFlag == False and gTypedef_SinglePattern.search(Line) is None:\r
                     # remove "#pragram pack" directive\r
-                    if gPragmaPattern.search(Line) == None:\r
+                    if gPragmaPattern.search(Line) is None:\r
                         NewLines.append(Line)\r
                     continue\r
                 elif SinglePatternFlag == False:\r
@@ -282,9 +282,9 @@ def TrimPreprocessedVfr(Source, Target):
             Lines[Index] = "\n"\r
             continue\r
 \r
-        if FoundTypedef == False and gTypedefPattern.search(Line) == None:\r
+        if FoundTypedef == False and gTypedefPattern.search(Line) is None:\r
             # keep "#pragram pack" directive\r
-            if gPragmaPattern.search(Line) == None:\r
+            if gPragmaPattern.search(Line) is None:\r
                 Lines[Index] = "\n"\r
             continue\r
         elif FoundTypedef == False:\r
@@ -437,7 +437,7 @@ def GenerateVfrBinSec(ModuleName, DebugDir, OutputFile):
         for CurrentDir, Dirs, Files in os.walk(DebugDir):\r
             for FileName in Files:\r
                 Name, Ext = os.path.splitext(FileName)\r
-                if Ext == '.lst':\r
+                if Ext == '.c' and Name != 'AutoGen':\r
                     VfrNameList.append (Name + 'Bin')\r
 \r
     VfrNameList.append (ModuleName + 'Strings')\r
@@ -510,7 +510,7 @@ def TrimEdkSources(Source, Target):
             for FileName in Files:\r
                 Dummy, Ext = os.path.splitext(FileName)\r
                 if Ext.upper() not in ['.C', '.H']: continue\r
-                if Target == None or Target == '':\r
+                if Target is None or Target == '':\r
                     TrimEdkSourceCode(\r
                         os.path.join(CurrentDir, FileName),\r
                         os.path.join(CurrentDir, FileName)\r
@@ -568,7 +568,7 @@ def TrimEdkSourceCode(Source, Target):
 \r
     NewLines = None\r
     for Re,Repl in gImportCodePatterns:\r
-        if NewLines == None:\r
+        if NewLines is None:\r
             NewLines = Re.sub(Repl, Lines)\r
         else:\r
             NewLines = Re.sub(Repl, NewLines)\r
@@ -672,11 +672,11 @@ def Main():
     \r
     try:\r
         if CommandOptions.FileType == "Vfr":\r
-            if CommandOptions.OutputFile == None:\r
+            if CommandOptions.OutputFile is None:\r
                 CommandOptions.OutputFile = os.path.splitext(InputFile)[0] + '.iii'\r
             TrimPreprocessedVfr(InputFile, CommandOptions.OutputFile)\r
         elif CommandOptions.FileType == "Asl":\r
-            if CommandOptions.OutputFile == None:\r
+            if CommandOptions.OutputFile is None:\r
                 CommandOptions.OutputFile = os.path.splitext(InputFile)[0] + '.iii'\r
             TrimAslFile(InputFile, CommandOptions.OutputFile, CommandOptions.IncludePathFile)\r
         elif CommandOptions.FileType == "EdkSourceCode":\r
@@ -684,13 +684,13 @@ def Main():
         elif CommandOptions.FileType == "VfrOffsetBin":\r
             GenerateVfrBinSec(CommandOptions.ModuleName, CommandOptions.DebugDir, CommandOptions.OutputFile)\r
         else :\r
-            if CommandOptions.OutputFile == None:\r
+            if CommandOptions.OutputFile is None:\r
                 CommandOptions.OutputFile = os.path.splitext(InputFile)[0] + '.iii'\r
             TrimPreprocessedFile(InputFile, CommandOptions.OutputFile, CommandOptions.ConvertHex, CommandOptions.TrimLong)\r
     except FatalError, X:\r
         import platform\r
         import traceback\r
-        if CommandOptions != None and CommandOptions.LogLevel <= EdkLogger.DEBUG_9:\r
+        if CommandOptions is not None and CommandOptions.LogLevel <= EdkLogger.DEBUG_9:\r
             EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc())\r
         return 1\r
     except:\r