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:
Carsey, Jaben
2018-03-27 04:25:43 +08:00
committed by Yonghong Zhu
parent 05a32984ab
commit 4231a8193e
131 changed files with 1142 additions and 1142 deletions

View File

@@ -271,7 +271,7 @@ class InfBinariesObject(InfSectionCommonDef):
#
pass
if InfBianryVerItemObj != None:
if InfBianryVerItemObj is not None:
if self.Binaries.has_key((InfBianryVerItemObj)):
BinariesList = self.Binaries[InfBianryVerItemObj]
BinariesList.append((InfBianryVerItemObj, VerComment))
@@ -521,7 +521,7 @@ class InfBinariesObject(InfSectionCommonDef):
# #
# pass
if InfBianryCommonItemObj != None:
if InfBianryCommonItemObj is not None:
if self.Binaries.has_key((InfBianryCommonItemObj)):
BinariesList = self.Binaries[InfBianryCommonItemObj]
BinariesList.append((InfBianryCommonItemObj, ItemComment))
@@ -538,11 +538,11 @@ class InfBinariesObject(InfSectionCommonDef):
#
# Validate Arch
#
if (ArchItem == '' or ArchItem == None):
if (ArchItem == '' or ArchItem is None):
ArchItem = 'COMMON'
__SupArchList.append(ArchItem)
if UiInf != None:
if UiInf is not None:
if len(UiInf) > 0:
#
# Check UI
@@ -672,7 +672,7 @@ class InfBinariesObject(InfSectionCommonDef):
# #
# pass
if InfBianryUiItemObj != None:
if InfBianryUiItemObj is not None:
if self.Binaries.has_key((InfBianryUiItemObj)):
BinariesList = self.Binaries[InfBianryUiItemObj]
BinariesList.append((InfBianryUiItemObj, UiComment))
@@ -681,7 +681,7 @@ class InfBinariesObject(InfSectionCommonDef):
BinariesList = []
BinariesList.append((InfBianryUiItemObj, UiComment))
self.Binaries[InfBianryUiItemObj] = BinariesList
if Ver != None and len(Ver) > 0:
if Ver is not None and len(Ver) > 0:
self.CheckVer(Ver, __SupArchList)
if CommonBinary and len(CommonBinary) > 0:
self.ParseCommonBinary(CommonBinary, __SupArchList)

View File

