From 4231a8193ec0d52df7e0a101d96c51b1a2b7a996 Mon Sep 17 00:00:00 2001 From: "Carsey, Jaben" Date: Tue, 27 Mar 2018 04:25:43 +0800 Subject: BaseTools: Remove equality operator with None replace "== None" with "is None" and "!= None" with "is not None" Cc: Yonghong Zhu Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey Reviewed-by: Yonghong Zhu --- BaseTools/Source/Python/Trim/Trim.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'BaseTools/Source/Python/Trim/Trim.py') diff --git a/BaseTools/Source/Python/Trim/Trim.py b/BaseTools/Source/Python/Trim/Trim.py index d1e40b025c..d07edbd5d8 100644 --- a/BaseTools/Source/Python/Trim/Trim.py +++ b/BaseTools/Source/Python/Trim/Trim.py @@ -173,7 +173,7 @@ def TrimPreprocessedFile(Source, Target, ConvertHex, TrimLong): elif PreprocessedFile == "" or InjectedFile != PreprocessedFile: continue - if LineIndexOfOriginalFile == None: + if LineIndexOfOriginalFile is None: # # Any non-empty lines must be from original preprocessed file. # And this must be the first one. @@ -193,7 +193,7 @@ def TrimPreprocessedFile(Source, Target, ConvertHex, TrimLong): # convert Decimal number format Line = gDecNumberPattern.sub(r"\1", Line) - if LineNumber != None: + if LineNumber is not None: EdkLogger.verbose("Got line directive: line=%d" % LineNumber) # in case preprocessor removed some lines, like blank or comment lines if LineNumber <= len(NewLines): @@ -216,10 +216,10 @@ def TrimPreprocessedFile(Source, Target, ConvertHex, TrimLong): Brace = 0 for Index in range(len(Lines)): Line = Lines[Index] - if MulPatternFlag == False and gTypedef_MulPattern.search(Line) == None: - if SinglePatternFlag == False and gTypedef_SinglePattern.search(Line) == None: + if MulPatternFlag == False and gTypedef_MulPattern.search(Line) is None: + if SinglePatternFlag == False and gTypedef_SinglePattern.search(Line) is None: # remove "#pragram pack" directive - if gPragmaPattern.search(Line) == None: + if gPragmaPattern.search(Line) is None: NewLines.append(Line) continue elif SinglePatternFlag == False: @@ -282,9 +282,9 @@ def TrimPreprocessedVfr(Source, Target): Lines[Index] = "\n" continue - if FoundTypedef == False and gTypedefPattern.search(Line) == None: + if FoundTypedef == False and gTypedefPattern.search(Line) is None: # keep "#pragram pack" directive - if gPragmaPattern.search(Line) == None: + if gPragmaPattern.search(Line) is None: Lines[Index] = "\n" continue elif FoundTypedef == False: @@ -510,7 +510,7 @@ def TrimEdkSources(Source, Target): for FileName in Files: Dummy, Ext = os.path.splitext(FileName) if Ext.upper() not in ['.C', '.H']: continue - if Target == None or Target == '': + if Target is None or Target == '': TrimEdkSourceCode( os.path.join(CurrentDir, FileName), os.path.join(CurrentDir, FileName) @@ -568,7 +568,7 @@ def TrimEdkSourceCode(Source, Target): NewLines = None for Re,Repl in gImportCodePatterns: - if NewLines == None: + if NewLines is None: NewLines = Re.sub(Repl, Lines) else: NewLines = Re.sub(Repl, NewLines) @@ -672,11 +672,11 @@ def Main(): try: if CommandOptions.FileType == "Vfr": - if CommandOptions.OutputFile == None: + if CommandOptions.OutputFile is None: CommandOptions.OutputFile = os.path.splitext(InputFile)[0] + '.iii' TrimPreprocessedVfr(InputFile, CommandOptions.OutputFile) elif CommandOptions.FileType == "Asl": - if CommandOptions.OutputFile == None: + if CommandOptions.OutputFile is None: CommandOptions.OutputFile = os.path.splitext(InputFile)[0] + '.iii' TrimAslFile(InputFile, CommandOptions.OutputFile, CommandOptions.IncludePathFile) elif CommandOptions.FileType == "EdkSourceCode": @@ -684,13 +684,13 @@ def Main(): elif CommandOptions.FileType == "VfrOffsetBin": GenerateVfrBinSec(CommandOptions.ModuleName, CommandOptions.DebugDir, CommandOptions.OutputFile) else : - if CommandOptions.OutputFile == None: + if CommandOptions.OutputFile is None: CommandOptions.OutputFile = os.path.splitext(InputFile)[0] + '.iii' TrimPreprocessedFile(InputFile, CommandOptions.OutputFile, CommandOptions.ConvertHex, CommandOptions.TrimLong) except FatalError, X: import platform import traceback - if CommandOptions != None and CommandOptions.LogLevel <= EdkLogger.DEBUG_9: + if CommandOptions is not None and CommandOptions.LogLevel <= EdkLogger.DEBUG_9: EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc()) return 1 except: -- cgit v1.2.3