diff options
author | Carsey, Jaben </o=Intel/ou=Americas01/cn=Workers/cn=Carsey, Jaben> | 2018-03-27 04:25:43 +0800 |
---|---|---|
committer | Yonghong Zhu <yonghong.zhu@intel.com> | 2018-03-30 08:25:13 +0800 |
commit | 4231a8193ec0d52df7e0a101d96c51b1a2b7a996 (patch) | |
tree | 4fc8e46c9d51a4938e891e6b029781f1b66537ae /BaseTools/Source/Python/Trim/Trim.py | |
parent | 05a32984ab799a564e2eeb7dff128fe0992910d8 (diff) | |
download | edk2-4231a8193ec0d52df7e0a101d96c51b1a2b7a996.tar.gz edk2-4231a8193ec0d52df7e0a101d96c51b1a2b7a996.tar.bz2 edk2-4231a8193ec0d52df7e0a101d96c51b1a2b7a996.zip |
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>
Diffstat (limited to 'BaseTools/Source/Python/Trim/Trim.py')
-rw-r--r-- | BaseTools/Source/Python/Trim/Trim.py | 26 |
1 files changed, 13 insertions, 13 deletions
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:
|