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
|
# Copyright 2009 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
# pylint: disable-msg=E0611,W0212
"""Database class for ArchiveDependency."""
__metaclass__ = type
__all__ = ['ArchiveDependency']
from sqlobject import ForeignKey
from zope.interface import implements
from canonical.database.constants import UTC_NOW
from canonical.database.datetimecol import UtcDateTimeCol
from canonical.database.enumcol import EnumCol
from canonical.database.sqlbase import SQLBase
from lp.registry.interfaces.pocket import PackagePublishingPocket
from lp.soyuz.adapters.archivedependencies import component_dependencies
from lp.soyuz.interfaces.archivedependency import IArchiveDependency
class ArchiveDependency(SQLBase):
"""See `IArchiveDependency`."""
implements(IArchiveDependency)
_table = 'ArchiveDependency'
_defaultOrder = 'id'
date_created = UtcDateTimeCol(
dbName='date_created', notNull=True, default=UTC_NOW)
archive = ForeignKey(
foreignKey='Archive', dbName='archive', notNull=True)
dependency = ForeignKey(
foreignKey='Archive', dbName='dependency', notNull=True)
pocket = EnumCol(
dbName='pocket', notNull=True, schema=PackagePublishingPocket)
component = ForeignKey(
foreignKey='Component', dbName='component')
@property
def component_name(self):
"""See `IArchiveDependency`"""
if self.component:
return self.component.name
else:
return None
@property
def title(self):
"""See `IArchiveDependency`."""
if self.dependency.is_ppa:
return self.dependency.displayname
pocket_title = "%s - %s" % (
self.dependency.displayname, self.pocket.name)
if self.component is None:
return pocket_title
component_part = ", ".join(
component_dependencies[self.component.name])
return "%s (%s)" % (pocket_title, component_part)
|