~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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Copyright 2011 Canonical Ltd.  This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

# pylint: disable-msg=E0211,E0213

"""DistroSeriesParent interface."""

__metaclass__ = type

__all__ = [
    'IDistroSeriesParent',
    'IDistroSeriesParentSet',
    ]

from lazr.restful.fields import Reference
from zope.interface import Interface
from zope.schema import (
    Bool,
    Choice,
    Int,
    )

from canonical.launchpad import _
from lp.registry.interfaces.distroseries import IDistroSeries
from lp.registry.interfaces.pocket import PackagePublishingPocket


class IDistroSeriesParent(Interface):
    """`DistroSeriesParent` interface."""

    id = Int(title=_('ID'), required=True, readonly=True)

    derived_series = Reference(
        IDistroSeries, title=_("Derived Series"), required=True,
        description=_("The derived distribution series."))

    parent_series = Reference(
        IDistroSeries, title=_("Parent Series"), required=True,
        description=_("The parent distribution series."))

    initialized = Bool(
        title=_("Initialized"), required=True,
        description=_(
            "Whether or not the derived_series has been populated with "
            "packages from its parent_series."))

    is_overlay = Bool(
        title=_("Is this relationship an overlay?"), required=True,
        default=False)

    pocket = Choice(
        title=_("The pocket for this overlay"), required=False,
        vocabulary=PackagePublishingPocket)

    component = Choice(
        title=_("The component for this overlay"), required=False,
        vocabulary='Component')


class IDistroSeriesParentSet(Interface):
    """`DistroSeriesParentSet` interface."""

    def new(derived_series, parent_series, initialized, is_overlay=False,
            pocket=None, component=None):
        """Create a new `DistroSeriesParent`."""

    def getByDerivedSeries(derived_series):
        """Get the `DistroSeriesParent` by derived series.

        :param derived_series: An `IDistroseries`
        """

    def getByParentSeries(parent_series):
        """Get the `DistroSeriesParent` by parent series.

        :param parent_series: An `IDistroseries`
        """

    def getByDerivedAndParentSeries(self, derived_series, parent_series):
        """Get the `DistroSeriesParent` by derived and parent series.

        :param derived_series: The derived `IDistroseries`
        :param parent_series: The parent `IDistroseries`
        """

    def getFlattenedOverlayTree(derived_series):
        """Get the list of DistroSeriesParents corresponding to the
        flattened overlay tree.

        :param parent_series: An `IDistroseries`.
        :return: A list of `IDistroSeriesParents`.

        For instance, given the following structure:

                     series               type of relation:
                       |                    |           |
            -----------------------         |           o
            |          |          |         |           |
            o          o          |      no overlay  overlay
            |          |          |
        parent1    parent2    parent3

        The result would be:
        [dsp(series, parent1), dsp(series, parent2)]
        """