Commit e97ac43e authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

Dependencies: look for ROS’ packages.xml

parent 50f7caf1
Pipeline #941 passed with stages
in 46 seconds
# Generated by Django 2.0.5 on 2018-07-11 16:54
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('rainboard', '0021_dependency'),
]
operations = [
migrations.AddField(
model_name='dependency',
name='ros',
field=models.BooleanField(default=False),
),
]
...@@ -232,6 +232,20 @@ class Project(Links, NamedModel, TimeStampedModel): ...@@ -232,6 +232,20 @@ class Project(Links, NamedModel, TimeStampedModel):
dependency.cmake = True dependency.cmake = True
dependency.save() dependency.save()
def ros(self):
filename = self.git_path() / 'package.xml'
if not filename.exists():
return
with filename.open() as f:
content = f.read()
for dependency in re.findall(r'<run_depend>(\w+).*</run_depend>', content, re.I):
project = Project.objects.filter(models.Q(slug=dependency) | models.Q(slug=dependency.replace('_', '-')))
if project.exists():
dependency, _ = Dependency.objects.get_or_create(project=self, library=project.first())
if not dependency.ros:
dependency.ros = True
dependency.save()
def repos(self): def repos(self):
return self.repo_set.count() return self.repo_set.count()
...@@ -294,10 +308,10 @@ class Project(Links, NamedModel, TimeStampedModel): ...@@ -294,10 +308,10 @@ class Project(Links, NamedModel, TimeStampedModel):
return images.order_by(Length('robotpkg__name').desc()).first() return images.order_by(Length('robotpkg__name').desc()).first()
def print_deps(self): def print_deps(self):
return mark_safe(', '.join(d.get_link() for d in self.dependencies.all())) return mark_safe(', '.join(d.library.get_link() for d in self.dependencies.all()))
def print_rdeps(self): def print_rdeps(self):
return mark_safe(', '.join(d.get_link() for d in self.rdeps.all())) return mark_safe(', '.join(d.project.get_link() for d in self.rdeps.all()))
class Repo(TimeStampedModel): class Repo(TimeStampedModel):
...@@ -763,6 +777,7 @@ class Dependency(models.Model): ...@@ -763,6 +777,7 @@ class Dependency(models.Model):
library = models.ForeignKey(Project, on_delete=models.CASCADE, related_name='rdeps') library = models.ForeignKey(Project, on_delete=models.CASCADE, related_name='rdeps')
robotpkg = models.BooleanField(default=False) # TODO NYI robotpkg = models.BooleanField(default=False) # TODO NYI
cmake = models.BooleanField(default=False) cmake = models.BooleanField(default=False)
ros = models.BooleanField(default=False)
class Meta: class Meta:
verbose_name_plural = 'dependencies' verbose_name_plural = 'dependencies'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment