1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-04 02:00:04 +00:00

bitbake: lib: amend code to use proper singleton comparisons where possible

amend the code to handle singleton comparisons properly so it only checks
if they only refer to the same object or not, and not bother
comparing the values.

(Bitbake rev: b809a6812aa15a8a9af97bc382cc4b19571e6bfc)

Signed-off-by: Frazer Clews <frazer.clews@codethink.co.uk>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Frazer Clews
2020-01-16 17:11:19 +00:00
committed by Richard Purdie
parent 0ac5174c7d
commit fa5524890e
28 changed files with 65 additions and 65 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ class Command:
# Can run synchronous commands straight away
command_method = getattr(self.cmds_sync, command)
if ro_only:
if not hasattr(command_method, 'readonly') or False == getattr(command_method, 'readonly'):
if not hasattr(command_method, 'readonly') or not getattr(command_method, 'readonly'):
return None, "Not able to execute not readonly commands in readonly mode"
try:
self.cooker.process_inotify_updates()
+4 -4
View File
@@ -1204,7 +1204,7 @@ class BBCooker:
for c in collection_list:
calc_layer_priority(c)
regex = self.data.getVar("BBFILE_PATTERN_%s" % c)
if regex == None:
if regex is None:
parselog.error("BBFILE_PATTERN_%s not defined" % c)
errors = True
continue
@@ -1310,7 +1310,7 @@ class BBCooker:
self.parseConfiguration()
# If we are told to do the None task then query the default task
if (task == None):
if task is None:
task = self.configuration.cmd
if not task.startswith("do_"):
task = "do_%s" % task
@@ -1454,7 +1454,7 @@ class BBCooker:
self.buildSetVars()
# If we are told to do the None task then query the default task
if (task == None):
if task is None:
task = self.configuration.cmd
if not task.startswith("do_"):
@@ -1687,7 +1687,7 @@ class CookerCollectFiles(object):
def calc_bbfile_priority( self, filename, matched = None ):
for _, _, regex, pri in self.bbfile_config_priorities:
if regex.match(filename):
if matched != None:
if matched is not None:
if not regex in matched:
matched.add(regex)
return pri
+1 -1
View File
@@ -79,7 +79,7 @@ def expand(s, d, varname = None):
return d.expand(s, varname)
def expandKeys(alterdata, readdata = None):
if readdata == None:
if readdata is None:
readdata = alterdata
todolist = {}
+1 -1
View File
@@ -346,7 +346,7 @@ def set_UIHmask(handlerNum, level, debug_domains, mask):
def getName(e):
"""Returns the name of a class or class instance"""
if getattr(e, "__name__", None) == None:
if getattr(e, "__name__", None) is None:
return e.__class__.__name__
else:
return e.__name__
+2 -2
View File
@@ -1081,7 +1081,7 @@ def try_mirrors(fetch, d, origud, mirrors, check = False):
for index, uri in enumerate(uris):
ret = try_mirror_url(fetch, origud, uds[index], ld, check)
if ret != False:
if ret:
return ret
return None
@@ -1351,7 +1351,7 @@ class FetchMethod(object):
"""
# We cannot compute checksums for directories
if os.path.isdir(urldata.localpath) == True:
if os.path.isdir(urldata.localpath):
return False
if urldata.localpath.find("*") != -1:
return False
+1 -1
View File
@@ -671,7 +671,7 @@ class Git(FetchMethod):
# search for version in the line
tag = tagregex.search(tag_head)
if tag == None:
if tag is None:
continue
tag = tag.group('pver')
+1 -1
View File
@@ -41,7 +41,7 @@ class Osc(FetchMethod):
else:
pv = d.getVar("PV", False)
rev = bb.fetch2.srcrev_internal_helper(ud, d)
if rev and rev != True:
if rev:
ud.revision = rev
else:
ud.revision = ""
+1 -1
View File
@@ -104,7 +104,7 @@ class Perforce(FetchMethod):
if command == 'changes':
p4cmd = '%s%s changes -m 1 //%s' % (ud.basecmd, p4opt, pathnrev)
elif command == 'print':
if depot_filename != None:
if depot_filename is not None:
p4cmd = '%s%s print -o "p4/%s" "%s"' % (ud.basecmd, p4opt, filename, depot_filename)
else:
raise FetchError('No depot file name provided to p4 %s' % command, ud.url)
+1 -1
View File
@@ -58,7 +58,7 @@ class SSH(FetchMethod):
'''Class to fetch a module or modules via Secure Shell'''
def supports(self, urldata, d):
return __pattern__.match(urldata.url) != None
return __pattern__.match(urldata.url) is not None
def supports_checksum(self, urldata):
return False
+10 -10
View File
@@ -89,7 +89,7 @@ class DataNode(AstNode):
self.groupd = groupd
def getFunc(self, key, data):
if 'flag' in self.groupd and self.groupd['flag'] != None:
if 'flag' in self.groupd and self.groupd['flag'] is not None:
return data.getVarFlag(key, self.groupd['flag'], expand=False, noweakdefault=True)
else:
return data.getVar(key, False, noweakdefault=True, parsing=True)
@@ -102,36 +102,36 @@ class DataNode(AstNode):
'file': self.filename,
'line': self.lineno,
}
if "exp" in groupd and groupd["exp"] != None:
if "exp" in groupd and groupd["exp"] is not None:
data.setVarFlag(key, "export", 1, op = 'exported', **loginfo)
op = "set"
if "ques" in groupd and groupd["ques"] != None:
if "ques" in groupd and groupd["ques"] is not None:
val = self.getFunc(key, data)
op = "set?"
if val == None:
if val is None:
val = groupd["value"]
elif "colon" in groupd and groupd["colon"] != None:
elif "colon" in groupd and groupd["colon"] is not None:
e = data.createCopy()
op = "immediate"
val = e.expand(groupd["value"], key + "[:=]")
elif "append" in groupd and groupd["append"] != None:
elif "append" in groupd and groupd["append"] is not None:
op = "append"
val = "%s %s" % ((self.getFunc(key, data) or ""), groupd["value"])
elif "prepend" in groupd and groupd["prepend"] != None:
elif "prepend" in groupd and groupd["prepend"] is not None:
op = "prepend"
val = "%s %s" % (groupd["value"], (self.getFunc(key, data) or ""))
elif "postdot" in groupd and groupd["postdot"] != None:
elif "postdot" in groupd and groupd["postdot"] is not None:
op = "postdot"
val = "%s%s" % ((self.getFunc(key, data) or ""), groupd["value"])
elif "predot" in groupd and groupd["predot"] != None:
elif "predot" in groupd and groupd["predot"] is not None:
op = "predot"
val = "%s%s" % (groupd["value"], (self.getFunc(key, data) or ""))
else:
val = groupd["value"]
flag = None
if 'flag' in groupd and groupd['flag'] != None:
if 'flag' in groupd and groupd['flag'] is not None:
flag = groupd['flag']
elif groupd["lazyques"]:
flag = "_defaultval"
+3 -3
View File
@@ -92,11 +92,11 @@ def preferredVersionMatch(pe, pv, pr, preferred_e, preferred_v, preferred_r):
Check if the version pe,pv,pr is the preferred one.
If there is preferred version defined and ends with '%', then pv has to start with that version after removing the '%'
"""
if (pr == preferred_r or preferred_r == None):
if (pe == preferred_e or preferred_e == None):
if pr == preferred_r or preferred_r is None:
if pe == preferred_e or preferred_e is None:
if preferred_v == pv:
return True
if preferred_v != None and preferred_v.endswith('%') and pv.startswith(preferred_v[:len(preferred_v)-1]):
if preferred_v is not None and preferred_v.endswith('%') and pv.startswith(preferred_v[:len(preferred_v)-1]):
return True
return False
+1 -1
View File
@@ -362,7 +362,7 @@ class TaskData:
bb.event.fire(bb.event.NoProvider(item, dependees=self.get_dependees(item), reasons=["No eligible PROVIDERs exist for '%s'" % item]), cfgData)
raise bb.providers.NoProvider(item)
if len(eligible) > 1 and foundUnique == False:
if len(eligible) > 1 and not foundUnique:
if item not in self.consider_msgs_cache:
providers_list = []
for fn in eligible:
+4 -4
View File
@@ -935,7 +935,7 @@ class BuildInfoHelper(object):
# only reset the build name if the one on the server is actually
# a valid value for the build_name field
if build_name != None:
if build_name is not None:
build_info['build_name'] = build_name
changed = True
@@ -1194,7 +1194,7 @@ class BuildInfoHelper(object):
evdata = BuildInfoHelper._get_data_from_event(event)
for t in self.internal_state['targets']:
if t.is_image == True:
if t.is_image:
output_files = list(evdata.keys())
for output in output_files:
if t.target in output and 'rootfs' in output and not output.endswith(".manifest"):
@@ -1236,7 +1236,7 @@ class BuildInfoHelper(object):
task_information['outcome'] = Task.OUTCOME_PREBUILT
else:
task_information['task_executed'] = True
if 'noexec' in vars(event) and event.noexec == True:
if 'noexec' in vars(event) and event.noexec:
task_information['task_executed'] = False
task_information['outcome'] = Task.OUTCOME_EMPTY
task_information['script_type'] = Task.CODING_NA
@@ -1776,7 +1776,7 @@ class BuildInfoHelper(object):
image_file_extensions_unique = {}
image_fstypes = self.server.runCommand(
['getVariable', 'IMAGE_FSTYPES'])[0]
if image_fstypes != None:
if image_fstypes is not None:
image_types_str = image_fstypes.strip()
image_file_extensions = re.sub(r' {2,}', ' ', image_types_str)
image_file_extensions_unique = set(image_file_extensions.split(' '))
+1 -1
View File
@@ -447,7 +447,7 @@ def main(server, eventHandler, params, tf = TerminalFilter):
if error:
logger.error("Command '%s' failed: %s" % (cmdline, error))
return 1
elif ret != True:
elif not ret:
logger.error("Command '%s' failed: returned %s" % (cmdline, ret))
return 1
+1 -1
View File
@@ -238,7 +238,7 @@ class NCursesUI:
if error:
print("Error running command '%s': %s" % (cmdline, error))
return
elif ret != True:
elif not ret:
print("Couldn't get default commandlind! %s" % ret)
return
except xmlrpc.client.Fault as x:
+1 -1
View File
@@ -200,7 +200,7 @@ def main(server, eventHandler, params):
if error:
print("Error running command '%s': %s" % (cmdline, error))
return 1
elif ret != True:
elif not ret:
print("Error running command '%s': returned %s" % (cmdline, ret))
return 1
except client.Fault as x:
+1 -1
View File
@@ -176,7 +176,7 @@ def main(server, eventHandler, params):
if error:
logger.error("Command '%s' failed: %s" % (cmdline, error))
return 1
elif ret != True:
elif not ret:
logger.error("Command '%s' failed: returned %s" % (cmdline, ret))
return 1
+1 -1
View File
@@ -46,7 +46,7 @@ class BBUIEventQueue:
self.EventHandle = ret
error = ""
if self.EventHandle != None:
if self.EventHandle is not None:
break
errmsg = "Could not register UI event handler. Error: %s, host %s, "\