1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-09 17:39:31 +00:00

classes/lib: Update to match python3 iter requirements

python3 standardises its use of iteration operations. Update
the code to match the for python3 requires.

(From OE-Core rev: 2476bdcbef591e951d11d57d53f1315848758571)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2016-05-20 11:49:34 +01:00
parent a7309d5790
commit 8587bce564
12 changed files with 19 additions and 19 deletions
+1 -1
View File
@@ -838,7 +838,7 @@ python write_srcrev() {
f.write('# SRCREV_%s = "%s"\n' % (name, orig_srcrev)) f.write('# SRCREV_%s = "%s"\n' % (name, orig_srcrev))
f.write('SRCREV_%s = "%s"\n' % (name, srcrev)) f.write('SRCREV_%s = "%s"\n' % (name, srcrev))
else: else:
f.write('SRCREV = "%s"\n' % srcrevs.itervalues().next()) f.write('SRCREV = "%s"\n' % srcrevs.values())
if len(tag_srcrevs) > 0: if len(tag_srcrevs) > 0:
for name, srcrev in tag_srcrevs.items(): for name, srcrev in tag_srcrevs.items():
f.write('# tag_%s = "%s"\n' % (name, srcrev)) f.write('# tag_%s = "%s"\n' % (name, srcrev))
+2 -2
View File
@@ -200,7 +200,7 @@ def get_deployed_dependencies(d):
# it might contain the bootloader. # it might contain the bootloader.
taskdata = d.getVar("BB_TASKDEPDATA", False) taskdata = d.getVar("BB_TASKDEPDATA", False)
depends = list(set([dep[0] for dep depends = list(set([dep[0] for dep
in taskdata.itervalues() in list(taskdata.values())
if not dep[0].endswith("-native")])) if not dep[0].endswith("-native")]))
extra_depends = d.getVar("EXTRA_IMAGEDEPENDS", True) extra_depends = d.getVar("EXTRA_IMAGEDEPENDS", True)
boot_depends = get_boot_dependencies(d) boot_depends = get_boot_dependencies(d)
@@ -261,7 +261,7 @@ def get_boot_dependencies(d):
depends.append(dep) depends.append(dep)
# We need to search for the provider of the dependency # We need to search for the provider of the dependency
else: else:
for taskdep in taskdepdata.itervalues(): for taskdep in taskdepdata.values():
# The fifth field contains what the task provides # The fifth field contains what the task provides
if dep in taskdep[4]: if dep in taskdep[4]:
info_file = os.path.join( info_file = os.path.join(
+2 -2
View File
@@ -45,7 +45,7 @@ def get_sdk_install_targets(d):
sdk_install_targets = d.getVar('SDK_TARGETS', True) sdk_install_targets = d.getVar('SDK_TARGETS', True)
depd = d.getVar('BB_TASKDEPDATA', False) depd = d.getVar('BB_TASKDEPDATA', False)
for v in depd.itervalues(): for v in depd.values():
if v[1] == 'do_image_complete': if v[1] == 'do_image_complete':
if v[0] not in sdk_install_targets: if v[0] not in sdk_install_targets:
sdk_install_targets += ' {}'.format(v[0]) sdk_install_targets += ' {}'.format(v[0])
@@ -267,7 +267,7 @@ python copy_buildsystem () {
# Ensure any variables set from the external environment (by way of # Ensure any variables set from the external environment (by way of
# BB_ENV_EXTRAWHITE) are set in the SDK's configuration # BB_ENV_EXTRAWHITE) are set in the SDK's configuration
extralines = [] extralines = []
for name, value in env_whitelist_values.iteritems(): for name, value in env_whitelist_values.items():
actualvalue = d.getVar(name, True) or '' actualvalue = d.getVar(name, True) or ''
if value != actualvalue: if value != actualvalue:
extralines.append('%s = "%s"\n' % (name, actualvalue)) extralines.append('%s = "%s"\n' % (name, actualvalue))
+2 -2
View File
@@ -62,7 +62,7 @@ class ChangeRecord:
def pkglist_combine(depver): def pkglist_combine(depver):
pkglist = [] pkglist = []
for k,v in depver.iteritems(): for k,v in depver.items():
if v: if v:
pkglist.append("%s (%s)" % (k,v)) pkglist.append("%s (%s)" % (k,v))
else: else:
@@ -220,7 +220,7 @@ def compare_file_lists(alines, blines):
adict = file_list_to_dict(alines) adict = file_list_to_dict(alines)
bdict = file_list_to_dict(blines) bdict = file_list_to_dict(blines)
filechanges = [] filechanges = []
for path, splitv in adict.iteritems(): for path, splitv in adict.items():
newsplitv = bdict.pop(path, None) newsplitv = bdict.pop(path, None)
if newsplitv: if newsplitv:
# Check type # Check type
+1 -1
View File
@@ -124,7 +124,7 @@ class BuildSystem(object):
def generate_locked_sigs(sigfile, d): def generate_locked_sigs(sigfile, d):
bb.utils.mkdirhier(os.path.dirname(sigfile)) bb.utils.mkdirhier(os.path.dirname(sigfile))
depd = d.getVar('BB_TASKDEPDATA', False) depd = d.getVar('BB_TASKDEPDATA', False)
tasks = ['%s.%s' % (v[2], v[1]) for v in depd.itervalues()] tasks = ['%s.%s' % (v[2], v[1]) for v in depd.values()]
bb.parse.siggen.dump_lockedsigs(sigfile, tasks) bb.parse.siggen.dump_lockedsigs(sigfile, tasks)
def prune_lockedsigs(excluded_tasks, excluded_targets, lockedsigs, pruned_output): def prune_lockedsigs(excluded_tasks, excluded_targets, lockedsigs, pruned_output):
+1 -1
View File
@@ -7,7 +7,7 @@ def typed_value(key, d):
flags = d.getVarFlags(key) flags = d.getVarFlags(key)
if flags is not None: if flags is not None:
flags = dict((flag, d.expand(value)) flags = dict((flag, d.expand(value))
for flag, value in flags.iteritems()) for flag, value in list(flags.items()))
else: else:
flags = {} flags = {}
+4 -4
View File
@@ -336,7 +336,7 @@ def patch_recipe(d, fn, varvalues, patch=False, relpath=''):
varfiles = get_var_files(fn, varlist, d) varfiles = get_var_files(fn, varlist, d)
locs = localise_file_vars(fn, varfiles, varlist) locs = localise_file_vars(fn, varfiles, varlist)
patches = [] patches = []
for f,v in locs.iteritems(): for f,v in locs.items():
vals = {k: varvalues[k] for k in v} vals = {k: varvalues[k] for k in v}
patchdata = patch_recipe_file(f, vals, patch, relpath) patchdata = patch_recipe_file(f, vals, patch, relpath)
if patch: if patch:
@@ -554,7 +554,7 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False,
bbappendlines = [] bbappendlines = []
if extralines: if extralines:
if isinstance(extralines, dict): if isinstance(extralines, dict):
for name, value in extralines.iteritems(): for name, value in extralines.items():
bbappendlines.append((name, '=', value)) bbappendlines.append((name, '=', value))
else: else:
# Do our best to split it # Do our best to split it
@@ -594,7 +594,7 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False,
copyfiles = {} copyfiles = {}
if srcfiles: if srcfiles:
instfunclines = [] instfunclines = []
for newfile, origsrcfile in srcfiles.iteritems(): for newfile, origsrcfile in srcfiles.items():
srcfile = origsrcfile srcfile = origsrcfile
srcurientry = None srcurientry = None
if not srcfile: if not srcfile:
@@ -717,7 +717,7 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False,
if copyfiles: if copyfiles:
if machine: if machine:
destsubdir = os.path.join(destsubdir, machine) destsubdir = os.path.join(destsubdir, machine)
for newfile, srcfile in copyfiles.iteritems(): for newfile, srcfile in copyfiles.items():
filedest = os.path.join(appenddir, destsubdir, os.path.basename(srcfile)) filedest = os.path.join(appenddir, destsubdir, os.path.basename(srcfile))
if os.path.abspath(newfile) != os.path.abspath(filedest): if os.path.abspath(newfile) != os.path.abspath(filedest):
bb.note('Copying %s to %s' % (newfile, filedest)) bb.note('Copying %s to %s' % (newfile, filedest))
+1 -1
View File
@@ -220,7 +220,7 @@ class SignatureGeneratorOEBasicHash(bb.siggen.SignatureGeneratorBasicHash):
for task in range(len(sq_fn)): for task in range(len(sq_fn)):
if task not in ret: if task not in ret:
for pn in self.lockedsigs: for pn in self.lockedsigs:
if sq_hash[task] in self.lockedsigs[pn].itervalues(): if sq_hash[task] in iter(self.lockedsigs[pn].values()):
if sq_task[task] == 'do_shared_workdir': if sq_task[task] == 'do_shared_workdir':
continue continue
sstate_missing_msgs.append("Locked sig is set for %s:%s (%s) yet not in sstate cache?" sstate_missing_msgs.append("Locked sig is set for %s:%s (%s) yet not in sstate cache?"
+1 -1
View File
@@ -50,7 +50,7 @@ class DevtoolBase(oeSelfTest):
missingvars = {} missingvars = {}
for var, value in checkvars.iteritems(): for var, value in checkvars.items():
if value is not None: if value is not None:
missingvars[var] = value missingvars[var] = value
self.assertEqual(missingvars, {}, 'Some expected variables not found in recipe: %s' % checkvars) self.assertEqual(missingvars, {}, 'Some expected variables not found in recipe: %s' % checkvars)
+2 -2
View File
@@ -445,14 +445,14 @@ http_proxy = "http://example.com/"
files1 = get_files(topdir + "/tmp-sstatesamehash/stamps/") files1 = get_files(topdir + "/tmp-sstatesamehash/stamps/")
files2 = get_files(topdir + "/tmp-sstatesamehash2/stamps/") files2 = get_files(topdir + "/tmp-sstatesamehash2/stamps/")
# Remove items that are identical in both sets # Remove items that are identical in both sets
for k,v in files1.viewitems() & files2.viewitems(): for k,v in files1.items() & files2.items():
del files1[k] del files1[k]
del files2[k] del files2[k]
if not files1 and not files2: if not files1 and not files2:
# No changes, so we're done # No changes, so we're done
return return
for k in files1.viewkeys() | files2.viewkeys(): for k in files1.keys() | files2.keys():
if k in files1 and k in files2: if k in files1 and k in files2:
print("%s differs:" % k) print("%s differs:" % k)
print(subprocess.check_output(("bitbake-diffsigs", print(subprocess.check_output(("bitbake-diffsigs",
+1 -1
View File
@@ -215,7 +215,7 @@ def tag(*args, **kwargs):
def wrap_ob(ob): def wrap_ob(ob):
for name in args: for name in args:
setattr(ob, __tag_prefix + name, True) setattr(ob, __tag_prefix + name, True)
for name, value in kwargs.iteritems(): for name, value in kwargs.items():
setattr(ob, __tag_prefix + name, value) setattr(ob, __tag_prefix + name, value)
return ob return ob
return wrap_ob return wrap_ob
+1 -1
View File
@@ -840,7 +840,7 @@ class SpecFileRecipeHandler(RecipeHandler):
linecount = 0 linecount = 0
with open(fileitem, 'r') as f: with open(fileitem, 'r') as f:
for line in f: for line in f:
for value, varname in valuemap.iteritems(): for value, varname in valuemap.items():
if line.startswith(value + ':') and not varname in foundvalues: if line.startswith(value + ':') and not varname in foundvalues:
foundvalues[varname] = line.split(':', 1)[1].strip() foundvalues[varname] = line.split(':', 1)[1].strip()
break break