Merge ~cjwatson/launchpad:stormify-sourcepackagename into launchpad:master
- Git
- lp:~cjwatson/launchpad
- stormify-sourcepackagename
- Merge into master
Proposed by
Colin Watson
Status: | Merged |
---|---|
Approved by: | Colin Watson |
Approved revision: | f5b65d896398afc16edae79256347805283c4416 |
Merge reported by: | Otto Co-Pilot |
Merged at revision: | not available |
Proposed branch: | ~cjwatson/launchpad:stormify-sourcepackagename |
Merge into: | launchpad:master |
Diff against target: |
907 lines (+164/-167) 20 files modified
lib/lp/archiveuploader/tests/test_uploadprocessor.py (+3/-8) lib/lp/registry/doc/distribution.rst (+4/-2) lib/lp/registry/doc/sourcepackage.rst (+2/-3) lib/lp/registry/interfaces/sourcepackagename.py (+1/-6) lib/lp/registry/model/distribution.py (+15/-16) lib/lp/registry/model/distroseries.py (+11/-11) lib/lp/registry/model/sourcepackage.py (+1/-1) lib/lp/registry/model/sourcepackagename.py (+33/-32) lib/lp/registry/vocabularies.py (+1/-1) lib/lp/soyuz/doc/gina-multiple-arch.rst (+10/-18) lib/lp/soyuz/doc/gina.rst (+43/-39) lib/lp/soyuz/doc/package-meta-classes.rst (+4/-2) lib/lp/soyuz/doc/sourcepackagerelease.rst (+4/-2) lib/lp/soyuz/doc/soyuz-upload.rst (+7/-5) lib/lp/soyuz/model/distroseriesdifferencejob.py (+3/-1) lib/lp/soyuz/scripts/gina/handlers.py (+5/-9) lib/lp/translations/doc/poexport-language-pack.rst (+4/-2) lib/lp/translations/doc/translationimportqueue.rst (+3/-1) lib/lp/translations/doc/translationsoverview.rst (+6/-2) lib/lp/translations/tests/test_autoapproval.py (+4/-6) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ines Almeida | Approve | ||
Review via email: mp+450323@code.launchpad.net |
Commit message
Convert SourcePackageName to Storm
Description of the change
`SourcePackageN
To post a comment you must log in.
- 7dd6fa6... by Colin Watson
-
Remove potemplates and packagings from interface too
- f5b65d8... by Colin Watson
-
Use set interfaces for xPN lookups
Revision history for this message
Colin Watson (cjwatson) wrote : | # |
I switched to `getUtility(
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/lib/lp/archiveuploader/tests/test_uploadprocessor.py b/lib/lp/archiveuploader/tests/test_uploadprocessor.py |
2 | index de16e04..95c1b8b 100644 |
3 | --- a/lib/lp/archiveuploader/tests/test_uploadprocessor.py |
4 | +++ b/lib/lp/archiveuploader/tests/test_uploadprocessor.py |
5 | @@ -51,7 +51,6 @@ from lp.registry.interfaces.pocket import PackagePublishingPocket |
6 | from lp.registry.interfaces.series import SeriesStatus |
7 | from lp.registry.interfaces.sourcepackage import SourcePackageFileType |
8 | from lp.registry.interfaces.sourcepackagename import ISourcePackageNameSet |
9 | -from lp.registry.model.sourcepackagename import SourcePackageName |
10 | from lp.services.config import config |
11 | from lp.services.database.constants import UTC_NOW |
12 | from lp.services.database.interfaces import IStore |
13 | @@ -68,6 +67,7 @@ from lp.soyuz.enums import ( |
14 | from lp.soyuz.interfaces.archive import IArchiveSet |
15 | from lp.soyuz.interfaces.archivepermission import IArchivePermissionSet |
16 | from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet |
17 | +from lp.soyuz.interfaces.binarypackagename import IBinaryPackageNameSet |
18 | from lp.soyuz.interfaces.component import IComponentSet |
19 | from lp.soyuz.interfaces.livefs import LIVEFS_FEATURE_FLAG |
20 | from lp.soyuz.interfaces.packageset import IPackagesetSet |
21 | @@ -80,7 +80,6 @@ from lp.soyuz.interfaces.sourcepackageformat import ( |
22 | ISourcePackageFormatSelectionSet, |
23 | ) |
24 | from lp.soyuz.model.archivepermission import ArchivePermission |
25 | -from lp.soyuz.model.binarypackagename import BinaryPackageName |
26 | from lp.soyuz.model.binarypackagerelease import BinaryPackageRelease |
27 | from lp.soyuz.model.publishing import ( |
28 | BinaryPackagePublishingHistory, |
29 | @@ -1096,7 +1095,7 @@ class TestUploadProcessor(StatsMixin, TestUploadProcessorBase): |
30 | self._checkPartnerUploadEmailSuccess() |
31 | |
32 | # Find the sourcepackagerelease and check its component. |
33 | - foocomm_name = SourcePackageName.selectOneBy(name="foocomm") |
34 | + foocomm_name = getUtility(ISourcePackageNameSet)["foocomm"] |
35 | foocomm_spr = ( |
36 | IStore(SourcePackageRelease) |
37 | .find(SourcePackageRelease, sourcepackagename=foocomm_name) |
38 | @@ -1162,11 +1161,7 @@ class TestUploadProcessor(StatsMixin, TestUploadProcessorBase): |
39 | self.processUpload(uploadprocessor, upload_dir) |
40 | |
41 | # Find the binarypackagerelease and check its component. |
42 | - foocomm_binname = ( |
43 | - IStore(BinaryPackageName) |
44 | - .find(BinaryPackageName, name="foocomm") |
45 | - .one() |
46 | - ) |
47 | + foocomm_binname = getUtility(IBinaryPackageNameSet)["foocomm"] |
48 | foocomm_bpr = ( |
49 | IStore(BinaryPackageRelease) |
50 | .find(BinaryPackageRelease, binarypackagename=foocomm_binname) |
51 | diff --git a/lib/lp/registry/doc/distribution.rst b/lib/lp/registry/doc/distribution.rst |
52 | index e618751..6ebdb59 100644 |
53 | --- a/lib/lp/registry/doc/distribution.rst |
54 | +++ b/lib/lp/registry/doc/distribution.rst |
55 | @@ -73,15 +73,17 @@ Let's make sure a distribution object properly implements its interfaces. |
56 | Once you've got a distribution, you can retrieve a source package if you |
57 | have a SourcePackageName object for it. |
58 | |
59 | - >>> from lp.registry.model.sourcepackagename import SourcePackageName |
60 | >>> from lp.registry.interfaces.distributionsourcepackage import ( |
61 | ... IDistributionSourcePackage, |
62 | ... ) |
63 | + >>> from lp.registry.interfaces.sourcepackagename import ( |
64 | + ... ISourcePackageNameSet, |
65 | + ... ) |
66 | >>> from lp.soyuz.interfaces.distributionsourcepackagerelease import ( |
67 | ... IDistributionSourcePackageRelease, |
68 | ... ) |
69 | |
70 | - >>> evo = SourcePackageName.byName("evolution") |
71 | + >>> evo = getUtility(ISourcePackageNameSet)["evolution"] |
72 | >>> evo_ubuntu = ubuntu.getSourcePackage(evo) |
73 | >>> print(evo_ubuntu.name) |
74 | evolution |
75 | diff --git a/lib/lp/registry/doc/sourcepackage.rst b/lib/lp/registry/doc/sourcepackage.rst |
76 | index 462d93f..ca27efe 100644 |
77 | --- a/lib/lp/registry/doc/sourcepackage.rst |
78 | +++ b/lib/lp/registry/doc/sourcepackage.rst |
79 | @@ -274,9 +274,8 @@ packaging process. Here we test the code that links all of those. |
80 | |
81 | First, let's get some useful objects from the db. |
82 | |
83 | - >>> from lp.registry.model.sourcepackagename import SourcePackageName |
84 | - >>> firefox = SourcePackageName.byName("mozilla-firefox") |
85 | - >>> pmount = SourcePackageName.byName("pmount") |
86 | + >>> firefox = sourcepackagenameset["mozilla-firefox"] |
87 | + >>> pmount = sourcepackagenameset["pmount"] |
88 | |
89 | >>> from lp.registry.model.distroseries import DistroSeries |
90 | >>> warty = DistroSeries.get(1) |
91 | diff --git a/lib/lp/registry/interfaces/sourcepackagename.py b/lib/lp/registry/interfaces/sourcepackagename.py |
92 | index 30c8b55..aabe44c 100644 |
93 | --- a/lib/lp/registry/interfaces/sourcepackagename.py |
94 | +++ b/lib/lp/registry/interfaces/sourcepackagename.py |
95 | @@ -8,7 +8,7 @@ __all__ = [ |
96 | "ISourcePackageNameSet", |
97 | ] |
98 | |
99 | -from zope.interface import Attribute, Interface |
100 | +from zope.interface import Interface |
101 | from zope.schema import Int, TextLine |
102 | |
103 | from lp import _ |
104 | @@ -28,11 +28,6 @@ class ISourcePackageName(Interface): |
105 | required=True, |
106 | constraint=name_validator, |
107 | ) |
108 | - potemplates = Attribute("The list of PO templates that this object has.") |
109 | - packagings = Attribute( |
110 | - "Everything we know about the packaging of " |
111 | - "packages with this source package name." |
112 | - ) |
113 | |
114 | def __str__(): |
115 | """Return the name""" |
116 | diff --git a/lib/lp/registry/model/distribution.py b/lib/lp/registry/model/distribution.py |
117 | index 81040cb..8abb04f 100644 |
118 | --- a/lib/lp/registry/model/distribution.py |
119 | +++ b/lib/lp/registry/model/distribution.py |
120 | @@ -124,7 +124,10 @@ from lp.registry.interfaces.pillar import IPillarNameSet |
121 | from lp.registry.interfaces.pocket import suffixpocket |
122 | from lp.registry.interfaces.role import IPersonRoles |
123 | from lp.registry.interfaces.series import SeriesStatus |
124 | -from lp.registry.interfaces.sourcepackagename import ISourcePackageName |
125 | +from lp.registry.interfaces.sourcepackagename import ( |
126 | + ISourcePackageName, |
127 | + ISourcePackageNameSet, |
128 | +) |
129 | from lp.registry.model.accesspolicy import AccessPolicyGrantFlat |
130 | from lp.registry.model.announcement import MakesAnnouncements |
131 | from lp.registry.model.commercialsubscription import CommercialSubscription |
132 | @@ -155,12 +158,7 @@ from lp.services.database.decoratedresultset import DecoratedResultSet |
133 | from lp.services.database.enumcol import DBEnum |
134 | from lp.services.database.interfaces import IStore |
135 | from lp.services.database.sqlbase import SQLBase, sqlvalues |
136 | -from lp.services.database.sqlobject import ( |
137 | - BoolCol, |
138 | - ForeignKey, |
139 | - SQLObjectNotFound, |
140 | - StringCol, |
141 | -) |
142 | +from lp.services.database.sqlobject import BoolCol, ForeignKey, StringCol |
143 | from lp.services.database.stormexpr import ( |
144 | ArrayAgg, |
145 | ArrayIntersects, |
146 | @@ -183,10 +181,10 @@ from lp.soyuz.enums import ( |
147 | from lp.soyuz.interfaces.archive import MAIN_ARCHIVE_PURPOSES, IArchiveSet |
148 | from lp.soyuz.interfaces.archivepermission import IArchivePermissionSet |
149 | from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet |
150 | +from lp.soyuz.interfaces.binarypackagename import IBinaryPackageNameSet |
151 | from lp.soyuz.interfaces.publishing import active_publishing_status |
152 | from lp.soyuz.model.archive import Archive |
153 | from lp.soyuz.model.archivefile import ArchiveFile |
154 | -from lp.soyuz.model.binarypackagename import BinaryPackageName |
155 | from lp.soyuz.model.distributionsourcepackagerelease import ( |
156 | DistributionSourcePackageRelease, |
157 | ) |
158 | @@ -1358,9 +1356,10 @@ class Distribution( |
159 | if ISourcePackageName.providedBy(name): |
160 | sourcepackagename = name |
161 | else: |
162 | - try: |
163 | - sourcepackagename = SourcePackageName.byName(name) |
164 | - except SQLObjectNotFound: |
165 | + sourcepackagename = getUtility(ISourcePackageNameSet).queryByName( |
166 | + name |
167 | + ) |
168 | + if sourcepackagename is None: |
169 | return None |
170 | return DistributionSourcePackage(self, sourcepackagename) |
171 | |
172 | @@ -1748,7 +1747,9 @@ class Distribution( |
173 | "published in it" % (self.displayname, pkgname) |
174 | ) |
175 | |
176 | - sourcepackagename = SourcePackageName.selectOneBy(name=pkgname) |
177 | + sourcepackagename = getUtility(ISourcePackageNameSet).queryByName( |
178 | + pkgname |
179 | + ) |
180 | if sourcepackagename: |
181 | # Note that in the source package case, we don't restrict |
182 | # the search to the distribution release, making a best |
183 | @@ -1789,10 +1790,8 @@ class Distribution( |
184 | # At this point we don't have a published source package by |
185 | # that name, so let's try to find a binary package and work |
186 | # back from there. |
187 | - binarypackagename = ( |
188 | - IStore(BinaryPackageName) |
189 | - .find(BinaryPackageName, name=pkgname) |
190 | - .one() |
191 | + binarypackagename = getUtility(IBinaryPackageNameSet).queryByName( |
192 | + pkgname |
193 | ) |
194 | if binarypackagename: |
195 | # Ok, so we have a binarypackage with that name. Grab its |
196 | diff --git a/lib/lp/registry/model/distroseries.py b/lib/lp/registry/model/distroseries.py |
197 | index db6564b..2b43af8 100644 |
198 | --- a/lib/lp/registry/model/distroseries.py |
199 | +++ b/lib/lp/registry/model/distroseries.py |
200 | @@ -56,7 +56,10 @@ from lp.registry.interfaces.person import validate_public_person |
201 | from lp.registry.interfaces.pocket import PackagePublishingPocket, pocketsuffix |
202 | from lp.registry.interfaces.series import SeriesStatus |
203 | from lp.registry.interfaces.sourcepackage import ISourcePackageFactory |
204 | -from lp.registry.interfaces.sourcepackagename import ISourcePackageName |
205 | +from lp.registry.interfaces.sourcepackagename import ( |
206 | + ISourcePackageName, |
207 | + ISourcePackageNameSet, |
208 | +) |
209 | from lp.registry.model.milestone import HasMilestonesMixin, Milestone |
210 | from lp.registry.model.packaging import Packaging |
211 | from lp.registry.model.person import Person |
212 | @@ -73,7 +76,6 @@ from lp.services.database.sqlobject import ( |
213 | BoolCol, |
214 | ForeignKey, |
215 | IntCol, |
216 | - SQLObjectNotFound, |
217 | StringCol, |
218 | ) |
219 | from lp.services.database.stormexpr import WithMaterialized, fti_search |
220 | @@ -89,7 +91,10 @@ from lp.soyuz.enums import ( |
221 | PackageUploadStatus, |
222 | ) |
223 | from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet |
224 | -from lp.soyuz.interfaces.binarypackagename import IBinaryPackageName |
225 | +from lp.soyuz.interfaces.binarypackagename import ( |
226 | + IBinaryPackageName, |
227 | + IBinaryPackageNameSet, |
228 | +) |
229 | from lp.soyuz.interfaces.distributionjob import ( |
230 | IInitializeDistroSeriesJobSource, |
231 | ) |
232 | @@ -1042,9 +1047,8 @@ class DistroSeries( |
233 | def getSourcePackage(self, name): |
234 | """See `IDistroSeries`.""" |
235 | if not ISourcePackageName.providedBy(name): |
236 | - try: |
237 | - name = SourcePackageName.byName(name) |
238 | - except SQLObjectNotFound: |
239 | + name = getUtility(ISourcePackageNameSet).queryByName(name) |
240 | + if name is None: |
241 | return None |
242 | return getUtility(ISourcePackageFactory).new( |
243 | sourcepackagename=name, distroseries=self |
244 | @@ -1053,11 +1057,7 @@ class DistroSeries( |
245 | def getBinaryPackage(self, name): |
246 | """See `IDistroSeries`.""" |
247 | if not IBinaryPackageName.providedBy(name): |
248 | - name = ( |
249 | - IStore(BinaryPackageName) |
250 | - .find(BinaryPackageName, name=name) |
251 | - .one() |
252 | - ) |
253 | + name = getUtility(IBinaryPackageNameSet).queryByName(name) |
254 | if name is None: |
255 | return None |
256 | return DistroSeriesBinaryPackage(self, name) |
257 | diff --git a/lib/lp/registry/model/sourcepackage.py b/lib/lp/registry/model/sourcepackage.py |
258 | index 329e692..c15b371 100644 |
259 | --- a/lib/lp/registry/model/sourcepackage.py |
260 | +++ b/lib/lp/registry/model/sourcepackage.py |
261 | @@ -666,7 +666,7 @@ class SourcePackage( |
262 | SourcePackagePublishingHistory.archive = BinaryPackageBuild.archive |
263 | """ |
264 | % sqlvalues( |
265 | - self.sourcepackagename, |
266 | + self.sourcepackagename.id, |
267 | self.distroseries, |
268 | list(self.distribution.all_distro_archive_ids), |
269 | ) |
270 | diff --git a/lib/lp/registry/model/sourcepackagename.py b/lib/lp/registry/model/sourcepackagename.py |
271 | index 37974b0..fbb3598 100644 |
272 | --- a/lib/lp/registry/model/sourcepackagename.py |
273 | +++ b/lib/lp/registry/model/sourcepackagename.py |
274 | @@ -7,7 +7,7 @@ __all__ = [ |
275 | "getSourcePackageDescriptions", |
276 | ] |
277 | |
278 | -import six |
279 | +from storm.properties import Int, Unicode |
280 | from zope.interface import implementer |
281 | |
282 | from lp.app.errors import NotFoundError |
283 | @@ -17,26 +17,21 @@ from lp.registry.interfaces.sourcepackagename import ( |
284 | ISourcePackageName, |
285 | ISourcePackageNameSet, |
286 | ) |
287 | -from lp.services.database.sqlbase import SQLBase, cursor, sqlvalues |
288 | -from lp.services.database.sqlobject import ( |
289 | - SQLMultipleJoin, |
290 | - SQLObjectNotFound, |
291 | - StringCol, |
292 | -) |
293 | +from lp.services.database.interfaces import IStore |
294 | +from lp.services.database.sqlbase import cursor, sqlvalues |
295 | +from lp.services.database.stormbase import StormBase |
296 | |
297 | |
298 | @implementer(ISourcePackageName) |
299 | -class SourcePackageName(SQLBase): |
300 | - _table = "SourcePackageName" |
301 | +class SourcePackageName(StormBase): |
302 | + __storm_table__ = "SourcePackageName" |
303 | |
304 | - name = StringCol( |
305 | - dbName="name", notNull=True, unique=True, alternateID=True |
306 | - ) |
307 | + id = Int(primary=True) |
308 | + name = Unicode(name="name", allow_none=False) |
309 | |
310 | - potemplates = SQLMultipleJoin("POTemplate", joinColumn="sourcepackagename") |
311 | - packagings = SQLMultipleJoin( |
312 | - "Packaging", joinColumn="sourcepackagename", orderBy="Packaging.id" |
313 | - ) |
314 | + def __init__(self, name): |
315 | + super().__init__() |
316 | + self.name = name |
317 | |
318 | def __str__(self): |
319 | return self.name |
320 | @@ -44,46 +39,52 @@ class SourcePackageName(SQLBase): |
321 | def __repr__(self): |
322 | return "<%s '%s'>" % (self.__class__.__name__, self.name) |
323 | |
324 | + @classmethod |
325 | def ensure(klass, name): |
326 | - try: |
327 | - return klass.byName(name) |
328 | - except SQLObjectNotFound: |
329 | - return klass(name=name) |
330 | - |
331 | - ensure = classmethod(ensure) |
332 | + spn = IStore(klass).find(klass, name=name).one() |
333 | + if spn is None: |
334 | + spn = klass(name=name) |
335 | + return spn |
336 | |
337 | |
338 | @implementer(ISourcePackageNameSet) |
339 | class SourcePackageNameSet: |
340 | def __getitem__(self, name): |
341 | """See `ISourcePackageNameSet`.""" |
342 | - name = six.ensure_text(name, "ASCII") |
343 | - try: |
344 | - return SourcePackageName.byName(name) |
345 | - except SQLObjectNotFound: |
346 | + spn = self.queryByName(name) |
347 | + if spn is None: |
348 | raise NoSuchSourcePackageName(name) |
349 | + return spn |
350 | |
351 | def get(self, sourcepackagenameid): |
352 | """See `ISourcePackageNameSet`.""" |
353 | - try: |
354 | - return SourcePackageName.get(sourcepackagenameid) |
355 | - except SQLObjectNotFound: |
356 | + spn = IStore(SourcePackageName).get( |
357 | + SourcePackageName, sourcepackagenameid |
358 | + ) |
359 | + if spn is None: |
360 | raise NotFoundError(sourcepackagenameid) |
361 | + return spn |
362 | |
363 | def getAll(self): |
364 | """See `ISourcePackageNameSet`.""" |
365 | - return SourcePackageName.select() |
366 | + return IStore(SourcePackageName).find(SourcePackageName) |
367 | |
368 | def queryByName(self, name): |
369 | """See `ISourcePackageNameSet`.""" |
370 | - return SourcePackageName.selectOneBy(name=name) |
371 | + return ( |
372 | + IStore(SourcePackageName).find(SourcePackageName, name=name).one() |
373 | + ) |
374 | |
375 | def new(self, name): |
376 | if not valid_name(name): |
377 | raise InvalidName( |
378 | "%s is not a valid name for a source package." % name |
379 | ) |
380 | - return SourcePackageName(name=name) |
381 | + spn = SourcePackageName(name=name) |
382 | + store = IStore(SourcePackageName) |
383 | + store.add(spn) |
384 | + store.flush() |
385 | + return spn |
386 | |
387 | def getOrCreateByName(self, name): |
388 | try: |
389 | diff --git a/lib/lp/registry/vocabularies.py b/lib/lp/registry/vocabularies.py |
390 | index e8932cd..955e975 100644 |
391 | --- a/lib/lp/registry/vocabularies.py |
392 | +++ b/lib/lp/registry/vocabularies.py |
393 | @@ -2122,7 +2122,7 @@ class SourcePackageNameVocabulary(NamedStormHugeVocabulary): |
394 | if not query: |
395 | return self.emptySelectResults() |
396 | |
397 | - query = six.ensure_text(query).lower() |
398 | + query = query.lower() |
399 | results = IStore(self._table).find( |
400 | self._table, |
401 | Or( |
402 | diff --git a/lib/lp/soyuz/doc/gina-multiple-arch.rst b/lib/lp/soyuz/doc/gina-multiple-arch.rst |
403 | index 5f6c56b..2c9f06b 100644 |
404 | --- a/lib/lp/soyuz/doc/gina-multiple-arch.rst |
405 | +++ b/lib/lp/soyuz/doc/gina-multiple-arch.rst |
406 | @@ -176,9 +176,13 @@ distroarchseries: |
407 | |
408 | Check that the source package was correctly imported: |
409 | |
410 | - >>> from lp.soyuz.model.binarypackagename import BinaryPackageName |
411 | - >>> from lp.registry.model.sourcepackagename import SourcePackageName |
412 | - >>> ekg_name = SourcePackageName.selectOneBy(name="ekg") |
413 | + >>> from lp.registry.interfaces.sourcepackagename import ( |
414 | + ... ISourcePackageNameSet, |
415 | + ... ) |
416 | + >>> from lp.soyuz.interfaces.binarypackagename import ( |
417 | + ... IBinaryPackageNameSet, |
418 | + ... ) |
419 | + >>> ekg_name = getUtility(ISourcePackageNameSet)["ekg"] |
420 | >>> ekg = ( |
421 | ... IStore(SourcePackageRelease) |
422 | ... .find( |
423 | @@ -195,11 +199,7 @@ Check that the source package was correctly imported: |
424 | |
425 | And that one of the packages in main is here too: |
426 | |
427 | - >>> libgadu_dev_name = ( |
428 | - ... IStore(BinaryPackageName) |
429 | - ... .find(BinaryPackageName, name="libgadu-dev") |
430 | - ... .one() |
431 | - ... ) |
432 | + >>> libgadu_dev_name = getUtility(IBinaryPackageNameSet)["libgadu-dev"] |
433 | >>> libgadu_dev = ( |
434 | ... IStore(BinaryPackageRelease) |
435 | ... .find( |
436 | @@ -223,11 +223,7 @@ processed. In particular, its section should be stripped of the |
437 | component name. |
438 | |
439 | >>> from lp.soyuz.enums import PackagePublishingPriority |
440 | - >>> ekg_name = ( |
441 | - ... IStore(BinaryPackageName) |
442 | - ... .find(BinaryPackageName, name="ekg") |
443 | - ... .one() |
444 | - ... ) |
445 | + >>> ekg_name = getUtility(IBinaryPackageNameSet)["ekg"] |
446 | >>> ekg = ( |
447 | ... IStore(BinaryPackageRelease) |
448 | ... .find( |
449 | @@ -250,11 +246,7 @@ package files are in main! Gina to the rescue: it finds them in the |
450 | right place, updates the component, and creates it with a semi-bogus |
451 | DSC. |
452 | |
453 | - >>> bdftopcf_name = ( |
454 | - ... IStore(BinaryPackageName) |
455 | - ... .find(BinaryPackageName, name="bdftopcf") |
456 | - ... .one() |
457 | - ... ) |
458 | + >>> bdftopcf_name = getUtility(IBinaryPackageNameSet)["bdftopcf"] |
459 | >>> bdftopcf = ( |
460 | ... IStore(BinaryPackageRelease) |
461 | ... .find( |
462 | diff --git a/lib/lp/soyuz/doc/gina.rst b/lib/lp/soyuz/doc/gina.rst |
463 | index b48d787..aac6267 100644 |
464 | --- a/lib/lp/soyuz/doc/gina.rst |
465 | +++ b/lib/lp/soyuz/doc/gina.rst |
466 | @@ -244,13 +244,15 @@ forcefully (ubuntu-meta). |
467 | |
468 | Check that x11proto-damage has its Build-Depends-Indep value correctly set: |
469 | |
470 | - >>> from lp.registry.model.sourcepackagename import SourcePackageName |
471 | - >>> n = SourcePackageName.selectOneBy(name="x11proto-damage") |
472 | + >>> from lp.registry.interfaces.sourcepackagename import ( |
473 | + ... ISourcePackageNameSet, |
474 | + ... ) |
475 | + >>> x11p_name = getUtility(ISourcePackageNameSet)["x11proto-damage"] |
476 | >>> x11p = ( |
477 | ... IStore(SourcePackageRelease) |
478 | ... .find( |
479 | ... SourcePackageRelease, |
480 | - ... sourcepackagename=n, |
481 | + ... sourcepackagename=x11p_name, |
482 | ... version="6.8.99.7-2", |
483 | ... ) |
484 | ... .one() |
485 | @@ -302,10 +304,10 @@ Same for the copyright: |
486 | Check that the dsc on the libcap package is correct, and that we |
487 | only imported one: |
488 | |
489 | - >>> n = SourcePackageName.selectOneBy(name="libcap") |
490 | + >>> cap_name = getUtility(ISourcePackageNameSet)["libcap"] |
491 | >>> cap = ( |
492 | ... IStore(SourcePackageRelease) |
493 | - ... .find(SourcePackageRelease, sourcepackagename=n) |
494 | + ... .find(SourcePackageRelease, sourcepackagename=cap_name) |
495 | ... .one() |
496 | ... ) |
497 | >>> print(cap.dsc) |
498 | @@ -338,10 +340,14 @@ only imported one: |
499 | |
500 | Test ubuntu-meta in breezy, which was forcefully imported. |
501 | |
502 | - >>> n = SourcePackageName.selectOneBy(name="ubuntu-meta") |
503 | + >>> um_name = getUtility(ISourcePackageNameSet)["ubuntu-meta"] |
504 | >>> um = ( |
505 | ... IStore(SourcePackageRelease) |
506 | - ... .find(SourcePackageRelease, sourcepackagename=n, version="0.80") |
507 | + ... .find( |
508 | + ... SourcePackageRelease, |
509 | + ... sourcepackagename=um_name, |
510 | + ... version="0.80", |
511 | + ... ) |
512 | ... .one() |
513 | ... ) |
514 | >>> print( |
515 | @@ -370,10 +376,10 @@ were calculated directly on the files): |
516 | Check that the section on the python-pam package is correct, and that we |
517 | only imported one: |
518 | |
519 | - >>> n = SourcePackageName.selectOneBy(name="python-pam") |
520 | + >>> pp_name = getUtility(ISourcePackageNameSet)["python-pam"] |
521 | >>> pp = ( |
522 | ... IStore(SourcePackageRelease) |
523 | - ... .find(SourcePackageRelease, sourcepackagename=n) |
524 | + ... .find(SourcePackageRelease, sourcepackagename=pp_name) |
525 | ... .one() |
526 | ... ) |
527 | >>> print(pp.component.name) |
528 | @@ -387,10 +393,10 @@ this is cut up correctly: |
529 | |
530 | Make sure that we only imported one db1-compat source package. |
531 | |
532 | - >>> n = SourcePackageName.selectOneBy(name="db1-compat") |
533 | + >>> db1_name = getUtility(ISourcePackageNameSet)["db1-compat"] |
534 | >>> db1 = ( |
535 | ... IStore(SourcePackageRelease) |
536 | - ... .find(SourcePackageRelease, sourcepackagename=n) |
537 | + ... .find(SourcePackageRelease, sourcepackagename=db1_name) |
538 | ... .one() |
539 | ... ) |
540 | >>> print(db1.section.name) |
541 | @@ -468,15 +474,13 @@ work. |
542 | Check that the shlibs parsing and bin-only-NMU version handling works as |
543 | expected: |
544 | |
545 | - >>> from lp.soyuz.model.binarypackagename import BinaryPackageName |
546 | - >>> n = ( |
547 | - ... IStore(BinaryPackageName) |
548 | - ... .find(BinaryPackageName, name="rioutil") |
549 | - ... .one() |
550 | + >>> from lp.soyuz.interfaces.binarypackagename import ( |
551 | + ... IBinaryPackageNameSet, |
552 | ... ) |
553 | + >>> rio_name = getUtility(IBinaryPackageNameSet)["rioutil"] |
554 | >>> rio = ( |
555 | ... IStore(BinaryPackageRelease) |
556 | - ... .find(BinaryPackageRelease, binarypackagename=n) |
557 | + ... .find(BinaryPackageRelease, binarypackagename=rio_name) |
558 | ... .one() |
559 | ... ) |
560 | >>> print(rio.shlibdeps) |
561 | @@ -489,10 +493,10 @@ expected: |
562 | Test all the data got to the ed BPR intact, and that the missing |
563 | priority was correctly munged to "extra": |
564 | |
565 | - >>> n = IStore(BinaryPackageName).find(BinaryPackageName, name="ed").one() |
566 | + >>> ed_name = getUtility(IBinaryPackageNameSet)["ed"] |
567 | >>> ed = ( |
568 | ... IStore(BinaryPackageRelease) |
569 | - ... .find(BinaryPackageRelease, binarypackagename=n) |
570 | + ... .find(BinaryPackageRelease, binarypackagename=ed_name) |
571 | ... .one() |
572 | ... ) |
573 | >>> print(ed.version) |
574 | @@ -527,15 +531,13 @@ We now check if the Breezy publication record has the correct priority: |
575 | Check binary package libgjc-dev in Breezy. Its version number must differ from |
576 | its source version number. |
577 | |
578 | - >>> n = ( |
579 | - ... IStore(BinaryPackageName) |
580 | - ... .find(BinaryPackageName, name="libgcj-dev") |
581 | - ... .one() |
582 | - ... ) |
583 | + >>> lib_name = getUtility(IBinaryPackageNameSet)["libgcj-dev"] |
584 | >>> lib = ( |
585 | ... IStore(BinaryPackageRelease) |
586 | ... .find( |
587 | - ... BinaryPackageRelease, binarypackagename=n, version="4:4.0.1-3" |
588 | + ... BinaryPackageRelease, |
589 | + ... binarypackagename=lib_name, |
590 | + ... version="4:4.0.1-3", |
591 | ... ) |
592 | ... .one() |
593 | ... ) |
594 | @@ -548,14 +550,14 @@ its source version number. |
595 | |
596 | Check if the udeb was properly parsed and identified: |
597 | |
598 | - >>> n = ( |
599 | - ... IStore(BinaryPackageName) |
600 | - ... .find(BinaryPackageName, name="archive-copier") |
601 | - ... .one() |
602 | - ... ) |
603 | + >>> ac_name = getUtility(IBinaryPackageNameSet)["archive-copier"] |
604 | >>> ac = ( |
605 | ... IStore(BinaryPackageRelease) |
606 | - ... .find(BinaryPackageRelease, binarypackagename=n, version="0.1.5") |
607 | + ... .find( |
608 | + ... BinaryPackageRelease, |
609 | + ... binarypackagename=ac_name, |
610 | + ... version="0.1.5", |
611 | + ... ) |
612 | ... .one() |
613 | ... ) |
614 | >>> print(ac.version) |
615 | @@ -573,15 +575,13 @@ Check if the udeb was properly parsed and identified: |
616 | |
617 | We check that the binary package publishing override facility works: |
618 | |
619 | - >>> n = ( |
620 | - ... IStore(BinaryPackageName) |
621 | - ... .find(BinaryPackageName, name="libdb1-compat") |
622 | - ... .one() |
623 | - ... ) |
624 | + >>> db1_name = getUtility(IBinaryPackageNameSet)["libdb1-compat"] |
625 | >>> db1 = ( |
626 | ... IStore(BinaryPackageRelease) |
627 | ... .find( |
628 | - ... BinaryPackageRelease, binarypackagename=n, version="2.1.3-7" |
629 | + ... BinaryPackageRelease, |
630 | + ... binarypackagename=db1_name, |
631 | + ... version="2.1.3-7", |
632 | ... ) |
633 | ... .one() |
634 | ... ) |
635 | @@ -774,10 +774,14 @@ package -- that's what overrides actually do. |
636 | ... ) |
637 | >>> print(ed_pub.priority) |
638 | Extra |
639 | - >>> n = SourcePackageName.selectOneBy(name="archive-copier") |
640 | + >>> ac_name = getUtility(ISourcePackageNameSet)["archive-copier"] |
641 | >>> ac = ( |
642 | ... IStore(SourcePackageRelease) |
643 | - ... .find(SourcePackageRelease, sourcepackagename=n, version="0.3.6") |
644 | + ... .find( |
645 | + ... SourcePackageRelease, |
646 | + ... sourcepackagename=ac_name, |
647 | + ... version="0.3.6", |
648 | + ... ) |
649 | ... .one() |
650 | ... ) |
651 | >>> ac_pub = ( |
652 | diff --git a/lib/lp/soyuz/doc/package-meta-classes.rst b/lib/lp/soyuz/doc/package-meta-classes.rst |
653 | index 62cc13b..3e39f54 100644 |
654 | --- a/lib/lp/soyuz/doc/package-meta-classes.rst |
655 | +++ b/lib/lp/soyuz/doc/package-meta-classes.rst |
656 | @@ -4,8 +4,10 @@ Package Meta Classes |
657 | There are a bunch of meta classes used for combine information from |
658 | our Database Model for packages in a intuitive manner, they are: |
659 | |
660 | + >>> from lp.registry.interfaces.sourcepackagename import ( |
661 | + ... ISourcePackageNameSet, |
662 | + ... ) |
663 | >>> from lp.registry.model.distribution import Distribution |
664 | - >>> from lp.registry.model.sourcepackagename import SourcePackageName |
665 | >>> from lp.services.database.interfaces import IStore |
666 | >>> from lp.soyuz.model.distributionsourcepackagerelease import ( |
667 | ... DistributionSourcePackageRelease, |
668 | @@ -26,7 +28,7 @@ Combining Distribution and SourcePackageRelease: |
669 | >>> print(distribution.name) |
670 | ubuntu |
671 | |
672 | - >>> src_name = SourcePackageName.selectOneBy(name="pmount") |
673 | + >>> src_name = getUtility(ISourcePackageNameSet)["pmount"] |
674 | >>> print(src_name.name) |
675 | pmount |
676 | |
677 | diff --git a/lib/lp/soyuz/doc/sourcepackagerelease.rst b/lib/lp/soyuz/doc/sourcepackagerelease.rst |
678 | index f68e146..2eb4b7b 100644 |
679 | --- a/lib/lp/soyuz/doc/sourcepackagerelease.rst |
680 | +++ b/lib/lp/soyuz/doc/sourcepackagerelease.rst |
681 | @@ -237,8 +237,10 @@ kilo-bytes). |
682 | |
683 | Verify that empty packages have a size of zero. |
684 | |
685 | - >>> from lp.registry.model.sourcepackagename import SourcePackageName |
686 | - >>> linux_src = SourcePackageName.selectOneBy(name="linux-source-2.6.15") |
687 | + >>> from lp.registry.interfaces.sourcepackagename import ( |
688 | + ... ISourcePackageNameSet, |
689 | + ... ) |
690 | + >>> linux_src = getUtility(ISourcePackageNameSet)["linux-source-2.6.15"] |
691 | >>> spr = ( |
692 | ... IStore(SourcePackageRelease) |
693 | ... .find( |
694 | diff --git a/lib/lp/soyuz/doc/soyuz-upload.rst b/lib/lp/soyuz/doc/soyuz-upload.rst |
695 | index 9413550..ac4512d 100644 |
696 | --- a/lib/lp/soyuz/doc/soyuz-upload.rst |
697 | +++ b/lib/lp/soyuz/doc/soyuz-upload.rst |
698 | @@ -325,10 +325,12 @@ Now continue with the real upload. |
699 | Let's check if packages were uploaded correctly. |
700 | |
701 | >>> from operator import attrgetter |
702 | - >>> from lp.registry.model.sourcepackagename import SourcePackageName |
703 | + >>> from lp.registry.interfaces.sourcepackagename import ( |
704 | + ... ISourcePackageNameSet, |
705 | + ... ) |
706 | >>> from lp.services.database.interfaces import IStore |
707 | >>> from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease |
708 | - >>> spn = SourcePackageName.selectOneBy(name="drdsl") |
709 | + >>> spn = getUtility(ISourcePackageNameSet)["drdsl"] |
710 | >>> print(spn.name) |
711 | drdsl |
712 | >>> spr = ( |
713 | @@ -364,7 +366,7 @@ Let's check if packages were uploaded correctly. |
714 | |
715 | Same thing for etherwake: |
716 | |
717 | - >>> spn = SourcePackageName.selectOneBy(name="etherwake") |
718 | + >>> spn = getUtility(ISourcePackageNameSet)["etherwake"] |
719 | >>> print(spn.name) |
720 | etherwake |
721 | >>> spr = ( |
722 | @@ -434,7 +436,7 @@ as NEW and RELEASE. |
723 | >>> from lp.soyuz.model.queue import PackageUploadSource |
724 | >>> for name in package_names: |
725 | ... print(name) |
726 | - ... spn = SourcePackageName.selectOneBy(name=name) |
727 | + ... spn = getUtility(ISourcePackageNameSet)[name] |
728 | ... spr = ( |
729 | ... IStore(SourcePackageRelease) |
730 | ... .find(SourcePackageRelease, sourcepackagename=spn) |
731 | @@ -508,7 +510,7 @@ These packages must now be in the publishing history. Let's check it. |
732 | ... ) |
733 | >>> package_names.sort() |
734 | >>> for name in package_names: |
735 | - ... spn = SourcePackageName.selectOneBy(name=name) |
736 | + ... spn = getUtility(ISourcePackageNameSet)[name] |
737 | ... spr = ( |
738 | ... IStore(SourcePackageRelease) |
739 | ... .find(SourcePackageRelease, sourcepackagename=spn) |
740 | diff --git a/lib/lp/soyuz/model/distroseriesdifferencejob.py b/lib/lp/soyuz/model/distroseriesdifferencejob.py |
741 | index d1e73f5..6b1faae 100644 |
742 | --- a/lib/lp/soyuz/model/distroseriesdifferencejob.py |
743 | +++ b/lib/lp/soyuz/model/distroseriesdifferencejob.py |
744 | @@ -271,7 +271,9 @@ class DistroSeriesDifferenceJob(DistributionJobDerived): |
745 | |
746 | @property |
747 | def sourcepackagename(self): |
748 | - return SourcePackageName.get(self.metadata["sourcepackagename"]) |
749 | + return IStore(SourcePackageName).get( |
750 | + SourcePackageName, self.metadata["sourcepackagename"] |
751 | + ) |
752 | |
753 | @property |
754 | def derived_series(self): |
755 | diff --git a/lib/lp/soyuz/scripts/gina/handlers.py b/lib/lp/soyuz/scripts/gina/handlers.py |
756 | index 37ae1f7..8d07ea7 100644 |
757 | --- a/lib/lp/soyuz/scripts/gina/handlers.py |
758 | +++ b/lib/lp/soyuz/scripts/gina/handlers.py |
759 | @@ -35,12 +35,12 @@ from lp.archiveuploader.utils import determine_binary_file_type |
760 | from lp.buildmaster.enums import BuildStatus |
761 | from lp.registry.interfaces.person import IPersonSet, PersonCreationRationale |
762 | from lp.registry.interfaces.sourcepackage import SourcePackageType |
763 | +from lp.registry.interfaces.sourcepackagename import ISourcePackageNameSet |
764 | from lp.registry.model.distribution import Distribution |
765 | from lp.registry.model.distroseries import DistroSeries |
766 | from lp.registry.model.sourcepackagename import SourcePackageName |
767 | from lp.services.database.constants import UTC_NOW |
768 | from lp.services.database.interfaces import IStore |
769 | -from lp.services.database.sqlobject import SQLObjectNotFound |
770 | from lp.services.librarian.interfaces import ILibraryFileAliasSet |
771 | from lp.services.scripts import log |
772 | from lp.soyuz.enums import ( |
773 | @@ -61,7 +61,6 @@ from lp.soyuz.interfaces.publishing import ( |
774 | ) |
775 | from lp.soyuz.interfaces.section import ISectionSet |
776 | from lp.soyuz.model.binarypackagebuild import BinaryPackageBuild |
777 | -from lp.soyuz.model.binarypackagename import BinaryPackageName |
778 | from lp.soyuz.model.binarypackagerelease import BinaryPackageRelease |
779 | from lp.soyuz.model.distroarchseries import DistroArchSeries |
780 | from lp.soyuz.model.files import BinaryPackageFile |
781 | @@ -592,9 +591,8 @@ class SourcePackageHandler: |
782 | |
783 | Returns the sourcepackagerelease if exists or none if not. |
784 | """ |
785 | - try: |
786 | - spname = SourcePackageName.byName(source) |
787 | - except SQLObjectNotFound: |
788 | + spname = getUtility(ISourcePackageNameSet).queryByName(source) |
789 | + if spname is None: |
790 | return None |
791 | |
792 | # Check if this sourcepackagerelease already exists using name and |
793 | @@ -811,10 +809,8 @@ class BinaryPackageHandler: |
794 | |
795 | def checkBin(self, binarypackagedata, distroarchseries): |
796 | """Returns a binarypackage -- if it exists.""" |
797 | - binaryname = ( |
798 | - IStore(BinaryPackageName) |
799 | - .find(BinaryPackageName, name=binarypackagedata.package) |
800 | - .one() |
801 | + binaryname = getUtility(IBinaryPackageNameSet).queryByName( |
802 | + binarypackagedata.package |
803 | ) |
804 | if binaryname is None: |
805 | # If the binary package's name doesn't exist, don't even |
806 | diff --git a/lib/lp/translations/doc/poexport-language-pack.rst b/lib/lp/translations/doc/poexport-language-pack.rst |
807 | index 996cccd..a243b29 100644 |
808 | --- a/lib/lp/translations/doc/poexport-language-pack.rst |
809 | +++ b/lib/lp/translations/doc/poexport-language-pack.rst |
810 | @@ -115,7 +115,9 @@ some DB classes. |
811 | >>> import io |
812 | >>> from lp.registry.interfaces.distribution import IDistributionSet |
813 | >>> from lp.registry.interfaces.person import IPersonSet |
814 | - >>> from lp.registry.model.sourcepackagename import SourcePackageName |
815 | + >>> from lp.registry.interfaces.sourcepackagename import ( |
816 | + ... ISourcePackageNameSet, |
817 | + ... ) |
818 | >>> from lp.translations.model.potemplate import POTemplate |
819 | |
820 | Get hold of a person. |
821 | @@ -130,7 +132,7 @@ Get the Grumpy distro series. |
822 | |
823 | Get a source package name to go with our distro series. |
824 | |
825 | - >>> spn = SourcePackageName.byName("evolution") |
826 | + >>> spn = getUtility(ISourcePackageNameSet)["evolution"] |
827 | |
828 | Put a dummy file in the Librarian required by the new template we are |
829 | creating. |
830 | diff --git a/lib/lp/translations/doc/translationimportqueue.rst b/lib/lp/translations/doc/translationimportqueue.rst |
831 | index e8f0793..29dabee 100644 |
832 | --- a/lib/lp/translations/doc/translationimportqueue.rst |
833 | +++ b/lib/lp/translations/doc/translationimportqueue.rst |
834 | @@ -112,7 +112,9 @@ Now let's try the same against the evolution sourcepackage that only has an |
835 | IPOTemplate. |
836 | |
837 | >>> hoary_distroseries = DistroSeries.get(3) |
838 | - >>> evolution_sourcepackagename = SourcePackageName.get(9) |
839 | + >>> evolution_sourcepackagename = IStore(SourcePackageName).get( |
840 | + ... SourcePackageName, 9 |
841 | + ... ) |
842 | >>> entry = translationimportqueue.addOrUpdateEntry( |
843 | ... "po/sr.po", |
844 | ... b"foo", |
845 | diff --git a/lib/lp/translations/doc/translationsoverview.rst b/lib/lp/translations/doc/translationsoverview.rst |
846 | index 818af4c..162d6d9 100644 |
847 | --- a/lib/lp/translations/doc/translationsoverview.rst |
848 | +++ b/lib/lp/translations/doc/translationsoverview.rst |
849 | @@ -17,8 +17,10 @@ test too much. |
850 | >>> from lp.registry.interfaces.karma import IKarmaCacheManager |
851 | >>> from lp.registry.interfaces.person import IPersonSet |
852 | >>> from lp.registry.interfaces.product import IProductSet |
853 | + >>> from lp.registry.interfaces.sourcepackagename import ( |
854 | + ... ISourcePackageNameSet, |
855 | + ... ) |
856 | >>> from lp.registry.model.karma import KarmaCategory |
857 | - >>> from lp.registry.model.sourcepackagename import SourcePackageName |
858 | >>> from lp.services.database.interfaces import IStore |
859 | >>> from lp.translations.interfaces.translationsoverview import ( |
860 | ... ITranslationsOverview, |
861 | @@ -162,7 +164,9 @@ list as well. |
862 | |
863 | >>> start_karma_update() |
864 | >>> ubuntu = getUtility(IDistributionSet).getByName("ubuntu") |
865 | - >>> evolution_sourcepackagename = SourcePackageName.byName("evolution") |
866 | + >>> evolution_sourcepackagename = getUtility(ISourcePackageNameSet)[ |
867 | + ... "evolution" |
868 | + ... ] |
869 | >>> cache_entry = karmacachemanager.new( |
870 | ... 5150, |
871 | ... carlos.id, |
872 | diff --git a/lib/lp/translations/tests/test_autoapproval.py b/lib/lp/translations/tests/test_autoapproval.py |
873 | index eeadbb0..94cfb07 100644 |
874 | --- a/lib/lp/translations/tests/test_autoapproval.py |
875 | +++ b/lib/lp/translations/tests/test_autoapproval.py |
876 | @@ -19,11 +19,9 @@ from zope.security.proxy import removeSecurityProxy |
877 | from lp.app.enums import ServiceUsage |
878 | from lp.app.interfaces.launchpad import ILaunchpadCelebrities |
879 | from lp.registry.interfaces.series import SeriesStatus |
880 | +from lp.registry.interfaces.sourcepackagename import ISourcePackageNameSet |
881 | from lp.registry.model.distribution import Distribution |
882 | -from lp.registry.model.sourcepackagename import ( |
883 | - SourcePackageName, |
884 | - SourcePackageNameSet, |
885 | -) |
886 | +from lp.registry.model.sourcepackagename import SourcePackageNameSet |
887 | from lp.services.database.interfaces import IPrimaryStore |
888 | from lp.services.worlddata.interfaces.language import ILanguageSet |
889 | from lp.testing import TestCaseWithFactory, verifyObject |
890 | @@ -87,7 +85,7 @@ class TestCustomLanguageCode(TestCaseWithFactory): |
891 | ) |
892 | |
893 | self.distro = Distribution.byName("ubuntu") |
894 | - self.sourcepackagename = SourcePackageName.byName("evolution") |
895 | + self.sourcepackagename = getUtility(ISourcePackageNameSet)["evolution"] |
896 | self.package_codes["Brazilian"] = CustomLanguageCode( |
897 | translation_target=self.distro.getSourcePackage( |
898 | self.sourcepackagename |
899 | @@ -118,7 +116,7 @@ class TestCustomLanguageCode(TestCaseWithFactory): |
900 | brazilian = gentoo_package.getCustomLanguageCode("Brazilian") |
901 | self.assertEqual(brazilian, None) |
902 | |
903 | - cnews = SourcePackageName.byName("cnews") |
904 | + cnews = getUtility(ISourcePackageNameSet)["cnews"] |
905 | cnews_package = self.distro.getSourcePackage(cnews) |
906 | self.assertEqual(cnews_package.getCustomLanguageCode("nocode"), None) |
907 | self.assertEqual( |
LGTM
We do seem to want to query SourcePackageNames by name a lot, would it make sense to create a small class method for that (something similar to what `byName` did)? I don't think that's a deal breaker though, the changes look good