@@ -62,7 +62,7 @@ class InfDefSectionOptionRomInfo():
#
# Value has been set before.
#
if self.PciVendorId != None:
if self.PciVendorId is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_PCI_VENDOR_ID),
LineInfo=self.CurrentLine)
return False
@@ -86,7 +86,7 @@ class InfDefSectionOptionRomInfo():
#
# Value has been set before.
#
if self.PciDeviceId != None:
if self.PciDeviceId is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_PCI_DEVICE_ID),
LineInfo=self.CurrentLine)
return False
@@ -110,7 +110,7 @@ class InfDefSectionOptionRomInfo():
#
# Value has been set before.
#
if self.PciClassCode != None:
if self.PciClassCode is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_PCI_CLASS_CODE),
LineInfo=self.CurrentLine)
return False
@@ -135,7 +135,7 @@ class InfDefSectionOptionRomInfo():
#
# Value has been set before.
#
if self.PciRevision != None:
if self.PciRevision is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_PCI_REVISION),
LineInfo=self.CurrentLine)
return False
@@ -159,7 +159,7 @@ class InfDefSectionOptionRomInfo():
#
# Value has been set before.
#
if self.PciCompress != None:
if self.PciCompress is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_PCI_COMPRESS),
LineInfo=self.CurrentLine)
return False
@@ -215,11 +215,11 @@ class InfDefSection(InfDefSectionOptionRomInfo):
#
# Value has been set before.
#
if self.BaseName != None:
if self.BaseName is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_BASE_NAME),
LineInfo=self.CurrentLine)
return False
if not (BaseName == '' or BaseName == None):
if not (BaseName == '' or BaseName is None):
if IsValidWord(BaseName) and not BaseName.startswith("_"):
self.BaseName = InfDefMember()
self.BaseName.SetValue(BaseName)
@@ -243,7 +243,7 @@ class InfDefSection(InfDefSectionOptionRomInfo):
#
# Value has been set before.
#
if self.FileGuid != None:
if self.FileGuid is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
%(DT.TAB_INF_DEFINES_FILE_GUID),
LineInfo=self.CurrentLine)
@@ -274,7 +274,7 @@ class InfDefSection(InfDefSectionOptionRomInfo):
#
# Value has been set before.
#
if self.ModuleType != None:
if self.ModuleType is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
%(DT.TAB_INF_DEFINES_MODULE_TYPE),
LineInfo=self.CurrentLine)
@@ -309,7 +309,7 @@ class InfDefSection(InfDefSectionOptionRomInfo):
def SetModuleUniFileName(self, ModuleUniFileName, Comments):
if Comments:
pass
if self.ModuleUniFileName != None:
if self.ModuleUniFileName is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_MODULE_UNI_FILE),
LineInfo=self.CurrentLine)
self.ModuleUniFileName = ModuleUniFileName
@@ -327,7 +327,7 @@ class InfDefSection(InfDefSectionOptionRomInfo):
#
# Value has been set before.
#
if self.InfVersion != None:
if self.InfVersion is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
%(DT.TAB_INF_DEFINES_INF_VERSION),
LineInfo=self.CurrentLine)
@@ -368,7 +368,7 @@ class InfDefSection(InfDefSectionOptionRomInfo):
#
# Value has been set before.
#
if self.EdkReleaseVersion != None:
if self.EdkReleaseVersion is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
%(DT.TAB_INF_DEFINES_EDK_RELEASE_VERSION),
LineInfo=self.CurrentLine)
@@ -401,7 +401,7 @@ class InfDefSection(InfDefSectionOptionRomInfo):
#
# Value has been set before.
#
if self.UefiSpecificationVersion != None:
if self.UefiSpecificationVersion is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
%(DT.TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION),
LineInfo=self.CurrentLine)
@@ -434,7 +434,7 @@ class InfDefSection(InfDefSectionOptionRomInfo):
#
# Value has been set before.
#
if self.PiSpecificationVersion != None:
if self.PiSpecificationVersion is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
%(DT.TAB_INF_DEFINES_PI_SPECIFICATION_VERSION),
LineInfo=self.CurrentLine)
@@ -495,7 +495,7 @@ class InfDefSection(InfDefSectionOptionRomInfo):
#
# Value has been set before.
#
if self.VersionString != None:
if self.VersionString is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
%(DT.TAB_INF_DEFINES_VERSION_STRING),
LineInfo=self.CurrentLine)
@@ -517,7 +517,7 @@ class InfDefSection(InfDefSectionOptionRomInfo):
#
# Value has been set before.
#
if self.PcdIsDriver != None:
if self.PcdIsDriver is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
%(DT.TAB_INF_DEFINES_PCD_IS_DRIVER),
LineInfo=self.CurrentLine)
@@ -710,7 +710,7 @@ class InfDefSection(InfDefSectionOptionRomInfo):
#
# Value has been set before.
#
if self.Shadow != None:
if self.Shadow is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_SHADOW),
LineInfo=self.CurrentLine)
return False
@@ -731,7 +731,7 @@ class InfDefSection(InfDefSectionOptionRomInfo):
# <CustomMake> ::= [<Family> "|"] <Filename>
#
def SetCustomMakefile(self, CustomMakefile, Comments):
if not (CustomMakefile == '' or CustomMakefile == None):
if not (CustomMakefile == '' or CustomMakefile is None):
ValueList = GetSplitValueList(CustomMakefile)
if len(ValueList) == 1:
FileName = ValueList[0]
@@ -811,12 +811,12 @@ class InfDefSection(InfDefSectionOptionRomInfo):
#
# Value has been set before.
#
if self.UefiHiiResourceSection != None:
if self.UefiHiiResourceSection is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND
%(DT.TAB_INF_DEFINES_UEFI_HII_RESOURCE_SECTION),
LineInfo=self.CurrentLine)
return False
if not (UefiHiiResourceSection == '' or UefiHiiResourceSection == None):
if not (UefiHiiResourceSection == '' or UefiHiiResourceSection is None):
if (IsValidBoolType(UefiHiiResourceSection)):
self.UefiHiiResourceSection = InfDefMember()
self.UefiHiiResourceSection.SetValue(UefiHiiResourceSection)
@@ -948,7 +948,7 @@ class InfDefObject(InfSectionCommonDef):
RaiseError=True)
if Name == DT.TAB_INF_DEFINES_INF_VERSION:
HasFoundInfVersionFalg = True
if not (Name == '' or Name == None):
if not (Name == '' or Name is None):
#
# Process "SPEC" Keyword definition.
#
@@ -971,7 +971,7 @@ class InfDefObject(InfSectionCommonDef):
LineInfo=LineInfo)
else:
ProcessFunc = gFUNCTION_MAPPING_FOR_DEFINE_SECTION[Name]
if (ProcessFunc != None):
if (ProcessFunc is not None):
ProcessFunc(DefineList, Value, InfLineCommentObj)
self.Defines[ArchListString] = DefineList
else:
@@ -991,7 +991,7 @@ class InfDefObject(InfSectionCommonDef):
#
else:
ProcessFunc = gFUNCTION_MAPPING_FOR_DEFINE_SECTION[Name]
if (ProcessFunc != None):
if (ProcessFunc is not None):
ProcessFunc(DefineList, Value, InfLineCommentObj)
self.Defines[ArchListString] = DefineList
#

