Merge lp:~jml/launchpad/import-fascist-tweaks into lp:launchpad
- import-fascist-tweaks
- Merge into devel
Proposed by
Jonathan Lange
Status: | Merged |
---|---|
Approved by: | Muharem Hrnjadovic |
Approved revision: | not available |
Merged at revision: | not available |
Proposed branch: | lp:~jml/launchpad/import-fascist-tweaks |
Merge into: | lp:launchpad |
Diff against target: |
375 lines (+90/-54) 13 files modified
lib/canonical/launchpad/fields/__init__.py (+2/-0) lib/lp/bugs/model/bugwatch.py (+1/-2) lib/lp/buildmaster/interfaces/buildfarmjobbehavior.py (+1/-0) lib/lp/registry/interfaces/mailinglist.py (+1/-1) lib/lp/registry/interfaces/teammembership.py (+1/-0) lib/lp/registry/model/structuralsubscription.py (+3/-1) lib/lp/scripts/utilities/importfascist.py (+66/-39) lib/lp/services/job/interfaces/job.py (+1/-0) lib/lp/soyuz/model/archive.py (+8/-4) lib/lp/soyuz/model/archivesubscriber.py (+2/-2) lib/lp/soyuz/model/builder.py (+2/-3) lib/lp/soyuz/model/distroarchseries.py (+1/-2) lib/lp/soyuz/model/files.py (+1/-0) |
To merge this branch: | bzr merge lp:~jml/launchpad/import-fascist-tweaks |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Muharem Hrnjadovic (community) | Approve | ||
Review via email: mp+16560@code.launchpad.net |
Commit message
importfascist now checks 'lp' package and is now more data-driven. Many dodgy imports fixed.
Description of the change
To post a comment you must log in.
Revision history for this message
Jonathan Lange (jml) wrote : | # |
Revision history for this message
Muharem Hrnjadovic (al-maisan) wrote : | # |
Nice branch, approved with the changes in http://
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'lib/canonical/launchpad/fields/__init__.py' | |||
2 | --- lib/canonical/launchpad/fields/__init__.py 2009-12-09 23:11:31 +0000 | |||
3 | +++ lib/canonical/launchpad/fields/__init__.py 2009-12-24 08:18:19 +0000 | |||
4 | @@ -32,9 +32,11 @@ | |||
5 | 32 | 'LocationField', | 32 | 'LocationField', |
6 | 33 | 'LogoImageUpload', | 33 | 'LogoImageUpload', |
7 | 34 | 'MugshotImageUpload', | 34 | 'MugshotImageUpload', |
8 | 35 | 'NoneableDescription', | ||
9 | 35 | 'NoneableTextLine', | 36 | 'NoneableTextLine', |
10 | 36 | 'ParticipatingPersonChoice', | 37 | 'ParticipatingPersonChoice', |
11 | 37 | 'PasswordField', | 38 | 'PasswordField', |
12 | 39 | 'PersonChoice', | ||
13 | 38 | 'PillarAliases', | 40 | 'PillarAliases', |
14 | 39 | 'PillarNameField', | 41 | 'PillarNameField', |
15 | 40 | 'PrivateMembershipTeamNotAllowed', | 42 | 'PrivateMembershipTeamNotAllowed', |
16 | 41 | 43 | ||
17 | === modified file 'lib/lp/bugs/model/bugwatch.py' | |||
18 | --- lib/lp/bugs/model/bugwatch.py 2009-12-15 17:28:51 +0000 | |||
19 | +++ lib/lp/bugs/model/bugwatch.py 2009-12-24 08:18:19 +0000 | |||
20 | @@ -35,10 +35,9 @@ | |||
21 | 35 | from canonical.launchpad.webapp import urlappend, urlsplit | 35 | from canonical.launchpad.webapp import urlappend, urlsplit |
22 | 36 | from canonical.launchpad.webapp.interfaces import NotFoundError | 36 | from canonical.launchpad.webapp.interfaces import NotFoundError |
23 | 37 | 37 | ||
24 | 38 | from lp.bugs.interfaces.bug import IBugWatch | ||
25 | 39 | from lp.bugs.interfaces.bugtracker import BugTrackerType, IBugTrackerSet | 38 | from lp.bugs.interfaces.bugtracker import BugTrackerType, IBugTrackerSet |
26 | 40 | from lp.bugs.interfaces.bugwatch import ( | 39 | from lp.bugs.interfaces.bugwatch import ( |
28 | 41 | BugWatchErrorType, IBugWatchSet, NoBugTrackerFound, | 40 | BugWatchErrorType, IBugWatch, IBugWatchSet, NoBugTrackerFound, |
29 | 42 | UnrecognizedBugTrackerURL) | 41 | UnrecognizedBugTrackerURL) |
30 | 43 | from lp.bugs.model.bugmessage import BugMessage | 42 | from lp.bugs.model.bugmessage import BugMessage |
31 | 44 | from lp.bugs.model.bugset import BugSetBase | 43 | from lp.bugs.model.bugset import BugSetBase |
32 | 45 | 44 | ||
33 | === modified file 'lib/lp/buildmaster/interfaces/buildfarmjobbehavior.py' | |||
34 | --- lib/lp/buildmaster/interfaces/buildfarmjobbehavior.py 2009-12-03 14:38:48 +0000 | |||
35 | +++ lib/lp/buildmaster/interfaces/buildfarmjobbehavior.py 2009-12-24 08:18:19 +0000 | |||
36 | @@ -8,6 +8,7 @@ | |||
37 | 8 | __metaclass__ = type | 8 | __metaclass__ = type |
38 | 9 | 9 | ||
39 | 10 | __all__ = [ | 10 | __all__ = [ |
40 | 11 | 'BuildBehaviorMismatch', | ||
41 | 11 | 'IBuildFarmJobBehavior', | 12 | 'IBuildFarmJobBehavior', |
42 | 12 | ] | 13 | ] |
43 | 13 | 14 | ||
44 | 14 | 15 | ||
45 | === modified file 'lib/lp/registry/interfaces/mailinglist.py' | |||
46 | --- lib/lp/registry/interfaces/mailinglist.py 2009-12-03 19:12:02 +0000 | |||
47 | +++ lib/lp/registry/interfaces/mailinglist.py 2009-12-24 08:18:19 +0000 | |||
48 | @@ -31,7 +31,7 @@ | |||
49 | 31 | 31 | ||
50 | 32 | from canonical.launchpad import _ | 32 | from canonical.launchpad import _ |
51 | 33 | from canonical.launchpad.fields import PublicPersonChoice | 33 | from canonical.launchpad.fields import PublicPersonChoice |
53 | 34 | from lp.registry.interfaces.person import IEmailAddress | 34 | from canonical.launchpad.interfaces.emailaddress import IEmailAddress |
54 | 35 | from canonical.launchpad.interfaces.librarian import ILibraryFileAlias | 35 | from canonical.launchpad.interfaces.librarian import ILibraryFileAlias |
55 | 36 | from canonical.launchpad.interfaces.message import IMessage | 36 | from canonical.launchpad.interfaces.message import IMessage |
56 | 37 | from lp.registry.interfaces.person import IPerson | 37 | from lp.registry.interfaces.person import IPerson |
57 | 38 | 38 | ||
58 | === modified file 'lib/lp/registry/interfaces/teammembership.py' | |||
59 | --- lib/lp/registry/interfaces/teammembership.py 2009-12-19 22:19:12 +0000 | |||
60 | +++ lib/lp/registry/interfaces/teammembership.py 2009-12-24 08:18:19 +0000 | |||
61 | @@ -14,6 +14,7 @@ | |||
62 | 14 | 'ITeamMembershipSet', | 14 | 'ITeamMembershipSet', |
63 | 15 | 'ITeamParticipation', | 15 | 'ITeamParticipation', |
64 | 16 | 'TeamMembershipStatus', | 16 | 'TeamMembershipStatus', |
65 | 17 | 'UserCannotChangeMembershipSilently', | ||
66 | 17 | ] | 18 | ] |
67 | 18 | 19 | ||
68 | 19 | from zope.schema import Bool, Choice, Datetime, Int, Text | 20 | from zope.schema import Bool, Choice, Datetime, Int, Text |
69 | 20 | 21 | ||
70 | === modified file 'lib/lp/registry/model/structuralsubscription.py' | |||
71 | --- lib/lp/registry/model/structuralsubscription.py 2009-12-05 18:37:28 +0000 | |||
72 | +++ lib/lp/registry/model/structuralsubscription.py 2009-12-24 08:18:19 +0000 | |||
73 | @@ -17,9 +17,11 @@ | |||
74 | 17 | 17 | ||
75 | 18 | from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities | 18 | from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities |
76 | 19 | from lp.registry.interfaces.distribution import IDistribution | 19 | from lp.registry.interfaces.distribution import IDistribution |
77 | 20 | from lp.registry.interfaces.distributionsourcepackage import ( | ||
78 | 21 | IDistributionSourcePackage) | ||
79 | 20 | from lp.registry.interfaces.distroseries import IDistroSeries | 22 | from lp.registry.interfaces.distroseries import IDistroSeries |
80 | 21 | from lp.registry.interfaces.milestone import IMilestone | 23 | from lp.registry.interfaces.milestone import IMilestone |
82 | 22 | from lp.registry.interfaces.product import IDistributionSourcePackage, IProduct | 24 | from lp.registry.interfaces.product import IProduct |
83 | 23 | from lp.registry.interfaces.productseries import IProductSeries | 25 | from lp.registry.interfaces.productseries import IProductSeries |
84 | 24 | from lp.registry.interfaces.project import IProject | 26 | from lp.registry.interfaces.project import IProject |
85 | 25 | from lp.registry.interfaces.structuralsubscription import ( | 27 | from lp.registry.interfaces.structuralsubscription import ( |
86 | 26 | 28 | ||
87 | === modified file 'lib/lp/scripts/utilities/importfascist.py' | |||
88 | --- lib/lp/scripts/utilities/importfascist.py 2009-08-27 01:32:01 +0000 | |||
89 | +++ lib/lp/scripts/utilities/importfascist.py 2009-12-24 08:18:19 +0000 | |||
90 | @@ -52,6 +52,17 @@ | |||
91 | 52 | """) | 52 | """) |
92 | 53 | 53 | ||
93 | 54 | 54 | ||
94 | 55 | # Sometimes, third-party modules don't export all of their public APIs through | ||
95 | 56 | # __all__. The following dict maps from such modules to a list of attributes | ||
96 | 57 | # that are allowed to be imported, whether or not they are in __all__. | ||
97 | 58 | valid_imports_not_in_all = { | ||
98 | 59 | 'cookielib': set(['domain_match']), | ||
99 | 60 | 'email.Utils': set(['mktime_tz']), | ||
100 | 61 | 'textwrap': set(['dedent']), | ||
101 | 62 | 'zope.component': set(['adapter', 'provideHandler']), | ||
102 | 63 | } | ||
103 | 64 | |||
104 | 65 | |||
105 | 55 | def database_import_allowed_into(module_path): | 66 | def database_import_allowed_into(module_path): |
106 | 56 | """Return True if database code is allowed to be imported into the given | 67 | """Return True if database code is allowed to be imported into the given |
107 | 57 | module path. Otherwise, returns False. | 68 | module path. Otherwise, returns False. |
108 | @@ -156,11 +167,11 @@ | |||
109 | 156 | 167 | ||
110 | 157 | 168 | ||
111 | 158 | # pylint: disable-msg=W0102,W0602 | 169 | # pylint: disable-msg=W0102,W0602 |
113 | 159 | def import_fascist(name, globals={}, locals={}, fromlist=[]): | 170 | def import_fascist(module_name, globals={}, locals={}, from_list=[]): |
114 | 160 | global naughty_imports | 171 | global naughty_imports |
115 | 161 | 172 | ||
116 | 162 | try: | 173 | try: |
118 | 163 | module = original_import(name, globals, locals, fromlist) | 174 | module = original_import(module_name, globals, locals, from_list) |
119 | 164 | except ImportError: | 175 | except ImportError: |
120 | 165 | # XXX sinzui 2008-04-17 bug=277274: | 176 | # XXX sinzui 2008-04-17 bug=277274: |
121 | 166 | # import_fascist screws zope configuration module which introspects | 177 | # import_fascist screws zope configuration module which introspects |
122 | @@ -170,19 +181,18 @@ | |||
123 | 170 | # time doesn't exist and dies a horrible death because of the import | 181 | # time doesn't exist and dies a horrible death because of the import |
124 | 171 | # fascist. That's the long explanation for why we special case this | 182 | # fascist. That's the long explanation for why we special case this |
125 | 172 | # module. | 183 | # module. |
129 | 173 | if name.startswith('zope.app.layers.'): | 184 | if module_name.startswith('zope.app.layers.'): |
130 | 174 | name = name[16:] | 185 | module_name = module_name[16:] |
131 | 175 | module = original_import(name, globals, locals, fromlist) | 186 | module = original_import(module_name, globals, locals, from_list) |
132 | 176 | else: | 187 | else: |
133 | 177 | raise | 188 | raise |
134 | 178 | # Python's re module imports some odd stuff every time certain regexes | 189 | # Python's re module imports some odd stuff every time certain regexes |
135 | 179 | # are used. Let's optimize this. | 190 | # are used. Let's optimize this. |
138 | 180 | # Also, 'dedent' is not in textwrap.__all__. | 191 | if module_name == 'sre': |
137 | 181 | if name == 'sre' or name == 'textwrap': | ||
139 | 182 | return module | 192 | return module |
140 | 183 | 193 | ||
141 | 184 | # Mailman 2.1 code base is originally circa 1998, so yeah, no __all__'s. | 194 | # Mailman 2.1 code base is originally circa 1998, so yeah, no __all__'s. |
143 | 185 | if name.startswith('Mailman'): | 195 | if module_name.startswith('Mailman'): |
144 | 186 | return module | 196 | return module |
145 | 187 | 197 | ||
146 | 188 | # Some uses of __import__ pass None for globals, so handle that. | 198 | # Some uses of __import__ pass None for globals, so handle that. |
147 | @@ -195,13 +205,17 @@ | |||
148 | 195 | # We could find out by jumping up the stack a frame. | 205 | # We could find out by jumping up the stack a frame. |
149 | 196 | # Let's not for now. | 206 | # Let's not for now. |
150 | 197 | import_into = '__import__ hook' | 207 | import_into = '__import__ hook' |
151 | 208 | |||
152 | 209 | # Check the "NotFoundError" policy. | ||
153 | 198 | if (import_into.startswith('canonical.launchpad.database') and | 210 | if (import_into.startswith('canonical.launchpad.database') and |
156 | 199 | name == 'zope.exceptions'): | 211 | module_name == 'zope.exceptions'): |
157 | 200 | if fromlist and 'NotFoundError' in fromlist: | 212 | if from_list and 'NotFoundError' in from_list: |
158 | 201 | raise NotFoundPolicyViolation(import_into) | 213 | raise NotFoundPolicyViolation(import_into) |
160 | 202 | if (name.startswith(database_root) and | 214 | |
161 | 215 | # Check the database import policy. | ||
162 | 216 | if (module_name.startswith(database_root) and | ||
163 | 203 | not database_import_allowed_into(import_into)): | 217 | not database_import_allowed_into(import_into)): |
165 | 204 | error = DatabaseImportPolicyViolation(import_into, name) | 218 | error = DatabaseImportPolicyViolation(import_into, module_name) |
166 | 205 | naughty_imports.add(error) | 219 | naughty_imports.add(error) |
167 | 206 | # Raise an error except in the case of browser.traversers. | 220 | # Raise an error except in the case of browser.traversers. |
168 | 207 | # This exception to raising an error is only temporary, until | 221 | # This exception to raising an error is only temporary, until |
169 | @@ -209,34 +223,48 @@ | |||
170 | 209 | if import_into not in warned_database_imports: | 223 | if import_into not in warned_database_imports: |
171 | 210 | raise error | 224 | raise error |
172 | 211 | 225 | ||
174 | 212 | if fromlist is not None and import_into.startswith('canonical'): | 226 | # Check the import from __all__ policy. |
175 | 227 | if from_list is not None and ( | ||
176 | 228 | import_into.startswith('canonical') or import_into.startswith('lp')): | ||
177 | 213 | # We only want to warn about "from foo import bar" violations in our | 229 | # We only want to warn about "from foo import bar" violations in our |
178 | 214 | # own code. | 230 | # own code. |
204 | 215 | if list(fromlist) == ['*'] and not hasattr(module, '__all__'): | 231 | from_list = list(from_list) |
205 | 216 | # "from foo import *" is naughty if foo has no __all__ | 232 | module_all = getattr(module, '__all__', None) |
206 | 217 | error = FromStarPolicyViolation(import_into, name) | 233 | if module_all is None: |
207 | 218 | naughty_imports.add(error) | 234 | if from_list == ['*']: |
208 | 219 | raise error | 235 | # "from foo import *" is naughty if foo has no __all__ |
209 | 220 | elif (list(fromlist) != ['*'] and hasattr(module, '__all__') and | 236 | error = FromStarPolicyViolation(import_into, module_name) |
210 | 221 | not is_test_module(import_into)): | 237 | naughty_imports.add(error) |
211 | 222 | # "from foo import bar" is naughty if bar isn't in foo.__all__ | 238 | raise error |
212 | 223 | # (and foo actually has an __all__). Unless foo is within a tests | 239 | else: |
213 | 224 | # or ftests module or bar is itself a module. | 240 | if from_list == ['*']: |
214 | 225 | for attrname in fromlist: | 241 | # "from foo import *" is allowed if foo has an __all__ |
215 | 226 | if (attrname in ('adapter', 'provideHandler') | 242 | return module |
216 | 227 | and module.__name__ == 'zope.component'): | 243 | if is_test_module(import_into): |
217 | 228 | # 'adapter' and 'provideHandler' are not in | 244 | # We don't bother checking imports into test modules. |
218 | 229 | # zope.component.__all__, but that's where they should be | 245 | return module |
219 | 230 | # imported from. | 246 | allowed_from_list = valid_imports_not_in_all.get( |
220 | 231 | continue | 247 | module_name, set()) |
221 | 232 | if attrname != '__doc__' and attrname not in module.__all__: | 248 | for attrname in from_list: |
222 | 233 | if not isinstance( | 249 | # Check that each thing we are importing into the module is |
223 | 234 | getattr(module, attrname, None), types.ModuleType): | 250 | # either in __all__, is a module itself, or is a specific |
224 | 235 | error = NotInModuleAllPolicyViolation( | 251 | # exception. |
225 | 236 | import_into, name, attrname) | 252 | if attrname == '__doc__': |
226 | 237 | naughty_imports.add(error) | 253 | # You can always import __doc__. |
227 | 238 | # Not raising on NotInModuleAllPolicyViolation yet. | 254 | continue |
228 | 239 | #raise error | 255 | if isinstance( |
229 | 256 | getattr(module, attrname, None), types.ModuleType): | ||
230 | 257 | # You can import modules even when they aren't declared in | ||
231 | 258 | # __all__. | ||
232 | 259 | continue | ||
233 | 260 | if attrname in allowed_from_list: | ||
234 | 261 | # Some things can be imported even if they aren't in | ||
235 | 262 | # __all__. | ||
236 | 263 | continue | ||
237 | 264 | if attrname not in module_all: | ||
238 | 265 | error = NotInModuleAllPolicyViolation( | ||
239 | 266 | import_into, module_name, attrname) | ||
240 | 267 | naughty_imports.add(error) | ||
241 | 240 | return module | 268 | return module |
242 | 241 | 269 | ||
243 | 242 | 270 | ||
244 | @@ -244,7 +272,6 @@ | |||
245 | 244 | if naughty_imports: | 272 | if naughty_imports: |
246 | 245 | 273 | ||
247 | 246 | print '** %d import policy violations **' % len(naughty_imports) | 274 | print '** %d import policy violations **' % len(naughty_imports) |
248 | 247 | current_type = None | ||
249 | 248 | 275 | ||
250 | 249 | database_violations = [] | 276 | database_violations = [] |
251 | 250 | fromstar_violations = [] | 277 | fromstar_violations = [] |
252 | 251 | 278 | ||
253 | === modified file 'lib/lp/services/job/interfaces/job.py' | |||
254 | --- lib/lp/services/job/interfaces/job.py 2009-09-02 21:09:48 +0000 | |||
255 | +++ lib/lp/services/job/interfaces/job.py 2009-12-24 08:18:19 +0000 | |||
256 | @@ -9,6 +9,7 @@ | |||
257 | 9 | 9 | ||
258 | 10 | __all__ = [ | 10 | __all__ = [ |
259 | 11 | 'IJob', | 11 | 'IJob', |
260 | 12 | 'IRunnableJob', | ||
261 | 12 | 'JobStatus', | 13 | 'JobStatus', |
262 | 13 | 'LeaseHeld', | 14 | 'LeaseHeld', |
263 | 14 | ] | 15 | ] |
264 | 15 | 16 | ||
265 | === modified file 'lib/lp/soyuz/model/archive.py' | |||
266 | --- lib/lp/soyuz/model/archive.py 2009-12-08 15:40:23 +0000 | |||
267 | +++ lib/lp/soyuz/model/archive.py 2009-12-24 08:18:19 +0000 | |||
268 | @@ -54,7 +54,7 @@ | |||
269 | 54 | from lp.registry.model.teammembership import TeamParticipation | 54 | from lp.registry.model.teammembership import TeamParticipation |
270 | 55 | from lp.soyuz.interfaces.archive import ( | 55 | from lp.soyuz.interfaces.archive import ( |
271 | 56 | AlreadySubscribed, ArchiveDependencyError, ArchiveNotPrivate, | 56 | AlreadySubscribed, ArchiveDependencyError, ArchiveNotPrivate, |
273 | 57 | ArchivePurpose, DistroSeriesNotFound, IArchive, IArchiveSet, | 57 | ArchivePurpose, CannotCopy, DistroSeriesNotFound, IArchive, IArchiveSet, |
274 | 58 | IDistributionArchive, InvalidComponent, IPPA, MAIN_ARCHIVE_PURPOSES, | 58 | IDistributionArchive, InvalidComponent, IPPA, MAIN_ARCHIVE_PURPOSES, |
275 | 59 | NoSuchPPA, PocketNotFound, VersionRequiresName, default_name_by_purpose) | 59 | NoSuchPPA, PocketNotFound, VersionRequiresName, default_name_by_purpose) |
276 | 60 | from lp.soyuz.interfaces.archiveauthtoken import IArchiveAuthTokenSet | 60 | from lp.soyuz.interfaces.archiveauthtoken import IArchiveAuthTokenSet |
277 | @@ -77,7 +77,7 @@ | |||
278 | 77 | from lp.soyuz.interfaces.publishing import ( | 77 | from lp.soyuz.interfaces.publishing import ( |
279 | 78 | active_publishing_status, PackagePublishingStatus, IPublishingSet) | 78 | active_publishing_status, PackagePublishingStatus, IPublishingSet) |
280 | 79 | from lp.registry.interfaces.sourcepackagename import ISourcePackageNameSet | 79 | from lp.registry.interfaces.sourcepackagename import ISourcePackageNameSet |
282 | 80 | from lp.soyuz.scripts.packagecopier import CannotCopy, do_copy | 80 | from lp.soyuz.scripts.packagecopier import do_copy |
283 | 81 | from canonical.launchpad.webapp.interfaces import ( | 81 | from canonical.launchpad.webapp.interfaces import ( |
284 | 82 | IStoreSelector, MAIN_STORE, DEFAULT_FLAVOR) | 82 | IStoreSelector, MAIN_STORE, DEFAULT_FLAVOR) |
285 | 83 | from canonical.launchpad.webapp.url import urlappend | 83 | from canonical.launchpad.webapp.url import urlappend |
286 | @@ -1096,7 +1096,9 @@ | |||
287 | 1096 | # Find and validate the source package names in source_names. | 1096 | # Find and validate the source package names in source_names. |
288 | 1097 | sources = [] | 1097 | sources = [] |
289 | 1098 | for name in source_names: | 1098 | for name in source_names: |
291 | 1099 | source_package_name = getUtility(ISourcePackageNameSet)[name] | 1099 | # Check to see if the source package exists, and raise a useful |
292 | 1100 | # error if it doesn't. | ||
293 | 1101 | getUtility(ISourcePackageNameSet)[name] | ||
294 | 1100 | # Grabbing the item at index 0 ensures it's the most recent | 1102 | # Grabbing the item at index 0 ensures it's the most recent |
295 | 1101 | # publication. | 1103 | # publication. |
296 | 1102 | sources.append( | 1104 | sources.append( |
297 | @@ -1108,8 +1110,10 @@ | |||
298 | 1108 | def syncSource(self, source_name, version, from_archive, to_pocket, | 1110 | def syncSource(self, source_name, version, from_archive, to_pocket, |
299 | 1109 | to_series=None, include_binaries=False): | 1111 | to_series=None, include_binaries=False): |
300 | 1110 | """See `IArchive`.""" | 1112 | """See `IArchive`.""" |
301 | 1113 | # Check to see if the source package exists, and raise a useful error | ||
302 | 1114 | # if it doesn't. | ||
303 | 1115 | getUtility(ISourcePackageNameSet)[source_name] | ||
304 | 1111 | # Find and validate the source package version required. | 1116 | # Find and validate the source package version required. |
305 | 1112 | source_package_name = getUtility(ISourcePackageNameSet)[source_name] | ||
306 | 1113 | source = from_archive.getPublishedSources( | 1117 | source = from_archive.getPublishedSources( |
307 | 1114 | name=source_name, version=version, exact_match=True)[0] | 1118 | name=source_name, version=version, exact_match=True)[0] |
308 | 1115 | 1119 | ||
309 | 1116 | 1120 | ||
310 | === modified file 'lib/lp/soyuz/model/archivesubscriber.py' | |||
311 | --- lib/lp/soyuz/model/archivesubscriber.py 2009-07-17 00:26:05 +0000 | |||
312 | +++ lib/lp/soyuz/model/archivesubscriber.py 2009-12-24 08:18:19 +0000 | |||
313 | @@ -20,8 +20,8 @@ | |||
314 | 20 | 20 | ||
315 | 21 | from canonical.database.constants import UTC_NOW | 21 | from canonical.database.constants import UTC_NOW |
316 | 22 | from canonical.database.enumcol import DBEnum | 22 | from canonical.database.enumcol import DBEnum |
319 | 23 | from lp.soyuz.model.archiveauthtoken import ( | 23 | from lp.soyuz.interfaces.archiveauthtoken import IArchiveAuthTokenSet |
320 | 24 | ArchiveAuthToken, IArchiveAuthTokenSet) | 24 | from lp.soyuz.model.archiveauthtoken import ArchiveAuthToken |
321 | 25 | from lp.registry.interfaces.person import ( | 25 | from lp.registry.interfaces.person import ( |
322 | 26 | validate_person_not_private_membership) | 26 | validate_person_not_private_membership) |
323 | 27 | from lp.registry.model.teammembership import TeamParticipation | 27 | from lp.registry.model.teammembership import TeamParticipation |
324 | 28 | 28 | ||
325 | === modified file 'lib/lp/soyuz/model/builder.py' | |||
326 | --- lib/lp/soyuz/model/builder.py 2009-12-04 12:49:25 +0000 | |||
327 | +++ lib/lp/soyuz/model/builder.py 2009-12-24 08:18:19 +0000 | |||
328 | @@ -42,8 +42,7 @@ | |||
329 | 42 | from lp.registry.interfaces.person import validate_public_person | 42 | from lp.registry.interfaces.person import validate_public_person |
330 | 43 | from lp.registry.interfaces.pocket import PackagePublishingPocket | 43 | from lp.registry.interfaces.pocket import PackagePublishingPocket |
331 | 44 | from canonical.launchpad.helpers import filenameToContentType | 44 | from canonical.launchpad.helpers import filenameToContentType |
334 | 45 | from canonical.launchpad.interfaces._schema_circular_imports import ( | 45 | from lp.soyuz.interfaces.buildrecords import IHasBuildRecords |
333 | 46 | IHasBuildRecords) | ||
335 | 47 | from lp.soyuz.interfaces.distroarchseries import IDistroArchSeriesSet | 46 | from lp.soyuz.interfaces.distroarchseries import IDistroArchSeriesSet |
336 | 48 | from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet | 47 | from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet |
337 | 49 | from canonical.launchpad.webapp.interfaces import NotFoundError | 48 | from canonical.launchpad.webapp.interfaces import NotFoundError |
338 | @@ -380,7 +379,7 @@ | |||
339 | 380 | return False | 379 | return False |
340 | 381 | try: | 380 | try: |
341 | 382 | slavestatus = self.slaveStatusSentence() | 381 | slavestatus = self.slaveStatusSentence() |
343 | 383 | except (xmlrpclib.Fault, socket.error), info: | 382 | except (xmlrpclib.Fault, socket.error): |
344 | 384 | return False | 383 | return False |
345 | 385 | if slavestatus[0] != BuilderStatus.IDLE: | 384 | if slavestatus[0] != BuilderStatus.IDLE: |
346 | 386 | return False | 385 | return False |
347 | 387 | 386 | ||
348 | === modified file 'lib/lp/soyuz/model/distroarchseries.py' | |||
349 | --- lib/lp/soyuz/model/distroarchseries.py 2009-08-28 07:34:44 +0000 | |||
350 | +++ lib/lp/soyuz/model/distroarchseries.py 2009-12-24 08:18:19 +0000 | |||
351 | @@ -23,12 +23,11 @@ | |||
352 | 23 | 23 | ||
353 | 24 | from canonical.launchpad.components.decoratedresultset import ( | 24 | from canonical.launchpad.components.decoratedresultset import ( |
354 | 25 | DecoratedResultSet) | 25 | DecoratedResultSet) |
355 | 26 | from canonical.launchpad.interfaces._schema_circular_imports import ( | ||
356 | 27 | IHasBuildRecords) | ||
357 | 28 | from lp.registry.interfaces.pocket import PackagePublishingPocket | 26 | from lp.registry.interfaces.pocket import PackagePublishingPocket |
358 | 29 | from lp.soyuz.interfaces.binarypackagename import IBinaryPackageName | 27 | from lp.soyuz.interfaces.binarypackagename import IBinaryPackageName |
359 | 30 | from lp.soyuz.interfaces.binarypackagerelease import IBinaryPackageReleaseSet | 28 | from lp.soyuz.interfaces.binarypackagerelease import IBinaryPackageReleaseSet |
360 | 31 | from lp.soyuz.interfaces.build import IBuildSet | 29 | from lp.soyuz.interfaces.build import IBuildSet |
361 | 30 | from lp.soyuz.interfaces.buildrecords import IHasBuildRecords | ||
362 | 32 | from lp.soyuz.interfaces.distroarchseries import ( | 31 | from lp.soyuz.interfaces.distroarchseries import ( |
363 | 33 | IDistroArchSeries, IDistroArchSeriesSet, IPocketChroot) | 32 | IDistroArchSeries, IDistroArchSeriesSet, IPocketChroot) |
364 | 34 | from lp.soyuz.interfaces.publishing import ( | 33 | from lp.soyuz.interfaces.publishing import ( |
365 | 35 | 34 | ||
366 | === modified file 'lib/lp/soyuz/model/files.py' | |||
367 | --- lib/lp/soyuz/model/files.py 2009-11-25 23:41:34 +0000 | |||
368 | +++ lib/lp/soyuz/model/files.py 2009-12-24 08:18:19 +0000 | |||
369 | @@ -7,6 +7,7 @@ | |||
370 | 7 | __all__ = [ | 7 | __all__ = [ |
371 | 8 | 'BinaryPackageFile', | 8 | 'BinaryPackageFile', |
372 | 9 | 'BinaryPackageFileSet', | 9 | 'BinaryPackageFileSet', |
373 | 10 | 'SourceFileMixin', | ||
374 | 10 | 'SourcePackageReleaseFile', | 11 | 'SourcePackageReleaseFile', |
375 | 11 | ] | 12 | ] |
376 | 12 | 13 |
This branch does a few different things, all to do with the import fascist. The patch:
* restructures the logic to be a bit clearer.
* provides a data-driven approach for allowing imports that aren't in __all__
* makes importfascist check packages in 'lp' and not just 'canonical'
* stops the warnings that we were all getting when running the tests
* fixes a whole bunch of warnings that we weren't getting because of 'lp' being ignored
* cleans up random pyflakes
Merry Christmas