~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
# Copyright 2009 Canonical Ltd.  This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

# pylint: disable-msg=E0211,E0213

"""Component interfaces."""

__metaclass__ = type

__all__ = [
    'IComponent',
    'IComponentSelection',
    'IComponentSet',
    ]

from zope.interface import (
    Attribute,
    Interface,
    )
from zope.schema import Choice

from lp import _


class IComponent(Interface):
    """Represents the Component table.

    This class represents the Component table, which stores valid
    distribution components; for Ubuntu this means, for instance,
    'main', 'restricted', 'universe', etc.
    """
    id = Attribute("The ID")
    name = Choice(
        title=_("Component Name"), vocabulary="Component", required=True)


class IComponentSelection(Interface):
    """Represents a single component allowed within a DistroSeries."""
    id = Attribute("The ID")
    distroseries = Attribute("Target DistroSeries")
    component = Attribute("Selected Component")


class IComponentSet(Interface):
    """Set manipulation tools for the Component table."""

    def __iter__():
        """Iterate over components."""

    def __getitem__(name):
        """Retrieve a component by name"""

    def get(component_id):
        """Return the IComponent with the given component_id."""

    def ensure(name):
        """Ensure the existence of a component with given name."""

    def new(name):
        """Create a new component."""