View File

@@ -107,7 +107,7 @@ def ParseGuidComment(CommentsList, InfGuidItemObj):
#
# Get/Set Usage and HelpString
#
if CommentsList != None and len(CommentsList) != 0 :
if CommentsList is not None and len(CommentsList) != 0 :
CommentInsList = []
PreUsage = None
PreGuidType = None
@@ -126,7 +126,7 @@ def ParseGuidComment(CommentsList, InfGuidItemObj):
[],
True)
if CommentItemHelpText == None:
if CommentItemHelpText is None:
CommentItemHelpText = ''
if Count == len(CommentsList) and CommentItemUsage == CommentItemGuidType == DT.ITEM_UNDEFINED:
CommentItemHelpText = DT.END_OF_LINE
@@ -236,7 +236,7 @@ class InfGuidObject():
#
# Validate Arch
#
if (ArchItem == '' or ArchItem == None):
if (ArchItem == '' or ArchItem is None):
ArchItem = 'COMMON'
__SupportArchList.append(ArchItem)

View File

@@ -43,7 +43,7 @@ class InfHeaderObject():
# @param FileName: File Name
#
def SetFileName(self, FileName):
if not (FileName == '' or FileName == None):
if not (FileName == '' or FileName is None):
self.FileName = FileName
return True
else:
@@ -59,7 +59,7 @@ class InfHeaderObject():
# @param Abstract: Abstract
#
def SetAbstract(self, Abstract):
if not (Abstract == '' or Abstract == None):
if not (Abstract == '' or Abstract is None):
self.Abstract = Abstract
return True
else:
@@ -75,7 +75,7 @@ class InfHeaderObject():
# @param Description: Description content
#
def SetDescription(self, Description):
if not (Description == '' or Description == None):
if not (Description == '' or Description is None):
self.Description = Description
return True
else:
@@ -91,7 +91,7 @@ class InfHeaderObject():
# @param Copyright: Copyright content
#
def SetCopyright(self, Copyright):
if not (Copyright == '' or Copyright == None):
if not (Copyright == '' or Copyright is None):
self.Copyright = Copyright
return True
else:
@@ -107,7 +107,7 @@ class InfHeaderObject():
# @param License: License content
#
def SetLicense(self, License):
if not (License == '' or License == None):
if not (License == '' or License is None):
self.License = License
return True
else:

View File

@@ -38,10 +38,10 @@ def GetArchModuleType(KeyList):
#
# Validate Arch
#
if (ArchItem == '' or ArchItem == None):
if (ArchItem == '' or ArchItem is None):
ArchItem = 'COMMON'
if (ModuleItem == '' or ModuleItem == None):
if (ModuleItem == '' or ModuleItem is None):
ModuleItem = 'COMMON'
if ArchItem not in __SupArchList:
@@ -136,7 +136,7 @@ class InfLibraryClassObject():
LibItemObj.CurrentLine.SetLineNo(LibItem[2][1])
LibItemObj.CurrentLine.SetLineString(LibItem[2][0])
LibItem = LibItem[0]
if HelpStringObj != None:
if HelpStringObj is not None:
LibItemObj.SetHelpString(HelpStringObj)
if len(LibItem) >= 1:
if LibItem[0].strip() != '':

View File

