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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
# 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
"""Source package in Distribution interfaces."""
__metaclass__ = type
__all__ = [
'IDistributionSourcePackage',
]
from lazr.restful.declarations import (
export_as_webservice_entry,
export_operation_as,
export_read_operation,
exported,
operation_parameters,
operation_returns_collection_of,
rename_parameters_as,
)
from lazr.restful.fields import Reference
from zope.interface import (
Attribute,
Interface,
)
from zope.schema import (
Int,
TextLine,
)
from canonical.launchpad import _
from lp.answers.interfaces.questiontarget import IQuestionTarget
from lp.bugs.interfaces.bugtarget import (
IBugTarget,
IHasOfficialBugTags,
)
from lp.bugs.interfaces.bugtask import IBugTask
from lp.bugs.interfaces.structuralsubscription import (
IStructuralSubscriptionTarget,
)
from lp.code.interfaces.hasbranches import (
IHasBranches,
IHasMergeProposals,
)
from lp.registry.interfaces.distribution import IDistribution
from lp.registry.interfaces.role import IHasDrivers
from lp.soyuz.enums import ArchivePurpose
class IDistributionSourcePackage(IBugTarget, IHasBranches, IHasMergeProposals,
IHasOfficialBugTags,
IStructuralSubscriptionTarget,
IQuestionTarget, IHasDrivers):
"""Represents a source package in a distribution.
Create IDistributionSourcePackages by invoking
`IDistribution.getSourcePackage()`.
"""
export_as_webservice_entry()
distribution = exported(
Reference(IDistribution, title=_("The distribution.")))
sourcepackagename = Attribute("The source package name.")
name = exported(
TextLine(title=_("The source package name as text"), readonly=True))
displayname = exported(
TextLine(title=_("Display name for this package."), readonly=True),
exported_as="display_name")
title = exported(
TextLine(title=_("Title for this package."), readonly=True))
upstream_product = exported(
Reference(
title=_("The upstream product to which this package is linked."),
required=False,
readonly=True,
# This is really an IProduct but we get a circular import
# problem if we do that here. This is patched in
# interfaces/product.py.
schema=Interface))
is_official = Attribute(
'Is this source package officially in the distribution?')
summary = Attribute(
'The summary of binary packages built from this package')
binary_names = Attribute(
'A list of binary package names built from this package.')
currentrelease = Attribute(
"The latest published `IDistributionSourcePackageRelease` of a "
"source package with this name in the distribution or distroseries, "
"or None if no source package with that name is published in this "
"distroseries.")
releases = Attribute(
"The list of all releases of this source package "
"in this distribution.")
development_version = Attribute(
"The development version of this source package. 'None' if there is "
"no such package -- this occurs when there is no current series for "
"the distribution.")
total_bug_heat = Attribute(
"Sum of the bug heat for all the bugs matching the distribution "
"and sourcepackagename of the IDistributionSourcePackage.")
max_bug_heat = Attribute(
"Maximum bug heat for a single bug matching the distribution "
"and sourcepackagename of the IDistributionSourcePackage.")
bug_count = Attribute(
"Number of bugs matching the distribution and sourcepackagename "
"of the IDistributionSourcePackage.")
po_message_count = Attribute(
"Number of translations matching the distribution and "
"sourcepackagename of the IDistributionSourcePackage.")
drivers = Attribute("The drivers for the distribution.")
def getReleasesAndPublishingHistory():
"""Return a list of all releases of this source package in this
distribution and their corresponding publishing history.
Items in the list are tuples comprised of a
DistributionSourcePackage and a list of
SourcePackagePublishingHistory objects.
"""
publishing_history = Attribute(
"Return a list of publishing records for this source package in this "
"distribution.")
current_publishing_records = Attribute(
"Return a list of CURRENT publishing records for this source "
"package in this distribution.")
def getVersion(version):
"""Return the a DistributionSourcePackageRelease with the given
version, or None if there has never been a release with that
version in this distribution.
"""
def get_distroseries_packages(active_only=True):
"""Return a list of DistroSeriesSourcePackage objects, each
representing this same source package in the series of this
distribution.
By default, this will return SourcePackage's in active
distroseries only. You can set only_active=False to return a
source package for EVERY series where this source package was
published.
"""
def findRelatedArchives(exclude_archive=None,
archive_purpose=ArchivePurpose.PPA,
required_karma=0):
"""Return Archives which publish this source package.
:param exclude_archive: an archive to exclude from the results,
used to exclude the current context from which the method
is called.
:param archive_purpose: used to filter the results to certain
archive purposes. Defaults to PPA.
:param required_karma: if non-zero then the results will be
limited to archives where the creator of the related source
package release in that archive has karma greater than the
specified value.
:returns: A `ResultSet` of non-unique `IArchive` with the
results ordered by the descending package karma.
"""
latest_overall_publication = Attribute(
"""The latest publication for this package across its distribution.
The criteria for determining the publication are:
- Only PUBLISHED or OBSOLETE publications
- Only updates, security or release pockets
- PUBLISHED wins over OBSOLETE
- The latest distroseries wins
- updates > security > release
See https://bugs.launchpad.net/soyuz/+bug/236922 for a plan
on how this criteria will be centrally encoded.
""")
@rename_parameters_as(quantity='limit')
@operation_parameters(
quantity=Int(
title=_("The maximum number of bug tasks to return"),
min=1))
@operation_returns_collection_of(IBugTask)
@export_operation_as(name="getBugTasks")
@export_read_operation()
def bugtasks(quantity=None):
"""Bug tasks on this source package, sorted newest first.
If needed, you can limit the number of bugtasks you are interested
in using the quantity parameter.
"""
def __eq__(other):
"""IDistributionSourcePackage comparison method.
Distro sourcepackages compare equal only if their distribution and
sourcepackagename compare equal.
"""
def __ne__(other):
"""IDistributionSourcePackage comparison method.
Distro sourcepackages compare not equal if either of their
distribution or sourcepackagename compare not equal.
"""
def delete():
"""Delete the persistent DSP if it exists.
:return: True if a persistent object was removed, otherwise False.
"""
|