BaseTools: Remove equality operator with None
replace "== None" with "is None" and "!= None" with "is not None" Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
committed by
Yonghong Zhu
parent
05a32984ab
commit
4231a8193e
@ -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:
|
||||
|
Reference in New Issue
Block a user