@@ -135,9 +135,9 @@ class InfSpecialCommentObject(InfSectionCommonDef):
# An encapsulate of Error for INF parser.
#
def ErrorInInf(Message=None, ErrorCode=None, LineInfo=None, RaiseError=True):
if ErrorCode == None:
if ErrorCode is None:
ErrorCode = ToolError.FORMAT_INVALID
if LineInfo == None:
if LineInfo is None:
LineInfo = ['', -1, '']
Logger.Error("InfParser",
ErrorCode,

View File

@@ -75,7 +75,7 @@ class InfPackageObject():
#
# Validate Arch
#
if (ArchItem == '' or ArchItem == None):
if (ArchItem == '' or ArchItem is None):
ArchItem = 'COMMON'
SupArchList.append(ArchItem)
@@ -84,7 +84,7 @@ class InfPackageObject():
HelpStringObj = PackageItem[1]
CurrentLineOfPackItem = PackageItem[2]
PackageItem = PackageItem[0]
if HelpStringObj != None:
if HelpStringObj is not None:
HelpString = HelpStringObj.HeaderComments + HelpStringObj.TailComments
PackageItemObj.SetHelpString(HelpString)
if len(PackageItem) >= 1:
@@ -183,5 +183,5 @@ class InfPackageObject():
return True
def GetPackages(self, Arch = None):
if Arch == None:
if Arch is None:
return self.Packages

View File

@@ -43,7 +43,7 @@ def ValidateArch(ArchItem, PcdTypeItem1, LineNo, SupArchDict, SupArchList):
#
# Validate Arch
#
if (ArchItem == '' or ArchItem == None):
if (ArchItem == '' or ArchItem is None):
ArchItem = 'COMMON'
if PcdTypeItem1.upper != DT.TAB_INF_FEATURE_PCD.upper():
@@ -82,7 +82,7 @@ def ParsePcdComment(CommentList, PcdTypeItem, PcdItemObj):
if PcdTypeItem == 'FeaturePcd':
CommentItemUsage = DT.USAGE_ITEM_CONSUMES
if CommentItemHelpText == None:
if CommentItemHelpText is None:
CommentItemHelpText = ''
if Count == 1:
@@ -96,7 +96,7 @@ def ParsePcdComment(CommentList, PcdTypeItem, PcdItemObj):
else:
continue
if CommentItemHelpText == None:
if CommentItemHelpText is None:
CommentItemHelpText = ''
if Count == len(CommentList) and CommentItemUsage == DT.ITEM_UNDEFINED:
CommentItemHelpText = DT.END_OF_LINE
@@ -326,7 +326,7 @@ class InfPcdObject():
#
# Validate PcdType
#
if (PcdTypeItem1 == '' or PcdTypeItem1 == None):
if (PcdTypeItem1 == '' or PcdTypeItem1 is None):
return False
else:
if not IsValidPcdType(PcdTypeItem1):
@@ -346,7 +346,7 @@ class InfPcdObject():
CurrentLineOfPcdItem = PcdItem[2]
PcdItem = PcdItem[0]
if CommentList != None and len(CommentList) != 0:
if CommentList is not None and len(CommentList) != 0:
PcdItemObj = ParsePcdComment(CommentList, PcdTypeItem, PcdItemObj)
else:
CommentItemIns = InfPcdItemCommentContent()

View File

@@ -51,7 +51,7 @@ def ParsePpiComment(CommentsList, InfPpiItemObj):
if CommentItemString:
pass
if CommentItemHelpText == None:
if CommentItemHelpText is None:
CommentItemHelpText = ''
if Count == len(CommentsList) and CommentItemUsage == CommentItemNotify == DT.ITEM_UNDEFINED:
CommentItemHelpText = DT.END_OF_LINE
@@ -213,7 +213,7 @@ class InfPpiObject():
#
# Validate Arch
#
if (ArchItem == '' or ArchItem == None):
if (ArchItem == '' or ArchItem is None):
ArchItem = 'COMMON'
__SupArchList.append(ArchItem)
@@ -290,7 +290,7 @@ class InfPpiObject():
#
# Get/Set Usage and HelpString for PPI entry
#
if CommentsList != None and len(CommentsList) != 0:
if CommentsList is not None and len(CommentsList) != 0:
InfPpiItemObj = ParsePpiComment(CommentsList, InfPpiItemObj)
else:
CommentItemIns = InfPpiItemCommentContent()

View File

@@ -49,7 +49,7 @@ def ParseProtocolComment(CommentsList, InfProtocolItemObj):
if CommentItemString:
pass
if CommentItemHelpText == None:
if CommentItemHelpText is None:
CommentItemHelpText = ''
if Count == len(CommentsList) and CommentItemUsage == CommentItemNotify == DT.ITEM_UNDEFINED:
CommentItemHelpText = DT.END_OF_LINE
@@ -203,7 +203,7 @@ class InfProtocolObject():
#
# Validate Arch
#
if (ArchItem == '' or ArchItem == None):
if (ArchItem == '' or ArchItem is None):
ArchItem = 'COMMON'
__SupArchList.append(ArchItem)
@@ -259,7 +259,7 @@ class InfProtocolObject():
#
# Get/Set Usage and HelpString for Protocol entry
#
if CommentsList != None and len(CommentsList) != 0:
if CommentsList is not None and len(CommentsList) != 0:
InfProtocolItemObj = ParseProtocolComment(CommentsList, InfProtocolItemObj)
else:
CommentItemIns = InfProtocolItemCommentContent()

View File

@@ -211,7 +211,7 @@ class InfSourcesObject(InfSectionCommonDef):
#
# Validate Arch
#
if (ArchItem == '' or ArchItem == None):
if (ArchItem == '' or ArchItem is None):
ArchItem = 'COMMON'
__SupArchList.append(ArchItem)