summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2016-05-10 13:18:02 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-16 22:32:41 (GMT)
commit473daf72545421ee2df40278efda7d3999a5d356 (patch)
treeba356af365a7d3a316a0313f5e9712f74af5ef42
parent337c8af55dac929b72e0bb32ef320cbb4b0e7892 (diff)
downloadpoky-473daf72545421ee2df40278efda7d3999a5d356.tar.gz
bitbake: toaster: replace map with list comprehensions
map returns map object in python 3. Replaced calls of map to equivalent list comprehensions in the code which requires lists. [YOCTO #9584] (Bitbake rev: 49d9cf1040e1659350eeaf6db4c40dc4c9bf7e50) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/toaster/orm/models.py2
-rw-r--r--bitbake/lib/toaster/toastergui/tables.py3
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py45
3 files changed, 20 insertions, 30 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index ee01a46..dd64664 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -1183,7 +1183,7 @@ class LayerIndexLayerSource(LayerSource):
1183 1183
1184 # update branches; only those that we already have names listed in the 1184 # update branches; only those that we already have names listed in the
1185 # Releases table 1185 # Releases table
1186 whitelist_branch_names = map(lambda x: x.branch_name, Release.objects.all()) 1186 whitelist_branch_names = [rel.branch_name for rel in Release.objects.all()]
1187 if len(whitelist_branch_names) == 0: 1187 if len(whitelist_branch_names) == 0:
1188 raise Exception("Failed to make list of branches to fetch") 1188 raise Exception("Failed to make list of branches to fetch")
1189 1189
diff --git a/bitbake/lib/toaster/toastergui/tables.py b/bitbake/lib/toaster/toastergui/tables.py
index d375da4..82dd3cd 100644
--- a/bitbake/lib/toaster/toastergui/tables.py
+++ b/bitbake/lib/toaster/toastergui/tables.py
@@ -344,8 +344,7 @@ class RecipesTable(ToasterTable):
344 context = super(RecipesTable, self).get_context_data(**kwargs) 344 context = super(RecipesTable, self).get_context_data(**kwargs)
345 345
346 context['project'] = project 346 context['project'] = project
347 347 context['projectlayers'] = [player.layercommit.id for player in ProjectLayer.objects.filter(project=context['project'])]
348 context['projectlayers'] = map(lambda prjlayer: prjlayer.layercommit.id, ProjectLayer.objects.filter(project=context['project']))
349 348
350 return context 349 return context
351 350
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index b256db7..8e920f0 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -967,18 +967,19 @@ def dirinfo(request, build_id, target_id, file_path=None):
967 return render(request, template, context) 967 return render(request, template, context)
968 968
969def _find_task_dep(task_object): 969def _find_task_dep(task_object):
970 return map(lambda x: x.depends_on, Task_Dependency.objects.filter(task=task_object).filter(depends_on__order__gt = 0).exclude(depends_on__outcome = Task.OUTCOME_NA).select_related("depends_on")) 970 tdeps = Task_Dependency.objects.filter(task=task_object).filter(depends_on__order__gt=0)
971 971 tdeps = tdeps.exclude(depends_on__outcome=Task.OUTCOME_NA).select_related("depends_on")
972 return [x.depends_on for x in tdeps]
972 973
973def _find_task_revdep(task_object): 974def _find_task_revdep(task_object):
974 tp = [] 975 tdeps = Task_Dependency.objects.filter(depends_on=task_object).filter(task__order__gt=0)
975 tp = map(lambda t: t.task, Task_Dependency.objects.filter(depends_on=task_object).filter(task__order__gt=0).exclude(task__outcome = Task.OUTCOME_NA).select_related("task", "task__recipe", "task__build")) 976 tdeps = tdeps.exclude(task__outcome = Task.OUTCOME_NA).select_related("task", "task__recipe", "task__build")
976 return tp 977 return [tdep.task for tdep in tdeps]
977 978
978def _find_task_revdep_list(tasklist): 979def _find_task_revdep_list(tasklist):
979 tp = [] 980 tdeps = Task_Dependency.objects.filter(depends_on__in=tasklist).filter(task__order__gt=0)
980 tp = map(lambda t: t.task, Task_Dependency.objects.filter(depends_on__in=tasklist).filter(task__order__gt=0).exclude(task__outcome = Task.OUTCOME_NA).select_related("task", "task__recipe", "task__build")) 981 tdeps = tdeps.exclude(task__outcome=Task.OUTCOME_NA).select_related("task", "task__recipe", "task__build")
981 return tp 982 return [tdep.task for tdep in tdeps]
982 983
983def _find_task_provider(task_object): 984def _find_task_provider(task_object):
984 task_revdeps = _find_task_revdep(task_object) 985 task_revdeps = _find_task_revdep(task_object)
@@ -1979,7 +1980,8 @@ if True:
1979 1980
1980 except (IntegrityError, BadParameterException) as e: 1981 except (IntegrityError, BadParameterException) as e:
1981 # fill in page with previously submitted values 1982 # fill in page with previously submitted values
1982 map(lambda x: context.__setitem__(x, request.POST.get(x, "-- missing")), mandatory_fields) 1983 for field in mandatory_fields:
1984 context.__setitem__(field, request.POST.get(field, "-- missing"))
1983 if isinstance(e, IntegrityError) and "username" in str(e): 1985 if isinstance(e, IntegrityError) and "username" in str(e):
1984 context['alert'] = "Your chosen username is already used" 1986 context['alert'] = "Your chosen username is already used"
1985 else: 1987 else:
@@ -2073,21 +2075,11 @@ if True:
2073 "prj" : {"name": prj.name, }, 2075 "prj" : {"name": prj.name, },
2074 "buildrequests" : prj.build_set.filter(outcome=Build.IN_PROGRESS), 2076 "buildrequests" : prj.build_set.filter(outcome=Build.IN_PROGRESS),
2075 "builds" : Build.get_recent(prj), 2077 "builds" : Build.get_recent(prj),
2076 "layers" : map(lambda x: { 2078 "layers" : layers,
2077 "id": x.layercommit.pk, 2079 "targets" : [{"target" : x.target, "task" : x.task, "pk": x.pk} for x in prj.projecttarget_set.all()],
2078 "orderid": x.pk, 2080 "variables": [(x.name, x.value) for x in prj.projectvariable_set.all()],
2079 "name" : x.layercommit.layer.name,
2080 "vcs_url": x.layercommit.layer.vcs_url,
2081 "vcs_reference" : x.layercommit.get_vcs_reference(),
2082 "url": x.layercommit.layer.layer_index_url,
2083 "layerdetailurl": x.layercommit.get_detailspage_url(prj.pk),
2084 # This branch name is actually the release
2085 "branch" : { "name" : x.layercommit.get_vcs_reference(), "layersource" : x.layercommit.up_branch.layer_source.name if x.layercommit.up_branch != None else None}},
2086 prj.projectlayer_set.all().order_by("id")),
2087 "targets" : map(lambda x: {"target" : x.target, "task" : x.task, "pk": x.pk}, prj.projecttarget_set.all()),
2088 "variables": map(lambda x: (x.name, x.value), prj.projectvariable_set.all()),
2089 "freqtargets": freqtargets[:5], 2081 "freqtargets": freqtargets[:5],
2090 "releases": map(lambda x: {"id": x.pk, "name": x.name, "description":x.description}, Release.objects.all()), 2082 "releases": [{"id": x.pk, "name": x.name, "description":x.description} for x in Release.objects.all()],
2091 "project_html": 1, 2083 "project_html": 1,
2092 "recipesTypeAheadUrl": reverse('xhr_recipestypeahead', args=(prj.pk,)), 2084 "recipesTypeAheadUrl": reverse('xhr_recipestypeahead', args=(prj.pk,)),
2093 "projectBuildsUrl": reverse('projectbuilds', args=(prj.pk,)), 2085 "projectBuildsUrl": reverse('projectbuilds', args=(prj.pk,)),
@@ -2178,8 +2170,7 @@ if True:
2178 retval.append(project) 2170 retval.append(project)
2179 2171
2180 return response({"error":"ok", 2172 return response({"error":"ok",
2181 "rows" : map( _lv_to_dict(prj), 2173 "rows": [_lv_to_dict(prj) for y in [x.layercommit for x in retval]]
2182 map(lambda x: x.layercommit, retval ))
2183 }) 2174 })
2184 2175
2185 except Exception as e: 2176 except Exception as e:
@@ -2225,7 +2216,7 @@ if True:
2225 2216
2226 return_data = { 2217 return_data = {
2227 "error": "ok", 2218 "error": "ok",
2228 'configvars' : map(lambda x: (x.name, x.value, x.pk), configvars_query), 2219 'configvars': [(x.name, x.value, x.pk) for x in configvars_query]
2229 } 2220 }
2230 try: 2221 try:
2231 return_data['distro'] = ProjectVariable.objects.get(project = prj, name = "DISTRO").value, 2222 return_data['distro'] = ProjectVariable.objects.get(project = prj, name = "DISTRO").value,
@@ -2848,7 +2839,7 @@ if True:
2848 "vcs_url": dep.layer.vcs_url, 2839 "vcs_url": dep.layer.vcs_url,
2849 "vcs_reference": dep.get_vcs_reference()} \ 2840 "vcs_reference": dep.get_vcs_reference()} \
2850 for dep in layer_version.get_alldeps(project.id)]}, 2841 for dep in layer_version.get_alldeps(project.id)]},
2851 'projectlayers': map(lambda prjlayer: prjlayer.layercommit.id, ProjectLayer.objects.filter(project=project)) 2842 'projectlayers': [player.layercommit.id for player in ProjectLayer.objects.filter(project=project)]
2852 } 2843 }
2853 2844
2854 return context 2845 return context