summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/Common
diff options
context:
space:
mode:
authorCarsey, Jaben </o=Intel/ou=Americas01/cn=Workers/cn=Carsey, Jaben>2018-03-27 04:25:43 +0800
committerYonghong Zhu <yonghong.zhu@intel.com>2018-03-30 08:25:13 +0800
commit4231a8193ec0d52df7e0a101d96c51b1a2b7a996 (patch)
tree4fc8e46c9d51a4938e891e6b029781f1b66537ae /BaseTools/Source/Python/Common
parent05a32984ab799a564e2eeb7dff128fe0992910d8 (diff)
downloadedk2-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/Common')
-rw-r--r--BaseTools/Source/Python/Common/DecClassObject.py2
-rw-r--r--BaseTools/Source/Python/Common/Dictionary.py2
-rw-r--r--BaseTools/Source/Python/Common/DscClassObject.py4
-rw-r--r--BaseTools/Source/Python/Common/EdkIIWorkspace.py2
-rw-r--r--BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py30
-rw-r--r--BaseTools/Source/Python/Common/EdkLogger.py18
-rw-r--r--BaseTools/Source/Python/Common/FdfClassObject.py2
-rw-r--r--BaseTools/Source/Python/Common/FdfParserLite.py40
-rw-r--r--BaseTools/Source/Python/Common/InfClassObject.py2
-rw-r--r--BaseTools/Source/Python/Common/Misc.py80
-rw-r--r--BaseTools/Source/Python/Common/Parsing.py4
-rw-r--r--BaseTools/Source/Python/Common/String.py4
-rw-r--r--BaseTools/Source/Python/Common/TargetTxtClassObject.py6
-rw-r--r--BaseTools/Source/Python/Common/ToolDefClassObject.py2
-rw-r--r--BaseTools/Source/Python/Common/VpdInfoFile.py12
15 files changed, 105 insertions, 105 deletions
diff --git a/BaseTools/Source/Python/Common/DecClassObject.py b/BaseTools/Source/Python/Common/DecClassObject.py
index d7c70a7336..835dbd5935 100644
--- a/BaseTools/Source/Python/Common/DecClassObject.py
+++ b/BaseTools/Source/Python/Common/DecClassObject.py
@@ -116,7 +116,7 @@ class Dec(DecObject):
#
# Load Dec file if filename is not None
#
- if Filename != None:
+ if Filename is not None:
self.LoadDecFile(Filename)
#
diff --git a/BaseTools/Source/Python/Common/Dictionary.py b/BaseTools/Source/Python/Common/Dictionary.py
index 1c33fefabf..f653275ff1 100644
--- a/BaseTools/Source/Python/Common/Dictionary.py
+++ b/BaseTools/Source/Python/Common/Dictionary.py
@@ -54,7 +54,7 @@ def ConvertTextFileToDictionary(FileName, Dictionary, CommentCharacter, KeySplit
# @param Dict: The dictionary to be printed
#
def printDict(Dict):
- if Dict != None:
+ if Dict is not None:
KeyList = Dict.keys()
for Key in KeyList:
if Dict[Key] != '':
diff --git a/BaseTools/Source/Python/Common/DscClassObject.py b/BaseTools/Source/Python/Common/DscClassObject.py
index c2fa1c275a..b98dbf5722 100644
--- a/BaseTools/Source/Python/Common/DscClassObject.py
+++ b/BaseTools/Source/Python/Common/DscClassObject.py
@@ -128,7 +128,7 @@ class Dsc(DscObject):
#
# Load Dsc file if filename is not None
#
- if Filename != None:
+ if Filename is not None:
self.LoadDscFile(Filename)
#
@@ -902,7 +902,7 @@ class Dsc(DscObject):
#
def GenSkuInfoList(self, SkuNameList, SkuInfo, VariableName='', VariableGuid='', VariableOffset='', HiiDefaultValue='', VpdOffset='', DefaultValue=''):
SkuNameList = GetSplitValueList(SkuNameList)
- if SkuNameList == None or SkuNameList == [] or SkuNameList == ['']:
+ if SkuNameList is None or SkuNameList == [] or SkuNameList == ['']:
SkuNameList = ['DEFAULT']
SkuInfoList = {}
for Item in SkuNameList:
diff --git a/BaseTools/Source/Python/Common/EdkIIWorkspace.py b/BaseTools/Source/Python/Common/EdkIIWorkspace.py
index f22a545b77..c14b4eb52d 100644
--- a/BaseTools/Source/Python/Common/EdkIIWorkspace.py
+++ b/BaseTools/Source/Python/Common/EdkIIWorkspace.py
@@ -38,7 +38,7 @@ class EdkIIWorkspace:
#
# Check environment valiable 'WORKSPACE'
#
- if os.environ.get('WORKSPACE') == None:
+ if os.environ.get('WORKSPACE') is None:
print 'ERROR: WORKSPACE not defined. Please run EdkSetup from the EDK II install directory.'
return False
diff --git a/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py b/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py
index d6df01d4ce..c0966d5265 100644
--- a/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py
+++ b/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py
@@ -93,7 +93,7 @@ class PcdClassObject(object):
# @retval True The two pcds are the same
#
def __eq__(self, Other):
- return Other != None and self.TokenCName == Other.TokenCName and self.TokenSpaceGuidCName == Other.TokenSpaceGuidCName
+ return Other is not None and self.TokenCName == Other.TokenCName and self.TokenSpaceGuidCName == Other.TokenSpaceGuidCName
## Override __hash__ function
#
@@ -121,7 +121,7 @@ class LibraryClassObject(object):
def __init__(self, Name = None, SupModList = [], Type = None):
self.LibraryClass = Name
self.SupModList = SupModList
- if Type != None:
+ if Type is not None:
self.SupModList = CleanString(Type).split(DataType.TAB_SPACE_SPLIT)
## ModuleBuildClassObject
@@ -864,7 +864,7 @@ class WorkspaceBuild(object):
for Libs in Pb.LibraryClass:
for Type in Libs.SupModList:
Instance = self.FindLibraryClassInstanceOfLibrary(Lib, Arch, Type)
- if Instance == None:
+ if Instance is None:
Instance = RecommendedInstance
Pb.LibraryClasses[(Lib, Type)] = Instance
else:
@@ -872,7 +872,7 @@ class WorkspaceBuild(object):
# For Module
#
Instance = self.FindLibraryClassInstanceOfModule(Lib, Arch, Pb.ModuleType, Inf)
- if Instance == None:
+ if Instance is None:
Instance = RecommendedInstance
Pb.LibraryClasses[(Lib, Pb.ModuleType)] = Instance
@@ -912,7 +912,7 @@ class WorkspaceBuild(object):
if not self.IsModuleDefinedInPlatform(Inf, Arch, InfList):
continue
Module = self.Build[Arch].ModuleDatabase[Inf]
- if Module.LibraryClass == None or Module.LibraryClass == []:
+ if Module.LibraryClass is None or Module.LibraryClass == []:
self.UpdateLibrariesOfModule(Platform, Module, Arch)
for Key in Module.LibraryClasses:
Lib = Module.LibraryClasses[Key]
@@ -969,15 +969,15 @@ class WorkspaceBuild(object):
continue
LibraryClassName = Key[0]
- if LibraryClassName not in LibraryInstance or LibraryInstance[LibraryClassName] == None:
- if LibraryPath == None or LibraryPath == "":
+ if LibraryClassName not in LibraryInstance or LibraryInstance[LibraryClassName] is None:
+ if LibraryPath is None or LibraryPath == "":
LibraryInstance[LibraryClassName] = None
continue
LibraryModule = ModuleDatabase[LibraryPath]
LibraryInstance[LibraryClassName] = LibraryModule
LibraryConsumerList.append(LibraryModule)
EdkLogger.verbose("\t" + LibraryClassName + " : " + str(LibraryModule))
- elif LibraryPath == None or LibraryPath == "":
+ elif LibraryPath is None or LibraryPath == "":
continue
else:
LibraryModule = LibraryInstance[LibraryClassName]
@@ -1002,7 +1002,7 @@ class WorkspaceBuild(object):
Q = []
for LibraryClassName in LibraryInstance:
M = LibraryInstance[LibraryClassName]
- if M == None:
+ if M is None:
EdkLogger.error("AutoGen", AUTOGEN_ERROR,
"Library instance for library class [%s] is not found" % LibraryClassName,
ExtraData="\t%s [%s]" % (str(Module), Arch))
@@ -1011,7 +1011,7 @@ class WorkspaceBuild(object):
# check if there're duplicate library classes
#
for Lc in M.LibraryClass:
- if Lc.SupModList != None and ModuleType not in Lc.SupModList:
+ if Lc.SupModList is not None and ModuleType not in Lc.SupModList:
EdkLogger.error("AutoGen", AUTOGEN_ERROR,
"Module type [%s] is not supported by library instance [%s]" % (ModuleType, str(M)),
ExtraData="\t%s" % str(Module))
@@ -1380,7 +1380,7 @@ class WorkspaceBuild(object):
if (Name, Guid) in Pcds:
OwnerPlatform = Dsc
Pcd = Pcds[(Name, Guid)]
- if Pcd.Type != '' and Pcd.Type != None:
+ if Pcd.Type != '' and Pcd.Type is not None:
NewType = Pcd.Type
if NewType in DataType.PCD_DYNAMIC_TYPE_LIST:
NewType = DataType.TAB_PCDS_DYNAMIC
@@ -1396,13 +1396,13 @@ class WorkspaceBuild(object):
EdkLogger.error("AutoGen", PARSER_ERROR, ErrorMsg)
- if Pcd.DatumType != '' and Pcd.DatumType != None:
+ if Pcd.DatumType != '' and Pcd.DatumType is not None:
DatumType = Pcd.DatumType
- if Pcd.TokenValue != '' and Pcd.TokenValue != None:
+ if Pcd.TokenValue != '' and Pcd.TokenValue is not None:
Token = Pcd.TokenValue
- if Pcd.DefaultValue != '' and Pcd.DefaultValue != None:
+ if Pcd.DefaultValue != '' and Pcd.DefaultValue is not None:
Value = Pcd.DefaultValue
- if Pcd.MaxDatumSize != '' and Pcd.MaxDatumSize != None:
+ if Pcd.MaxDatumSize != '' and Pcd.MaxDatumSize is not None:
MaxDatumSize = Pcd.MaxDatumSize
SkuInfoList = Pcd.SkuInfoList
diff --git a/BaseTools/Source/Python/Common/EdkLogger.py b/BaseTools/Source/Python/Common/EdkLogger.py
index ac1c8edc4f..3f462df49a 100644
--- a/BaseTools/Source/Python/Common/EdkLogger.py
+++ b/BaseTools/Source/Python/Common/EdkLogger.py
@@ -89,7 +89,7 @@ def debug(Level, Message, ExtraData=None):
"msg" : Message,
}
- if ExtraData != None:
+ if ExtraData is not None:
LogText = _DebugMessageTemplate % TemplateDict + "\n %s" % ExtraData
else:
LogText = _DebugMessageTemplate % TemplateDict
@@ -119,10 +119,10 @@ def warn(ToolName, Message, File=None, Line=None, ExtraData=None):
return
# if no tool name given, use caller's source file name as tool name
- if ToolName == None or ToolName == "":
+ if ToolName is None or ToolName == "":
ToolName = os.path.basename(traceback.extract_stack()[-2][0])
- if Line == None:
+ if Line is None:
Line = "..."
else:
Line = "%d" % Line
@@ -134,12 +134,12 @@ def warn(ToolName, Message, File=None, Line=None, ExtraData=None):
"msg" : Message,
}
- if File != None:
+ if File is not None:
LogText = _WarningMessageTemplate % TemplateDict
else:
LogText = _WarningMessageTemplateWithoutFile % TemplateDict
- if ExtraData != None:
+ if ExtraData is not None:
LogText += "\n %s" % ExtraData
_InfoLogger.log(WARN, LogText)
@@ -168,18 +168,18 @@ info = _InfoLogger.info
# it's True. This is the default behavior.
#
def error(ToolName, ErrorCode, Message=None, File=None, Line=None, ExtraData=None, RaiseError=IsRaiseError):
- if Line == None:
+ if Line is None:
Line = "..."
else:
Line = "%d" % Line
- if Message == None:
+ if Message is None:
if ErrorCode in gErrorMessage:
Message = gErrorMessage[ErrorCode]
else:
Message = gErrorMessage[UNKNOWN_ERROR]
- if ExtraData == None:
+ if ExtraData is None:
ExtraData = ""
TemplateDict = {
@@ -191,7 +191,7 @@ def error(ToolName, ErrorCode, Message=None, File=None, Line=None, ExtraData=Non
"extra" : ExtraData
}
- if File != None:
+ if File is not None:
LogText = _ErrorMessageTemplate % TemplateDict
else:
LogText = _ErrorMessageTemplateWithoutFile % TemplateDict
diff --git a/BaseTools/Source/Python/Common/FdfClassObject.py b/BaseTools/Source/Python/Common/FdfClassObject.py
index 3e7d44954c..3d37800d9a 100644
--- a/BaseTools/Source/Python/Common/FdfClassObject.py
+++ b/BaseTools/Source/Python/Common/FdfClassObject.py
@@ -51,7 +51,7 @@ class Fdf(FdfObject):
#
# Load Fdf file if filename is not None
#
- if Filename != None:
+ if Filename is not None:
self.LoadFdfFile(Filename)
#
diff --git a/BaseTools/Source/Python/Common/FdfParserLite.py b/BaseTools/Source/Python/Common/FdfParserLite.py
index b7b5e21a9e..66815d3e17 100644
--- a/BaseTools/Source/Python/Common/FdfParserLite.py
+++ b/BaseTools/Source/Python/Common/FdfParserLite.py
@@ -356,7 +356,7 @@ class FdfParser(object):
if Profile.FileName == File and Profile.MacroName == Name and Profile.DefinedAtLine <= Line:
Value = Profile.MacroValue
- if Value != None:
+ if Value is not None:
Str = Str.replace('$(' + Name + ')', Value)
MacroEnd = MacroStart + len(Value)
@@ -679,8 +679,8 @@ class FdfParser(object):
FileLineTuple = GetRealFileLine(self.FileName, Line)
if Name in InputMacroDict:
MacroValue = InputMacroDict[Name]
- if Op == None:
- if Value == 'Bool' and MacroValue == None or MacroValue.upper() == 'FALSE':
+ if Op is None:
+ if Value == 'Bool' and MacroValue is None or MacroValue.upper() == 'FALSE':
return False
return True
elif Op == '!=':
@@ -694,7 +694,7 @@ class FdfParser(object):
else:
return False
else:
- if (self.__IsHex(Value) or Value.isdigit()) and (self.__IsHex(MacroValue) or (MacroValue != None and MacroValue.isdigit())):
+ if (self.__IsHex(Value) or Value.isdigit()) and (self.__IsHex(MacroValue) or (MacroValue is not None and MacroValue.isdigit())):
InputVal = long(Value, 0)
MacroVal = long(MacroValue, 0)
if Op == '>':
@@ -724,8 +724,8 @@ class FdfParser(object):
for Profile in AllMacroList:
if Profile.FileName == FileLineTuple[0] and Profile.MacroName == Name and Profile.DefinedAtLine <= FileLineTuple[1]:
- if Op == None:
- if Value == 'Bool' and Profile.MacroValue == None or Profile.MacroValue.upper() == 'FALSE':
+ if Op is None:
+ if Value == 'Bool' and Profile.MacroValue is None or Profile.MacroValue.upper() == 'FALSE':
return False
return True
elif Op == '!=':
@@ -739,7 +739,7 @@ class FdfParser(object):
else:
return False
else:
- if (self.__IsHex(Value) or Value.isdigit()) and (self.__IsHex(Profile.MacroValue) or (Profile.MacroValue != None and Profile.MacroValue.isdigit())):
+ if (self.__IsHex(Value) or Value.isdigit()) and (self.__IsHex(Profile.MacroValue) or (Profile.MacroValue is not None and Profile.MacroValue.isdigit())):
InputVal = long(Value, 0)
MacroVal = long(Profile.MacroValue, 0)
if Op == '>':
@@ -935,7 +935,7 @@ class FdfParser(object):
if not self.__GetNextToken():
return False
- if gGuidPattern.match(self.__Token) != None:
+ if gGuidPattern.match(self.__Token) is not None:
return True
else:
self.__UndoToken()
@@ -1454,7 +1454,7 @@ class FdfParser(object):
pass
for Item in Obj.BlockSizeList:
- if Item[0] == None or Item[1] == None:
+ if Item[0] is None or Item[1] is None:
raise Warning("expected block statement for Fd Section", self.FileName, self.CurrentLineNumber)
return True
@@ -2423,7 +2423,7 @@ class FdfParser(object):
FvImageSectionObj = CommonDataClass.FdfClass.FvImageSectionClassObject()
FvImageSectionObj.Alignment = AlignValue
- if FvObj != None:
+ if FvObj is not None:
FvImageSectionObj.Fv = FvObj
FvImageSectionObj.FvName = None
else:
@@ -2942,7 +2942,7 @@ class FdfParser(object):
Rule.CheckSum = CheckSum
Rule.Fixed = Fixed
Rule.KeyStringList = KeyStringList
- if KeepReloc != None:
+ if KeepReloc is not None:
Rule.KeepReloc = KeepReloc
while True:
@@ -2969,7 +2969,7 @@ class FdfParser(object):
Rule.Fixed = Fixed
Rule.FileExtension = Ext
Rule.KeyStringList = KeyStringList
- if KeepReloc != None:
+ if KeepReloc is not None:
Rule.KeepReloc = KeepReloc
return Rule
@@ -3012,7 +3012,7 @@ class FdfParser(object):
Rule.Fixed = Fixed
Rule.FileName = self.__Token
Rule.KeyStringList = KeyStringList
- if KeepReloc != None:
+ if KeepReloc is not None:
Rule.KeepReloc = KeepReloc
return Rule
@@ -3149,7 +3149,7 @@ class FdfParser(object):
EfiSectionObj.KeepReloc = False
else:
EfiSectionObj.KeepReloc = True
- if Obj.KeepReloc != None and Obj.KeepReloc != EfiSectionObj.KeepReloc:
+ if Obj.KeepReloc is not None and Obj.KeepReloc != EfiSectionObj.KeepReloc:
raise Warning("Section type %s has reloc strip flag conflict with Rule At Line %d" % (EfiSectionObj.SectionType, self.CurrentLineNumber), self.FileName, self.CurrentLineNumber)
else:
raise Warning("Section type %s could not have reloc strip flag At Line %d" % (EfiSectionObj.SectionType, self.CurrentLineNumber), self.FileName, self.CurrentLineNumber)
@@ -3471,7 +3471,7 @@ class FdfParser(object):
raise Warning("expected Component version At Line ", self.FileName, self.CurrentLineNumber)
Pattern = re.compile('-$|[0-9]{0,1}[0-9]{1}\.[0-9]{0,1}[0-9]{1}')
- if Pattern.match(self.__Token) == None:
+ if Pattern.match(self.__Token) is None:
raise Warning("Unknown version format At line ", self.FileName, self.CurrentLineNumber)
CompStatementObj.CompVer = self.__Token
@@ -3544,7 +3544,7 @@ class FdfParser(object):
for elementRegion in FdObj.RegionList:
if elementRegion.RegionType == 'FV':
for elementRegionData in elementRegion.RegionDataList:
- if elementRegionData != None and elementRegionData.upper() not in FvList:
+ if elementRegionData is not None and elementRegionData.upper() not in FvList:
FvList.append(elementRegionData.upper())
return FvList
@@ -3561,9 +3561,9 @@ class FdfParser(object):
for FfsObj in FvObj.FfsList:
if isinstance(FfsObj, FfsFileStatement.FileStatement):
- if FfsObj.FvName != None and FfsObj.FvName.upper() not in RefFvList:
+ if FfsObj.FvName is not None and FfsObj.FvName.upper() not in RefFvList:
RefFvList.append(FfsObj.FvName.upper())
- elif FfsObj.FdName != None and FfsObj.FdName.upper() not in RefFdList:
+ elif FfsObj.FdName is not None and FfsObj.FdName.upper() not in RefFdList:
RefFdList.append(FfsObj.FdName.upper())
else:
self.__GetReferencedFdFvTupleFromSection(FfsObj, RefFdList, RefFvList)
@@ -3584,9 +3584,9 @@ class FdfParser(object):
while SectionStack != []:
SectionObj = SectionStack.pop()
if isinstance(SectionObj, FvImageSection.FvImageSection):
- if SectionObj.FvName != None and SectionObj.FvName.upper() not in FvList:
+ if SectionObj.FvName is not None and SectionObj.FvName.upper() not in FvList:
FvList.append(SectionObj.FvName.upper())
- if SectionObj.Fv != None and SectionObj.Fv.UiFvName != None and SectionObj.Fv.UiFvName.upper() not in FvList:
+ if SectionObj.Fv is not None and SectionObj.Fv.UiFvName is not None and SectionObj.Fv.UiFvName.upper() not in FvList:
FvList.append(SectionObj.Fv.UiFvName.upper())
self.__GetReferencedFdFvTuple(SectionObj.Fv, FdList, FvList)
diff --git a/BaseTools/Source/Python/Common/InfClassObject.py b/BaseTools/Source/Python/Common/InfClassObject.py
index f24e4e41a0..ba43eb5484 100644
--- a/BaseTools/Source/Python/Common/InfClassObject.py
+++ b/BaseTools/Source/Python/Common/InfClassObject.py
@@ -199,7 +199,7 @@ class Inf(InfObject):
#
# Load Inf file if filename is not None
#
- if Filename != None:
+ if Filename is not None:
self.LoadInfFile(Filename)
#
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 8f479ace4c..4c33e645fa 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -85,7 +85,7 @@ def _parseForXcode(lines, efifilepath, varnames):
for varname in varnames:
if varname in line:
m = re.match('^([\da-fA-FxX]+)([\s\S]*)([_]*%s)$' % varname, line)
- if m != None:
+ if m is not None:
ret.append((varname, m.group(1)))
return ret
@@ -110,27 +110,27 @@ def _parseForGCC(lines, efifilepath, varnames):
# status handler
if status == 3:
m = re.match('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$', line)
- if m != None:
+ if m is not None:
sections.append(m.groups(0))
for varname in varnames:
Str = ''
m = re.match("^.data.(%s)" % varname, line)
- if m != None:
+ if m is not None:
m = re.match(".data.(%s)$" % varname, line)
- if m != None:
+ if m is not None:
Str = lines[index + 1]
else:
Str = line[len(".data.%s" % varname):]
if Str:
m = re.match('^([\da-fA-Fx]+) +([\da-fA-Fx]+)', Str.strip())
- if m != None:
+ if m is not None:
varoffset.append((varname, int(m.groups(0)[0], 16) , int(sections[-1][1], 16), sections[-1][0]))
if not varoffset:
return []
# get section information from efi file
efisecs = PeImageClass(efifilepath).SectionHeaderList
- if efisecs == None or len(efisecs) == 0:
+ if efisecs is None or len(efisecs) == 0:
return []
#redirection
redirection = 0
@@ -166,19 +166,19 @@ def _parseGeneral(lines, efifilepath, varnames):
continue
if status == 1 and len(line) != 0:
m = secRe.match(line)
- assert m != None, "Fail to parse the section in map file , line is %s" % line
+ assert m is not None, "Fail to parse the section in map file , line is %s" % line
sec_no, sec_start, sec_length, sec_name, sec_class = m.groups(0)
secs.append([int(sec_no, 16), int(sec_start, 16), int(sec_length, 16), sec_name, sec_class])
if status == 2 and len(line) != 0:
for varname in varnames:
m = symRe.match(line)
- assert m != None, "Fail to parse the symbol in map file, line is %s" % line
+ assert m is not None, "Fail to parse the symbol in map file, line is %s" % line
sec_no, sym_offset, sym_name, vir_addr = m.groups(0)
sec_no = int(sec_no, 16)
sym_offset = int(sym_offset, 16)
vir_addr = int(vir_addr, 16)
m2 = re.match('^[_]*(%s)' % varname, sym_name)
- if m2 != None:
+ if m2 is not None:
# fond a binary pcd entry in map file
for sec in secs:
if sec[0] == sec_no and (sym_offset >= sec[1] and sym_offset < sec[1] + sec[2]):
@@ -188,7 +188,7 @@ def _parseGeneral(lines, efifilepath, varnames):
# get section information from efi file
efisecs = PeImageClass(efifilepath).SectionHeaderList
- if efisecs == None or len(efisecs) == 0:
+ if efisecs is None or len(efisecs) == 0:
return []
ret = []
@@ -423,7 +423,7 @@ def GuidStructureStringToGuidValueName(GuidValue):
# @param Directory The directory name
#
def CreateDirectory(Directory):
- if Directory == None or Directory.strip() == "":
+ if Directory is None or Directory.strip() == "":
return True
try:
if not os.access(Directory, os.F_OK):
@@ -437,7 +437,7 @@ def CreateDirectory(Directory):
# @param Directory The directory name
#
def RemoveDirectory(Directory, Recursively=False):
- if Directory == None or Directory.strip() == "" or not os.path.exists(Directory):
+ if Directory is None or Directory.strip() == "" or not os.path.exists(Directory):
return
if Recursively:
CurrentDirectory = os.getcwd()
@@ -540,7 +540,7 @@ def DataDump(Data, File):
except:
EdkLogger.error("", FILE_OPEN_FAILURE, ExtraData=File, RaiseError=False)
finally:
- if Fd != None:
+ if Fd is not None:
Fd.close()
## Restore a Python object from a file
@@ -560,7 +560,7 @@ def DataRestore(File):
EdkLogger.verbose("Failed to load [%s]\n\t%s" % (File, str(e)))
Data = None
finally:
- if Fd != None:
+ if Fd is not None:
Fd.close()
return Data
@@ -668,7 +668,7 @@ def GetFiles(Root, SkipList=None, FullPath=True):
# @retval False if file doesn't exists
#
def ValidFile(File, Ext=None):
- if Ext != None:
+ if Ext is not None:
Dummy, FileExt = os.path.splitext(File)
if FileExt.lower() != Ext.lower():
return False
@@ -715,13 +715,13 @@ def RealPath2(File, Dir='', OverrideDir=''):
#
def ValidFile2(AllFiles, File, Ext=None, Workspace='', EfiSource='', EdkSource='', Dir='.', OverrideDir=''):
NewFile = File
- if Ext != None:
+ if Ext is not None:
Dummy, FileExt = os.path.splitext(File)
if FileExt.lower() != Ext.lower():
return False, File
# Replace the Edk macros
- if OverrideDir != '' and OverrideDir != None:
+ if OverrideDir != '' and OverrideDir is not None:
if OverrideDir.find('$(EFI_SOURCE)') > -1:
OverrideDir = OverrideDir.replace('$(EFI_SOURCE)', EfiSource)
if OverrideDir.find('$(EDK_SOURCE)') > -1:
@@ -737,19 +737,19 @@ def ValidFile2(AllFiles, File, Ext=None, Workspace='', EfiSource='', EdkSource='
NewFile = File.replace('$(EFI_SOURCE)', EfiSource)
NewFile = NewFile.replace('$(EDK_SOURCE)', EdkSource)
NewFile = AllFiles[os.path.normpath(NewFile)]
- if NewFile != None:
+ if NewFile is not None:
return True, NewFile
# Second check the path with override value
- if OverrideDir != '' and OverrideDir != None:
+ if OverrideDir != '' and OverrideDir is not None:
NewFile = AllFiles[os.path.normpath(os.path.join(OverrideDir, File))]
- if NewFile != None:
+ if NewFile is not None:
return True, NewFile
# Last check the path with normal definitions
File = os.path.join(Dir, File)
NewFile = AllFiles[os.path.normpath(File)]
- if NewFile != None:
+ if NewFile is not None:
return True, NewFile
return False, File
@@ -759,7 +759,7 @@ def ValidFile2(AllFiles, File, Ext=None, Workspace='', EfiSource='', EdkSource='
#
def ValidFile3(AllFiles, File, Workspace='', EfiSource='', EdkSource='', Dir='.', OverrideDir=''):
# Replace the Edk macros
- if OverrideDir != '' and OverrideDir != None:
+ if OverrideDir != '' and OverrideDir is not None:
if OverrideDir.find('$(EFI_SOURCE)') > -1:
OverrideDir = OverrideDir.replace('$(EFI_SOURCE)', EfiSource)
if OverrideDir.find('$(EDK_SOURCE)') > -1:
@@ -781,23 +781,23 @@ def ValidFile3(AllFiles, File, Workspace='', EfiSource='', EdkSource='', Dir='.'
File = File.replace('$(EFI_SOURCE)', EfiSource)
File = File.replace('$(EDK_SOURCE)', EdkSource)
NewFile = AllFiles[os.path.normpath(File)]
- if NewFile != None:
+ if NewFile is not None:
NewRelaPath = os.path.dirname(NewFile)
File = os.path.basename(NewFile)
#NewRelaPath = NewFile[:len(NewFile) - len(File.replace("..\\", '').replace("../", '')) - 1]
break
# Second check the path with override value
- if OverrideDir != '' and OverrideDir != None:
+ if OverrideDir != '' and OverrideDir is not None:
NewFile = AllFiles[os.path.normpath(os.path.join(OverrideDir, File))]
- if NewFile != None:
+ if NewFile is not None:
#NewRelaPath = os.path.dirname(NewFile)
NewRelaPath = NewFile[:len(NewFile) - len(File.replace("..\\", '').replace("../", '')) - 1]
break
# Last check the path with normal definitions
NewFile = AllFiles[os.path.normpath(os.path.join(Dir, File))]
- if NewFile != None:
+ if NewFile is not None:
break
# No file found
@@ -1062,7 +1062,7 @@ class Progressor:
self.CodaMessage = CloseMessage
self.ProgressChar = ProgressChar
self.Interval = Interval
- if Progressor._StopFlag == None:
+ if Progressor._StopFlag is None:
Progressor._StopFlag = threading.Event()
## Start to print progress charater
@@ -1070,10 +1070,10 @@ class Progressor:
# @param OpenMessage The string printed before progress charaters
#
def Start(self, OpenMessage=None):
- if OpenMessage != None:
+ if OpenMessage is not None:
self.PromptMessage = OpenMessage
Progressor._StopFlag.clear()
- if Progressor._ProgressThread == None:
+ if Progressor._ProgressThread is None:
Progressor._ProgressThread = threading.Thread(target=self._ProgressThreadEntry)
Progressor._ProgressThread.setDaemon(False)
Progressor._ProgressThread.start()
@@ -1084,7 +1084,7 @@ class Progressor:
#
def Stop(self, CloseMessage=None):
OriginalCodaMessage = self.CodaMessage
- if CloseMessage != None:
+ if CloseMessage is not None:
self.CodaMessage = CloseMessage
self.Abort()
self.CodaMessage = OriginalCodaMessage
@@ -1107,9 +1107,9 @@ class Progressor:
## Abort the progress display
@staticmethod
def Abort():
- if Progressor._StopFlag != None:
+ if Progressor._StopFlag is not None:
Progressor._StopFlag.set()
- if Progressor._ProgressThread != None:
+ if Progressor._ProgressThread is not None:
Progressor._ProgressThread.join()
Progressor._ProgressThread = None
@@ -1228,7 +1228,7 @@ class sdict(IterableUserDict):
return key, value
def update(self, dict=None, **kwargs):
- if dict != None:
+ if dict is not None:
for k, v in dict.items():
self[k] = v
if len(kwargs):
@@ -1301,7 +1301,7 @@ class tdict:
if self._Level_ > 1:
RestKeys = [self._Wildcard for i in range(0, self._Level_ - 1)]
- if FirstKey == None or str(FirstKey).upper() in self._ValidWildcardList:
+ if FirstKey is None or str(FirstKey).upper() in self._ValidWildcardList:
FirstKey = self._Wildcard
if self._Single_:
@@ -1316,24 +1316,24 @@ class tdict:
if FirstKey == self._Wildcard:
if FirstKey in self.data:
Value = self.data[FirstKey][RestKeys]
- if Value == None:
+ if Value is None:
for Key in self.data:
Value = self.data[Key][RestKeys]
- if Value != None: break
+ if Value is not None: break
else:
if FirstKey in self.data:
Value = self.data[FirstKey][RestKeys]
- if Value == None and self._Wildcard in self.data:
+ if Value is None and self._Wildcard in self.data:
#print "Value=None"
Value = self.data[self._Wildcard][RestKeys]
else:
if FirstKey == self._Wildcard:
if FirstKey in self.data:
Value = self.data[FirstKey]
- if Value == None:
+ if Value is None:
for Key in self.data:
Value = self.data[Key]
- if Value != None: break
+ if Value is not None: break
else:
if FirstKey in self.data:
Value = self.data[FirstKey]
@@ -2066,7 +2066,7 @@ class PathClass(object):
return hash(self.Path)
def _GetFileKey(self):
- if self._Key == None:
+ if self._Key is None:
self._Key = self.Path.upper() # + self.ToolChainFamily + self.TagName + self.ToolCode + self.Target
return self._Key
diff --git a/BaseTools/Source/Python/Common/Parsing.py b/BaseTools/Source/Python/Common/Parsing.py
index 584fc7f3c3..d199d1e40d 100644
--- a/BaseTools/Source/Python/Common/Parsing.py
+++ b/BaseTools/Source/Python/Common/Parsing.py
@@ -299,7 +299,7 @@ def GetLibraryClassOfInf(Item, ContainerFile, WorkspaceDir, LineNo = -1):
#
def CheckPcdTokenInfo(TokenInfoString, Section, File, LineNo = -1):
Format = '<TokenSpaceGuidCName>.<PcdCName>'
- if TokenInfoString != '' and TokenInfoString != None:
+ if TokenInfoString != '' and TokenInfoString is not None:
TokenInfoList = GetSplitValueList(TokenInfoString, TAB_SPLIT)
if len(TokenInfoList) == 2:
return True
@@ -550,7 +550,7 @@ def GetComponents(Lines, Key, KeyValues, CommentCharacter):
LineList = Lines.split('\n')
for Line in LineList:
Line = CleanString(Line, CommentCharacter)
- if Line == None or Line == '':
+ if Line is None or Line == '':
continue
if findBlock == False:
diff --git a/BaseTools/Source/Python/Common/String.py b/BaseTools/Source/Python/Common/String.py
index 696be4c1f0..5dc5b85dc5 100644
--- a/BaseTools/Source/Python/Common/String.py
+++ b/BaseTools/Source/Python/Common/String.py
@@ -634,7 +634,7 @@ def PreCheck(FileName, FileContent, SupSectionTag):
# @retval True The file type is correct
#
def CheckFileType(CheckFilename, ExtName, ContainerFilename, SectionName, Line, LineNo= -1):
- if CheckFilename != '' and CheckFilename != None:
+ if CheckFilename != '' and CheckFilename is not None:
(Root, Ext) = os.path.splitext(CheckFilename)
if Ext.upper() != ExtName.upper():
ContainerFile = open(ContainerFilename, 'r').read()
@@ -662,7 +662,7 @@ def CheckFileType(CheckFilename, ExtName, ContainerFilename, SectionName, Line,
#
def CheckFileExist(WorkspaceDir, CheckFilename, ContainerFilename, SectionName, Line, LineNo= -1):
CheckFile = ''
- if CheckFilename != '' and CheckFilename != None:
+ if CheckFilename != '' and CheckFilename is not None:
CheckFile = WorkspaceFile(WorkspaceDir, CheckFilename)
if not os.path.isfile(CheckFile):
ContainerFile = open(ContainerFilename, 'r').read()
diff --git a/BaseTools/Source/Python/Common/TargetTxtClassObject.py b/BaseTools/Source/Python/Common/TargetTxtClassObject.py
index 387e515230..0ba7725dd5 100644
--- a/BaseTools/Source/Python/Common/TargetTxtClassObject.py
+++ b/BaseTools/Source/Python/Common/TargetTxtClassObject.py
@@ -45,7 +45,7 @@ class TargetTxtClassObject(object):
DataType.TAB_TAT_DEFINES_BUILD_RULE_CONF : '',
}
self.ConfDirectoryPath = ""
- if Filename != None:
+ if Filename is not None:
self.LoadTargetTxtFile(Filename)
## LoadTargetTxtFile
@@ -83,7 +83,7 @@ class TargetTxtClassObject(object):
self.ConfDirectoryPath = os.path.dirname(FileName)
except:
EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=FileName)
- if F != None:
+ if F is not None:
F.close()
for Line in F:
@@ -144,7 +144,7 @@ class TargetTxtClassObject(object):
# @param Dict: The dictionary to be printed
#
def printDict(Dict):
- if Dict != None:
+ if Dict is not None:
KeyList = Dict.keys()
for Key in KeyList:
if Dict[Key] != '':
diff --git a/BaseTools/Source/Python/Common/ToolDefClassObject.py b/BaseTools/Source/Python/Common/ToolDefClassObject.py
index dc90b4783f..1ab848f1ec 100644
--- a/BaseTools/Source/Python/Common/ToolDefClassObject.py
+++ b/BaseTools/Source/Python/Common/ToolDefClassObject.py
@@ -53,7 +53,7 @@ class ToolDefClassObject(object):
for Env in os.environ:
self.MacroDictionary["ENV(%s)" % Env] = os.environ[Env]
- if FileName != None:
+ if FileName is not None:
self.LoadToolDefFile(FileName)
## LoadToolDefFile
diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Source/Python/Common/VpdInfoFile.py
index 716155e96d..b1baf06b9c 100644
--- a/BaseTools/Source/Python/Common/VpdInfoFile.py
+++ b/BaseTools/Source/Python/Common/VpdInfoFile.py
@@ -89,7 +89,7 @@ class VpdInfoFile:
# @param offset integer value for VPD's offset in specific SKU.
#
def Add(self, Vpd, skuname,Offset):
- if (Vpd == None):
+ if (Vpd is None):
EdkLogger.error("VpdInfoFile", BuildToolError.ATTRIBUTE_UNKNOWN_ERROR, "Invalid VPD PCD entry.")
if not (Offset >= 0 or Offset == "*"):
@@ -100,7 +100,7 @@ class VpdInfoFile:
EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID,
"Invalid max datum size for VPD PCD %s.%s" % (Vpd.TokenSpaceGuidCName, Vpd.TokenCName))
elif Vpd.DatumType in ["BOOLEAN", "UINT8", "UINT16", "UINT32", "UINT64"]:
- if Vpd.MaxDatumSize == None or Vpd.MaxDatumSize == "":
+ if Vpd.MaxDatumSize is None or Vpd.MaxDatumSize == "":
Vpd.MaxDatumSize = VpdInfoFile._MAX_SIZE_TYPE[Vpd.DatumType]
else:
if Vpd.MaxDatumSize <= 0:
@@ -122,7 +122,7 @@ class VpdInfoFile:
# If
# @param FilePath The given file path which would hold VPD information
def Write(self, FilePath):
- if not (FilePath != None or len(FilePath) != 0):
+ if not (FilePath is not None or len(FilePath) != 0):
EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID,
"Invalid parameter FilePath: %s." % FilePath)
@@ -227,8 +227,8 @@ class VpdInfoFile:
# @param VpdFileName The string path name for VPD information guid.txt
#
def CallExtenalBPDGTool(ToolPath, VpdFileName):
- assert ToolPath != None, "Invalid parameter ToolPath"
- assert VpdFileName != None and os.path.exists(VpdFileName), "Invalid parameter VpdFileName"
+ assert ToolPath is not None, "Invalid parameter ToolPath"
+ assert VpdFileName is not None and os.path.exists(VpdFileName), "Invalid parameter VpdFileName"
OutputDir = os.path.dirname(VpdFileName)
FileName = os.path.basename(VpdFileName)
@@ -250,7 +250,7 @@ def CallExtenalBPDGTool(ToolPath, VpdFileName):
EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, ExtraData="%s" % (str(X)))
(out, error) = PopenObject.communicate()
print out
- while PopenObject.returncode == None :
+ while PopenObject.returncode is None :
PopenObject.wait()
if PopenObject.returncode != 0: