~launchpad-pqm/launchpad/devel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Copyright 2009 Canonical Ltd.  This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

__metaclass__ = type

__all__ = [
    'BinaryPackageReleaseNavigation',
    'BinaryPackageView',
    ]

from apt_pkg import parse_depends

from lp.services.webapp import Navigation
from lp.soyuz.browser.packagerelationship import relationship_builder
from lp.soyuz.interfaces.binarypackagerelease import IBinaryPackageRelease


class BinaryPackageReleaseNavigation(Navigation):
    usedfor = IBinaryPackageRelease


class BinaryPackageView:
    """View class for BinaryPackage"""

    def __init__(self, context, request):
        self.context = context
        self.request = request

    def _relationship_parser(self, content):
        """Wrap the relationship_builder for BinaryPackages.

        Define apt_pkg.ParseDep as a relationship 'parser' and
        IDistroArchSeries.getBinaryPackage as 'getter'.
        """
        getter = self.context.build.distro_arch_series.getBinaryPackage
        parser = parse_depends
        return relationship_builder(content, parser=parser, getter=getter)

    def depends(self):
        return self._relationship_parser(self.context.depends)

    def recommends(self):
        return self._relationship_parser(self.context.recommends)

    def conflicts(self):
        return self._relationship_parser(self.context.conflicts)

    def replaces(self):
        return self._relationship_parser(self.context.replaces)

    def suggests(self):
        return self._relationship_parser(self.context.suggests)

    def provides(self):
        return self._relationship_parser(self.context.provides)

    def pre_depends(self):
        return self._relationship_parser(self.context.pre_depends)

    def enhances(self):
        return self._relationship_parser(self.context.enhances)

    def breaks(self):
        return self._relationship_parser(self.context.breaks)