summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2015-10-02 11:05:12 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-10-12 14:37:49 +0100
commit7d853a3054a9ae3d18eb6f5bc13ba27d2795c31a (patch)
treeb8a4c5a2d76341a9b44c18f52f5b2b29bf622cd5 /lib
parent9c40b3b6377ab8f5d6ac9b8e00585b71de00bf74 (diff)
downloadbitbake-7d853a3054a9ae3d18eb6f5bc13ba27d2795c31a.tar.gz
toaster: implement API to get full list of deps
Implemented Layer_Version.get_alldeps API to recursively get full list of dependencies for the layer. Dependencies that are already in the project are filtered out from the result. Result list of Layer_Version objects is sorted by layer name for UI to look consistent. This API is going to be used to show amount and list of dependencies for the layer in the list of compatible layers for the project. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: brian avery <avery.brian@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/toaster/orm/models.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/toaster/orm/models.py b/lib/toaster/orm/models.py
index 9851c92b7..9a5942b75 100644
--- a/lib/toaster/orm/models.py
+++ b/lib/toaster/orm/models.py
@@ -1177,6 +1177,25 @@ class Layer_Version(models.Model):
def get_detailspage_url(self, project_id):
return reverse('layerdetails', args=(project_id, self.pk))
+ def get_alldeps(self, project_id):
+ """Get full list of unique layer dependencies."""
+ def gen_layerdeps(lver, project):
+ for ldep in lver.dependencies.all():
+ yield ldep.depends_on
+ # get next level of deps recursively calling gen_layerdeps
+ for subdep in gen_layerdeps(ldep.depends_on, project):
+ yield subdep
+
+ project = Project.objects.get(pk=project_id)
+ result = []
+ projectlvers = [player.layercommit for player in project.projectlayer_set.all()]
+ for dep in gen_layerdeps(self, project):
+ # filter out duplicates and layers already belonging to the project
+ if dep not in result + projectlvers:
+ result.append(dep)
+
+ return sorted(result, key=lambda x: x.layer.name)
+
def __unicode__(self):
return "%d %s (VCS %s, Project %s)" % (self.pk, str(self.layer), self.get_vcs_reference(), self.build.project if self.build is not None else "No project")