Merge lp:~elachuni/software-center/pep8-test-part18 into lp:software-center
- pep8-test-part18
- Merge into trunk
Proposed by
Anthony Lenton
Status: | Merged |
---|---|
Merged at revision: | 2872 |
Proposed branch: | lp:~elachuni/software-center/pep8-test-part18 |
Merge into: | lp:software-center |
Diff against target: |
1184 lines (+279/-177) 8 files modified
softwarecenter/db/appfilter.py (+27/-10) softwarecenter/db/application.py (+91/-56) softwarecenter/distro/Debian.py (+17/-11) softwarecenter/distro/Fedora.py (+23/-18) softwarecenter/distro/SUSELINUX.py (+19/-14) softwarecenter/distro/Ubuntu.py (+63/-41) softwarecenter/distro/__init__.py (+36/-26) test/test_pep8.py (+3/-1) |
To merge this branch: | bzr merge lp:~elachuni/software-center/pep8-test-part18 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gary Lasker (community) | Approve | ||
Review via email: mp+97961@code.launchpad.net |
Commit message
Description of the change
The remaining files under softwarecenter.db and all of softwarecenter.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'softwarecenter/db/appfilter.py' |
2 | --- softwarecenter/db/appfilter.py 2011-09-20 12:09:53 +0000 |
3 | +++ softwarecenter/db/appfilter.py 2012-03-16 18:55:25 +0000 |
4 | @@ -5,15 +5,18 @@ |
5 | AVAILABLE_FOR_PURCHASE_MAGIC_CHANNEL_NAME, |
6 | ) |
7 | |
8 | + |
9 | class GlobalFilter(object): |
10 | def __init__(self): |
11 | self.supported_only = False |
12 | |
13 | global_filter = GlobalFilter() |
14 | |
15 | + |
16 | def get_global_filter(): |
17 | return global_filter |
18 | |
19 | + |
20 | class AppFilter(xapian.MatchDecider): |
21 | """ |
22 | Filter that can be hooked into xapian get_mset to filter for criteria that |
23 | @@ -30,49 +33,62 @@ |
24 | self.installed_only = False |
25 | self.not_installed_only = False |
26 | self.restricted_list = False |
27 | + |
28 | @property |
29 | def required(self): |
30 | - """ True if the filter is in a state that it should be part of a query """ |
31 | + """True if the filter is in a state that it should be part of a |
32 | + query |
33 | + """ |
34 | return (self.available_only or |
35 | global_filter.supported_only or |
36 | - self.installed_only or |
37 | + self.installed_only or |
38 | self.not_installed_only or |
39 | self.restricted_list) |
40 | + |
41 | def set_available_only(self, v): |
42 | self.available_only = v |
43 | + |
44 | def set_supported_only(self, v): |
45 | global_filter.supported_only = v |
46 | + |
47 | def set_installed_only(self, v): |
48 | self.installed_only = v |
49 | + |
50 | def set_not_installed_only(self, v): |
51 | self.not_installed_only = v |
52 | + |
53 | def set_restricted_list(self, v): |
54 | self.restricted_list = v |
55 | + |
56 | def get_supported_only(self): |
57 | return global_filter.supported_only |
58 | + |
59 | def __eq__(self, other): |
60 | - if self is None and other is not None: |
61 | + if self is None and other is not None: |
62 | return True |
63 | - if self is None or other is None: |
64 | + if self is None or other is None: |
65 | return False |
66 | return (self.installed_only == other.installed_only and |
67 | self.not_installed_only == other.not_installed_only and |
68 | global_filter.supported_only == other.supported_only and |
69 | self.restricted_list == other.restricted_list) |
70 | + |
71 | def __ne__(self, other): |
72 | return not self.__eq__(other) |
73 | + |
74 | def __call__(self, doc): |
75 | """return True if the package should be displayed""" |
76 | # get pkgname from document |
77 | - pkgname = self.db.get_pkgname(doc) |
78 | + pkgname = self.db.get_pkgname(doc) |
79 | #logging.debug( |
80 | # "filter: supported_only: %s installed_only: %s '%s'" % ( |
81 | # self.supported_only, self.installed_only, pkgname)) |
82 | if self.available_only: |
83 | # an item is considered available if it is either found |
84 | # in the cache or is available for purchase |
85 | - if (not pkgname in self.cache and |
86 | - not doc.get_value(XapianValues.ARCHIVE_CHANNEL) == AVAILABLE_FOR_PURCHASE_MAGIC_CHANNEL_NAME): |
87 | + if (not pkgname in self.cache and |
88 | + not doc.get_value(XapianValues.ARCHIVE_CHANNEL) == |
89 | + AVAILABLE_FOR_PURCHASE_MAGIC_CHANNEL_NAME): |
90 | return False |
91 | if self.installed_only: |
92 | if (not pkgname in self.cache or |
93 | @@ -85,16 +101,17 @@ |
94 | if global_filter.supported_only: |
95 | if not self.distro.is_supported(self.cache, doc, pkgname): |
96 | return False |
97 | - if self.restricted_list != False: # keep != False as the set can be empty |
98 | + if self.restricted_list != False: # keep != False as the set can be |
99 | + # empty |
100 | if not pkgname in self.restricted_list: |
101 | return False |
102 | return True |
103 | + |
104 | def copy(self): |
105 | """ create a new copy of the given filter """ |
106 | - new_filter= AppFilter(self.db, self.cache) |
107 | + new_filter = AppFilter(self.db, self.cache) |
108 | new_filter.available_only = self.available_only |
109 | new_filter.installed_only = self.installed_only |
110 | new_filter.not_installed_only = self.not_installed_only |
111 | new_filter.restricted_list = self.restricted_list |
112 | return new_filter |
113 | - |
114 | |
115 | === modified file 'softwarecenter/db/application.py' |
116 | --- softwarecenter/db/application.py 2012-03-15 10:58:19 +0000 |
117 | +++ softwarecenter/db/application.py 2012-03-16 18:55:25 +0000 |
118 | @@ -37,6 +37,7 @@ |
119 | |
120 | LOG = logging.getLogger(__name__) |
121 | |
122 | + |
123 | # this is a very lean class as its used in the main listview |
124 | # and there are a lot of application objects in memory |
125 | class Application(object): |
126 | @@ -74,9 +75,11 @@ |
127 | if self.appname: |
128 | return self.appname |
129 | return self.pkgname |
130 | + |
131 | @property |
132 | def popcon(self): |
133 | return self._popcon |
134 | + |
135 | # get a AppDetails object for this Applications |
136 | def get_details(self, db): |
137 | """ return a new AppDetails object for this application """ |
138 | @@ -90,7 +93,8 @@ |
139 | doc = db.get_xapian_document(self.appname, self.pkgname) |
140 | except IndexError: |
141 | return self |
142 | - untranslated_application = doc.get_value(XapianValues.APPNAME_UNTRANSLATED) |
143 | + untranslated_application = doc.get_value( |
144 | + XapianValues.APPNAME_UNTRANSLATED) |
145 | uapp = Application(untranslated_application, self.pkgname) |
146 | return uapp |
147 | |
148 | @@ -108,11 +112,12 @@ |
149 | return appname |
150 | else: |
151 | return db.get_summary(doc) |
152 | + |
153 | @staticmethod |
154 | def get_display_summary(db, doc): |
155 | """ Return the application summary as it should be displayed in the UI |
156 | - If the appname is defined, return the application summary, else return |
157 | - the application's pkgname (per the spec) |
158 | + If the appname is defined, return the application summary, else |
159 | + return the application's pkgname (per the spec) |
160 | """ |
161 | if doc: |
162 | if db.get_appname(doc): |
163 | @@ -123,12 +128,17 @@ |
164 | # special methods |
165 | def __hash__(self): |
166 | return ("%s:%s" % (self.appname, self.pkgname)).__hash__() |
167 | + |
168 | def __cmp__(self, other): |
169 | return self.apps_cmp(self, other) |
170 | + |
171 | def __str__(self): |
172 | return utf8("%s,%s") % (utf8(self.appname), utf8(self.pkgname)) |
173 | + |
174 | def __repr__(self): |
175 | - return "[Application: appname=%s pkgname=%s]" % (self.appname, self.pkgname) |
176 | + return "[Application: appname=%s pkgname=%s]" % (self.appname, |
177 | + self.pkgname) |
178 | + |
179 | @staticmethod |
180 | def apps_cmp(x, y): |
181 | """ sort method for the applications """ |
182 | @@ -143,16 +153,17 @@ |
183 | else: |
184 | return cmp(x.pkgname, y.pkgname) |
185 | |
186 | + |
187 | # the details |
188 | class AppDetails(GObject.GObject): |
189 | """ The details for a Application. This contains all the information |
190 | we have available like website etc |
191 | """ |
192 | |
193 | - __gsignals__ = {"screenshots-available" : (GObject.SIGNAL_RUN_FIRST, |
194 | - GObject.TYPE_NONE, |
195 | - (GObject.TYPE_PYOBJECT,), |
196 | - ), |
197 | + __gsignals__ = {"screenshots-available": (GObject.SIGNAL_RUN_FIRST, |
198 | + GObject.TYPE_NONE, |
199 | + (GObject.TYPE_PYOBJECT,), |
200 | + ), |
201 | } |
202 | |
203 | def __init__(self, db, doc=None, application=None): |
204 | @@ -214,7 +225,9 @@ |
205 | not channel_matches and |
206 | not section_matches): |
207 | self._error = _("Not found") |
208 | - self._error_not_found = utf8(_(u"There isn\u2019t a software package called \u201c%s\u201D in your current software sources.")) % utf8(self.pkgname) |
209 | + self._error_not_found = utf8(_(u"There isn\u2019t a " |
210 | + "software package called \u201c%s\u201D in your " |
211 | + "current software sources.")) % utf8(self.pkgname) |
212 | |
213 | def same_app(self, other): |
214 | return self.pkgname == other.pkgname |
215 | @@ -241,7 +254,6 @@ |
216 | raise ValueError("pkg '%s' has not archive_suite '%s'" % ( |
217 | pkg, archive_suite)) |
218 | |
219 | - |
220 | @property |
221 | def channelname(self): |
222 | if self._doc: |
223 | @@ -251,7 +263,8 @@ |
224 | return channel |
225 | else: |
226 | # check if we have an apturl request to enable a channel |
227 | - channel_matches = re.findall(r'channel=([0-9a-z,-]*)', self._app.request) |
228 | + channel_matches = re.findall(r'channel=([0-9a-z,-]*)', |
229 | + self._app.request) |
230 | if channel_matches: |
231 | channel = channel_matches[0] |
232 | channelfile = APP_INSTALL_CHANNELS_PATH + channel + ".list" |
233 | @@ -268,7 +281,7 @@ |
234 | def eulafile(self): |
235 | channel = self.channelname |
236 | if channel: |
237 | - eulafile = APP_INSTALL_CHANNELS_PATH + channel + ".eula" |
238 | + eulafile = APP_INSTALL_CHANNELS_PATH + channel + ".eula" |
239 | if os.path.exists(eulafile): |
240 | return eulafile |
241 | |
242 | @@ -292,11 +305,14 @@ |
243 | return comp |
244 | # then apturl requests |
245 | else: |
246 | - section_matches = re.findall(r'section=([a-z]+)', self._app.request) |
247 | + section_matches = re.findall(r'section=([a-z]+)', |
248 | + self._app.request) |
249 | if section_matches: |
250 | valid_section_matches = [] |
251 | for section_match in section_matches: |
252 | - if self._unavailable_component(component_to_check=section_match) and valid_section_matches.count(section_match) == 0: |
253 | + if (self._unavailable_component( |
254 | + component_to_check=section_match) and |
255 | + valid_section_matches.count(section_match) == 0): |
256 | valid_section_matches.append(section_match) |
257 | if valid_section_matches: |
258 | return ('&').join(valid_section_matches) |
259 | @@ -305,6 +321,7 @@ |
260 | def desktop_file(self): |
261 | if self._doc: |
262 | return self._doc.get_value(XapianValues.DESKTOP_FILE) |
263 | + |
264 | @property |
265 | def description(self): |
266 | if self._pkg: |
267 | @@ -328,8 +345,10 @@ |
268 | return self._error |
269 | # this may have changed since we inited the appdetails |
270 | elif self.pkg_state == PkgStates.NOT_FOUND: |
271 | - self._error = _("Not found") |
272 | - self._error_not_found = utf8(_(u"There isn\u2019t a software package called \u201c%s\u201D in your current software sources.")) % utf8(self.pkgname) |
273 | + self._error = _("Not found") |
274 | + self._error_not_found = utf8(_(u"There isn\u2019t a software " |
275 | + "package called \u201c%s\u201D in your current software " |
276 | + "sources.")) % utf8(self.pkgname) |
277 | return self._error_not_found |
278 | |
279 | @property |
280 | @@ -354,7 +373,8 @@ |
281 | @property |
282 | def cached_icon_file_path(self): |
283 | if self._doc: |
284 | - return os.path.join(SOFTWARE_CENTER_ICON_CACHE_DIR, self._db.get_iconname(self._doc)) |
285 | + return os.path.join(SOFTWARE_CENTER_ICON_CACHE_DIR, |
286 | + self._db.get_iconname(self._doc)) |
287 | |
288 | @property |
289 | def installation_date(self): |
290 | @@ -416,8 +436,8 @@ |
291 | @property |
292 | def display_summary(self): |
293 | """ Return the application summary as it should be displayed in the UI |
294 | - If the appname is defined, return the application summary, else return |
295 | - the application's pkgname (per the spec) |
296 | + If the appname is defined, return the application summary, else |
297 | + return the application's pkgname (per the spec) |
298 | """ |
299 | if self._doc: |
300 | return Application.get_display_summary(self._db, self._doc) |
301 | @@ -456,7 +476,7 @@ |
302 | # not-automatic channels (like experimental/backports) |
303 | if self._pkg: |
304 | if self._pkg.installed and self._app.archive_suite: |
305 | - archive_suites = [origin.archive |
306 | + archive_suites = [origin.archive |
307 | for origin in self._pkg.installed.origins] |
308 | if not self._app.archive_suite in archive_suites: |
309 | return PkgStates.FORCE_VERSION |
310 | @@ -477,8 +497,10 @@ |
311 | if self._unavailable_channel(): |
312 | return PkgStates.NEEDS_SOURCE |
313 | else: |
314 | - self._error = _("Not found") |
315 | - self._error_not_found = utf8(_(u"There isn\u2019t a software package called \u201c%s\u201D in your current software sources.")) % utf8(self.pkgname) |
316 | + self._error = _("Not found") |
317 | + self._error_not_found = utf8(_(u"There isn\u2019t a " |
318 | + "software package called \u201c%s\u201D in your " |
319 | + "current software sources.")) % utf8(self.pkgname) |
320 | return PkgStates.NOT_FOUND |
321 | else: |
322 | if self.price: |
323 | @@ -505,10 +527,13 @@ |
324 | if self.component: |
325 | components = self.component.split('&') |
326 | for component in components: |
327 | - if component and self._unavailable_component(component_to_check=component): |
328 | + if component and self._unavailable_component( |
329 | + component_to_check=component): |
330 | return PkgStates.NEEDS_SOURCE |
331 | - self._error = _("Not found") |
332 | - self._error_not_found = utf8(_(u"There isn\u2019t a software package called \u201c%s\u201D in your current software sources.")) % utf8(self.pkgname) |
333 | + self._error = _("Not found") |
334 | + self._error_not_found = utf8(_(u"There isn\u2019t a software " |
335 | + "package called \u201c%s\u201D in your current software " |
336 | + "sources.")) % utf8(self.pkgname) |
337 | return PkgStates.NOT_FOUND |
338 | return PkgStates.UNKNOWN |
339 | |
340 | @@ -520,7 +545,8 @@ |
341 | @property |
342 | def supported_distros(self): |
343 | if self._doc: |
344 | - supported_series = self._doc.get_value(XapianValues.SC_SUPPORTED_DISTROS) |
345 | + supported_series = self._doc.get_value( |
346 | + XapianValues.SC_SUPPORTED_DISTROS) |
347 | if not supported_series: |
348 | return {} |
349 | |
350 | @@ -552,8 +578,10 @@ |
351 | if screenshot_url: |
352 | return screenshot_url.split(",")[0] |
353 | # else use the default |
354 | - return self._distro.SCREENSHOT_LARGE_URL % { 'pkgname' : self.pkgname, |
355 | - 'version' : self.version or 0 } |
356 | + return self._distro.SCREENSHOT_LARGE_URL % { |
357 | + 'pkgname': self.pkgname, |
358 | + 'version': self.version or 0, |
359 | + } |
360 | |
361 | @property |
362 | def screenshots(self): |
363 | @@ -561,10 +589,11 @@ |
364 | "query_multiple_screenshos" was run before and emited the signal |
365 | """ |
366 | if not self._screenshot_list: |
367 | - return [ {'small_image_url': self.thumbnail, |
368 | - 'large_image_url': self.screenshot, |
369 | - 'version': self.version}, |
370 | - ] |
371 | + return [{ |
372 | + 'small_image_url': self.thumbnail, |
373 | + 'large_image_url': self.screenshot, |
374 | + 'version': self.version, |
375 | + }] |
376 | return self._screenshot_list |
377 | |
378 | @property |
379 | @@ -583,17 +612,18 @@ |
380 | screenshot_url = self._doc.get_value(XapianValues.SCREENSHOT_URLS) |
381 | if screenshot_url and len(screenshot_url.split(",")) > 1: |
382 | for screenshot in screenshot_url.split(","): |
383 | - screenshot_list.append({'small_image_url' : screenshot, |
384 | - 'large_image_url' : screenshot, |
385 | - 'version' : self.version, |
386 | - }) |
387 | + screenshot_list.append({ |
388 | + 'small_image_url': screenshot, |
389 | + 'large_image_url': screenshot, |
390 | + 'version': self.version, |
391 | + }) |
392 | return screenshot_list |
393 | |
394 | def query_multiple_screenshots(self): |
395 | """ query if multiple screenshots for the given app are available |
396 | and if so, emit "screenshots-available" signal |
397 | """ |
398 | - # get screenshot list from the db, if that is empty thats fine, |
399 | + # get screenshot list from the db, if that is empty thats fine, |
400 | # and we will query the screenshot server |
401 | if not self._screenshot_list: |
402 | self._screenshot_list = self._get_multiple_screenshots_from_db() |
403 | @@ -612,7 +642,7 @@ |
404 | LOG.exception("failed to load content") |
405 | |
406 | def _sort_screenshots_by_best_version(self, screenshot_list): |
407 | - """ take a screenshot result dict from screenshots.debian.org |
408 | + """ take a screenshot result dict from screenshots.debian.org |
409 | and sort it |
410 | """ |
411 | from softwarecenter.utils import version_compare |
412 | @@ -624,9 +654,9 @@ |
413 | screenshot_list.remove(item) |
414 | # now sort from high to low |
415 | return sorted( |
416 | - screenshot_list, |
417 | - cmp=lambda a,b: version_compare(a["version"] or '', |
418 | - b["version"] or ''), |
419 | + screenshot_list, |
420 | + cmp=lambda a, b: version_compare(a["version"] or '', |
421 | + b["version"] or ''), |
422 | reverse=True) |
423 | |
424 | def _gio_screenshots_json_download_complete_cb(self, source, result, path): |
425 | @@ -649,7 +679,6 @@ |
426 | self._screenshot_list = self._sort_screenshots_by_best_version( |
427 | screenshot_list) |
428 | self.emit("screenshots-available", self._screenshot_list) |
429 | - return |
430 | |
431 | @property |
432 | def summary(self): |
433 | @@ -671,8 +700,10 @@ |
434 | if self._doc.get_value(XapianValues.THUMBNAIL_URL): |
435 | return self._doc.get_value(XapianValues.THUMBNAIL_URL) |
436 | # else use the default |
437 | - return self._distro.SCREENSHOT_THUMB_URL % { 'pkgname' : self.pkgname, |
438 | - 'version' : self.version or 0} |
439 | + return self._distro.SCREENSHOT_THUMB_URL % { |
440 | + 'pkgname': self.pkgname, |
441 | + 'version': self.version or 0, |
442 | + } |
443 | |
444 | @property |
445 | def video_url(self): |
446 | @@ -681,9 +712,10 @@ |
447 | if self._doc.get_value(XapianValues.VIDEO_URL): |
448 | return self._doc.get_value(XapianValues.VIDEO_URL) |
449 | # else use the video server |
450 | - #return self._distro.VIDEO_URL % { 'pkgname' : self.pkgname, |
451 | - # 'version' : self.version or 0} |
452 | - return None |
453 | + #return self._distro.VIDEO_URL % { |
454 | + # 'pkgname' : self.pkgname, |
455 | + # 'version' : self.version or 0, |
456 | + #} |
457 | |
458 | @property |
459 | def version(self): |
460 | @@ -745,7 +777,8 @@ |
461 | # apturl minver matches |
462 | if not self.pkg_state == PkgStates.INSTALLED: |
463 | if self._app.request: |
464 | - minver_matches = re.findall(r'minver=[a-z,0-9,-,+,.,~]*', self._app.request) |
465 | + minver_matches = re.findall(r'minver=[a-z,0-9,-,+,.,~]*', |
466 | + self._app.request) |
467 | if minver_matches and self.version: |
468 | minver = minver_matches[0][7:] |
469 | from softwarecenter.utils import version_compare |
470 | @@ -763,10 +796,11 @@ |
471 | sources = source_to_enable.split('&') |
472 | sources_length = len(sources) |
473 | if sources_length == 1: |
474 | - warning = _("Available from the \"%s\" source.") % sources[0] |
475 | + warning = (_("Available from the \"%s\" source.") % |
476 | + sources[0]) |
477 | elif sources_length > 1: |
478 | - # Translators: the visible string is constructed concatenating |
479 | - # the following 3 strings like this: |
480 | + # Translators: the visible string is constructed |
481 | + # concatenating the following 3 strings like this: |
482 | # Available from the following sources: %s, ... %s, %s. |
483 | warning = _("Available from the following sources: ") |
484 | # Cycle through all, but the last |
485 | @@ -805,7 +839,7 @@ |
486 | if tag.startswith(REGIONTAG): |
487 | # we found a region tag, now the region must match |
488 | res = False |
489 | - if tag == REGIONTAG+my_region: |
490 | + if tag == REGIONTAG + my_region: |
491 | # we have the right region |
492 | return True |
493 | return res |
494 | @@ -822,7 +856,7 @@ |
495 | result = {} |
496 | try: |
497 | from softwarecenter.hw import get_hardware_support_for_tags |
498 | - result = get_hardware_support_for_tags(self.tags) |
499 | + result = get_hardware_support_for_tags(self.tags) |
500 | except ImportError: |
501 | LOG.warn("failed to import debtagshw") |
502 | return result |
503 | @@ -835,7 +869,7 @@ |
504 | return not is_channel_available(self.channelname) |
505 | |
506 | def _unavailable_component(self, component_to_check=None): |
507 | - """ Check if the given doc refers to a component that is currently |
508 | + """ Check if the given doc refers to a component that is currently |
509 | not enabled |
510 | """ |
511 | if component_to_check: |
512 | @@ -843,7 +877,7 @@ |
513 | elif self.component: |
514 | component = self.component |
515 | else: |
516 | - component = self._doc.get_value(XapianValues.ARCHIVE_SECTION) |
517 | + component = self._doc.get_value(XapianValues.ARCHIVE_SECTION) |
518 | if not component: |
519 | return False |
520 | distro_codename = self._distro.get_codename() |
521 | @@ -870,7 +904,8 @@ |
522 | details.append(" installation_date: %s" % self.installation_date) |
523 | details.append(" purchase_date: %s" % self.purchase_date) |
524 | details.append(" license: %s" % self.license) |
525 | - details.append(" license_key: %s" % self.license_key[0:3] + len(self.license_key)*"*") |
526 | + details.append(" license_key: %s" % self.license_key[0:3] + |
527 | + len(self.license_key) * "*") |
528 | details.append(" license_key_path: %s" % self.license_key_path) |
529 | details.append(" date_published: %s" % self.date_published) |
530 | details.append(" maintenance_status: %s" % self.maintenance_status) |
531 | |
532 | === modified file 'softwarecenter/distro/Debian.py' |
533 | --- softwarecenter/distro/Debian.py 2011-12-16 10:10:10 +0000 |
534 | +++ softwarecenter/distro/Debian.py 2012-03-16 18:55:25 +0000 |
535 | @@ -22,14 +22,17 @@ |
536 | from softwarecenter.distro import Distro |
537 | from gettext import gettext as _ |
538 | |
539 | + |
540 | class Debian(Distro): |
541 | |
542 | # metapackages |
543 | IMPORTANT_METAPACKAGES = ("kde", "gnome", "gnome-desktop-environment") |
544 | |
545 | # screenshot handling |
546 | - SCREENSHOT_THUMB_URL = "http://screenshots.debian.net/thumbnail/%(pkgname)s" |
547 | - SCREENSHOT_LARGE_URL = "http://screenshots.debian.net/screenshot/%(pkgname)s" |
548 | + SCREENSHOT_THUMB_URL = ("http://screenshots.debian.net/" |
549 | + "thumbnail/%(pkgname)s") |
550 | + SCREENSHOT_LARGE_URL = ("http://screenshots.debian.net/" |
551 | + "screenshot/%(pkgname)s") |
552 | # the json description of the available screenshots |
553 | SCREENSHOT_JSON_URL = "http://screenshots.debian.net/json/package/%s" |
554 | |
555 | @@ -54,8 +57,9 @@ |
556 | for m in depends: |
557 | if cache[m].section == "metapackages": |
558 | primary = _("If you uninstall %s, future updates will not " |
559 | - "include new items in <b>%s</b> set. " |
560 | - "Are you sure you want to continue?") % (appname, cache[m].installed.summary) |
561 | + "include new items in <b>%s</b> set. " |
562 | + "Are you sure you want to continue?") % (appname, |
563 | + cache[m].installed.summary) |
564 | button_text = _("Remove Anyway") |
565 | depends = [] |
566 | break |
567 | @@ -71,7 +75,7 @@ |
568 | depends = None |
569 | break |
570 | return (primary, button_text) |
571 | - |
572 | + |
573 | def get_license_text(self, component): |
574 | if component in ("main",): |
575 | return _("Meets the Debian Free Software Guidelines") |
576 | @@ -106,7 +110,8 @@ |
577 | return True |
578 | return False |
579 | |
580 | - def get_maintenance_status(self, cache, appname, pkgname, component, channelname): |
581 | + def get_maintenance_status(self, cache, appname, pkgname, component, |
582 | + channelname): |
583 | """Return the maintenance status of a package.""" |
584 | if not hasattr(cache, '_cache') or not pkgname: |
585 | return |
586 | @@ -143,16 +148,17 @@ |
587 | elif pkg_archive == "unstable": |
588 | return _("Debian does not provide critical updates " |
589 | "for %s") % appname |
590 | - return |
591 | |
592 | def get_supported_query(self): |
593 | import xapian |
594 | - query1 = xapian.Query("XOL"+"Debian") |
595 | - query2 = xapian.Query("XOC"+"main") |
596 | + query1 = xapian.Query("XOL" + "Debian") |
597 | + query2 = xapian.Query("XOC" + "main") |
598 | return xapian.Query(xapian.Query.OP_AND, query1, query2) |
599 | |
600 | |
601 | if __name__ == "__main__": |
602 | cache = apt.Cache() |
603 | - print(cache.get_maintenance_status(cache, "synaptic app", "synaptic", "main", None)) |
604 | - print(cache.get_maintenance_status(cache, "3dchess app", "3dchess", "universe", None)) |
605 | + print(cache.get_maintenance_status(cache, "synaptic app", "synaptic", |
606 | + "main", None)) |
607 | + print(cache.get_maintenance_status(cache, "3dchess app", "3dchess", |
608 | + "universe", None)) |
609 | |
610 | === modified file 'softwarecenter/distro/Fedora.py' |
611 | --- softwarecenter/distro/Fedora.py 2011-12-16 12:50:18 +0000 |
612 | +++ softwarecenter/distro/Fedora.py 2012-03-16 18:55:25 +0000 |
613 | @@ -22,13 +22,14 @@ |
614 | from softwarecenter.distro import Distro |
615 | from gettext import gettext as _ |
616 | |
617 | + |
618 | class Fedora(Distro): |
619 | DISTROSERIES = [ |
620 | - 'Beefy Miracle', |
621 | - 'Verne', |
622 | - 'Lovelock', |
623 | - 'Laughlin', |
624 | - 'Leonidas', |
625 | + 'Beefy Miracle', |
626 | + 'Verne', |
627 | + 'Lovelock', |
628 | + 'Laughlin', |
629 | + 'Leonidas', |
630 | 'Constantine', |
631 | ] |
632 | |
633 | @@ -37,25 +38,29 @@ |
634 | |
635 | # screenshot handling |
636 | # FIXME - fedora should get its own proxy eventually |
637 | - SCREENSHOT_THUMB_URL = "http://screenshots.ubuntu.com/thumbnail-with-version/%(pkgname)s/%(version)s" |
638 | - SCREENSHOT_LARGE_URL = "http://screenshots.ubuntu.com/screenshot-with-version/%(pkgname)s/%(version)s" |
639 | + SCREENSHOT_THUMB_URL = ("http://screenshots.ubuntu.com/" |
640 | + "thumbnail-with-version/%(pkgname)s/%(version)s") |
641 | + SCREENSHOT_LARGE_URL = ("http://screenshots.ubuntu.com/" |
642 | + "screenshot-with-version/%(pkgname)s/%(version)s") |
643 | SCREENSHOT_JSON_URL = "http://screenshots.ubuntu.com/json/package/%s" |
644 | - |
645 | + |
646 | # reviews |
647 | # FIXME: fedora will want to get their own review server instance at |
648 | # some point I imagine :) (or a alternative backend) |
649 | # |
650 | - REVIEWS_SERVER = os.environ.get("SOFTWARE_CENTER_REVIEWS_HOST") or "http://reviews.ubuntu.com/reviews/api/1.0" |
651 | - REVIEWS_URL = REVIEWS_SERVER + "/reviews/filter/%(language)s/%(origin)s/%(distroseries)s/%(version)s/%(pkgname)s%(appname)s/" |
652 | + REVIEWS_SERVER = (os.environ.get("SOFTWARE_CENTER_REVIEWS_HOST") or |
653 | + "http://reviews.ubuntu.com/reviews/api/1.0") |
654 | + REVIEWS_URL = (REVIEWS_SERVER + "/reviews/filter/%(language)s/%(origin)s/" |
655 | + "%(distroseries)s/%(version)s/%(pkgname)s%(appname)s/") |
656 | |
657 | - REVIEW_STATS_URL = REVIEWS_SERVER+"/review-stats" |
658 | + REVIEW_STATS_URL = REVIEWS_SERVER + "/review-stats" |
659 | |
660 | def get_distro_channel_name(self): |
661 | """ The name of the primary repository """ |
662 | return "fedora" |
663 | |
664 | def get_distro_channel_description(self): |
665 | - """ The description of the main distro channel |
666 | + """ The description of the main distro channel |
667 | Overrides what's present in yum.conf for fedora, updates, |
668 | updates-testing, their respective -source and -debuginfo |
669 | """ |
670 | @@ -70,7 +75,7 @@ |
671 | button_text = _("Remove All") |
672 | |
673 | return (primary, button_text) |
674 | - |
675 | + |
676 | def get_license_text(self, component): |
677 | # with a PackageKit backend, component is always 'main' |
678 | # (but we have license in the individual packages) |
679 | @@ -86,13 +91,13 @@ |
680 | origin = cache.get_origin(pkgname) |
681 | return origin == 'fedora' or origin == 'updates' |
682 | |
683 | - def get_maintenance_status(self, cache, appname, pkgname, component, channelname): |
684 | + def get_maintenance_status(self, cache, appname, pkgname, component, |
685 | + channelname): |
686 | # FIXME |
687 | - return |
688 | + pass |
689 | |
690 | def get_supported_query(self): |
691 | import xapian |
692 | - query1 = xapian.Query("XOO"+"fedora") |
693 | - query2 = xapian.Query("XOO"+"updates") |
694 | + query1 = xapian.Query("XOO" + "fedora") |
695 | + query2 = xapian.Query("XOO" + "updates") |
696 | return xapian.Query(xapian.Query.OP_OR, query1, query2) |
697 | - |
698 | |
699 | === modified file 'softwarecenter/distro/SUSELINUX.py' |
700 | --- softwarecenter/distro/SUSELINUX.py 2011-11-02 14:13:26 +0000 |
701 | +++ softwarecenter/distro/SUSELINUX.py 2012-03-16 18:55:25 +0000 |
702 | @@ -20,28 +20,33 @@ |
703 | from gettext import gettext as _ |
704 | from softwarecenter.distro import Distro |
705 | |
706 | + |
707 | class SUSELINUX(Distro): |
708 | # see __init__.py description |
709 | DISTROSERIES = ["11.4", |
710 | ] |
711 | |
712 | # screenshot handling |
713 | - SCREENSHOT_THUMB_URL = "http://screenshots.ubuntu.com/thumbnail-with-version/%(pkgname)s/%(version)s" |
714 | - SCREENSHOT_LARGE_URL = "http://screenshots.ubuntu.com/screenshot-with-version/%(pkgname)s/%(version)s" |
715 | + SCREENSHOT_THUMB_URL = ("http://screenshots.ubuntu.com/" |
716 | + "thumbnail-with-version/%(pkgname)s/%(version)s") |
717 | + SCREENSHOT_LARGE_URL = ("http://screenshots.ubuntu.com/" |
718 | + "screenshot-with-version/%(pkgname)s/%(version)s") |
719 | SCREENSHOT_JSON_URL = "http://screenshots.ubuntu.com/json/package/%s" |
720 | - |
721 | + |
722 | # reviews |
723 | - REVIEWS_SERVER = os.environ.get("SOFTWARE_CENTER_REVIEWS_HOST") or "http://reviews.ubuntu.com/reviews/api/1.0" |
724 | - REVIEWS_URL = REVIEWS_SERVER + "/reviews/filter/%(language)s/%(origin)s/%(distroseries)s/%(version)s/%(pkgname)s%(appname)s/" |
725 | + REVIEWS_SERVER = (os.environ.get("SOFTWARE_CENTER_REVIEWS_HOST") or |
726 | + "http://reviews.ubuntu.com/reviews/api/1.0") |
727 | + REVIEWS_URL = (REVIEWS_SERVER + "/reviews/filter/%(language)s/%(origin)s/" |
728 | + "%(distroseries)s/%(version)s/%(pkgname)s%(appname)s/") |
729 | |
730 | - REVIEW_STATS_URL = REVIEWS_SERVER+"/review-stats" |
731 | + REVIEW_STATS_URL = REVIEWS_SERVER + "/review-stats" |
732 | |
733 | def get_app_name(self): |
734 | return _("Software Center") |
735 | |
736 | def get_app_description(self): |
737 | return _("Lets you choose from thousands of applications available.") |
738 | - |
739 | + |
740 | def get_distro_channel_name(self): |
741 | """ The name in the Release file """ |
742 | return "openSUSE" |
743 | @@ -70,17 +75,17 @@ |
744 | def get_supported_query(self): |
745 | # FIXME |
746 | import xapian |
747 | - query1 = xapian.Query("XOL"+"Ubuntu") |
748 | - query2a = xapian.Query("XOC"+"main") |
749 | - query2b = xapian.Query("XOC"+"restricted") |
750 | + query1 = xapian.Query("XOL" + "Ubuntu") |
751 | + query2a = xapian.Query("XOC" + "main") |
752 | + query2b = xapian.Query("XOC" + "restricted") |
753 | query2 = xapian.Query(xapian.Query.OP_OR, query2a, query2b) |
754 | return xapian.Query(xapian.Query.OP_AND, query1, query2) |
755 | |
756 | - def get_maintenance_status(self, cache, appname, pkgname, component, channelname): |
757 | + def get_maintenance_status(self, cache, appname, pkgname, component, |
758 | + channelname): |
759 | # FIXME |
760 | - return |
761 | + pass |
762 | |
763 | def get_downloadable_icon_url(self, full_archive_url, icon_filename): |
764 | # FIXME |
765 | - return None |
766 | - |
767 | + pass |
768 | |
769 | === modified file 'softwarecenter/distro/Ubuntu.py' |
770 | --- softwarecenter/distro/Ubuntu.py 2012-03-06 15:00:23 +0000 |
771 | +++ softwarecenter/distro/Ubuntu.py 2012-03-16 18:55:25 +0000 |
772 | @@ -31,6 +31,7 @@ |
773 | |
774 | LOG = logging.getLogger(__name__) |
775 | |
776 | + |
777 | class Ubuntu(Debian): |
778 | |
779 | # see __init__.py description |
780 | @@ -43,22 +44,28 @@ |
781 | IMPORTANT_METAPACKAGES = ("ubuntu-desktop", "kubuntu-desktop") |
782 | |
783 | # screenshot handling |
784 | - SCREENSHOT_THUMB_URL = "http://screenshots.ubuntu.com/thumbnail-with-version/%(pkgname)s/%(version)s" |
785 | - SCREENSHOT_LARGE_URL = "http://screenshots.ubuntu.com/screenshot-with-version/%(pkgname)s/%(version)s" |
786 | + SCREENSHOT_THUMB_URL = ("http://screenshots.ubuntu.com/" |
787 | + "thumbnail-with-version/%(pkgname)s/%(version)s") |
788 | + SCREENSHOT_LARGE_URL = ("http://screenshots.ubuntu.com/" |
789 | + "screenshot-with-version/%(pkgname)s/%(version)s") |
790 | |
791 | # the json description of the available screenshots |
792 | SCREENSHOT_JSON_URL = "http://screenshots.ubuntu.com/json/package/%s" |
793 | |
794 | # purchase subscription |
795 | - PURCHASE_APP_URL = BUY_SOMETHING_HOST+"/subscriptions/%s/ubuntu/%s/+new/?%s" |
796 | + PURCHASE_APP_URL = (BUY_SOMETHING_HOST + "/subscriptions/%s/ubuntu/%s/" |
797 | + "+new/?%s") |
798 | |
799 | # reviews |
800 | - REVIEWS_SERVER = os.environ.get("SOFTWARE_CENTER_REVIEWS_HOST") or "http://reviews.ubuntu.com/reviews/api/1.0" |
801 | - REVIEWS_URL = REVIEWS_SERVER + "/reviews/filter/%(language)s/%(origin)s/%(distroseries)s/%(version)s/%(pkgname)s%(appname)s/" |
802 | + REVIEWS_SERVER = (os.environ.get("SOFTWARE_CENTER_REVIEWS_HOST") or |
803 | + "http://reviews.ubuntu.com/reviews/api/1.0") |
804 | + REVIEWS_URL = (REVIEWS_SERVER + "/reviews/filter/%(language)s/%(origin)s/" |
805 | + "%(distroseries)s/%(version)s/%(pkgname)s%(appname)s/") |
806 | |
807 | - #REVIEW_STATS_URL = REVIEWS_SERVER+"/reviews/api/1.0/%(language)s/%(origin)s/%(distroseries)s/review-stats/" |
808 | + #REVIEW_STATS_URL = (REVIEWS_SERVER + "/reviews/api/1.0/%(language)s/" |
809 | + # "%(origin)s/%(distroseries)s/review-stats/") |
810 | # FIXME: does that make sense?!? |
811 | - REVIEW_STATS_URL = REVIEWS_SERVER+"/review-stats" |
812 | + REVIEW_STATS_URL = REVIEWS_SERVER + "/review-stats" |
813 | |
814 | # Starting point for Ubuntu app developers |
815 | DEVELOPER_URL = "http://developer.ubuntu.com/" |
816 | @@ -67,8 +74,9 @@ |
817 | return _("Ubuntu Software Center") |
818 | |
819 | def get_app_description(self): |
820 | - return _("Lets you choose from thousands of applications available for Ubuntu.") |
821 | - |
822 | + return _("Lets you choose from thousands of applications available " |
823 | + "for Ubuntu.") |
824 | + |
825 | def get_distro_channel_name(self): |
826 | """ The name in the Release file """ |
827 | return "Ubuntu" |
828 | @@ -87,7 +95,8 @@ |
829 | if cache[m].section == "metapackages": |
830 | primary = _("If you uninstall %s, future updates will not " |
831 | "include new items in <b>%s</b> set. " |
832 | - "Are you sure you want to continue?") % (appname, cache[m].installed.summary) |
833 | + "Are you sure you want to continue?") % (appname, |
834 | + cache[m].installed.summary) |
835 | button_text = _("Remove Anyway") |
836 | depends = [] |
837 | break |
838 | @@ -110,9 +119,10 @@ |
839 | elif component == "restricted": |
840 | return _("Proprietary") |
841 | else: |
842 | - # commercial apps provide license info via the software-center-agent, |
843 | - # but if a given commercial app does not provide this for some reason, |
844 | - # default to a license type of "Unknown" |
845 | + # commercial apps provide license info via the |
846 | + # software-center-agent, but if a given commercial app does not |
847 | + # provide this for some reason, default to a license type of |
848 | + # "Unknown" |
849 | return _("Unknown") |
850 | |
851 | def is_supported(self, cache, doc, pkgname): |
852 | @@ -120,8 +130,8 @@ |
853 | # section. Looking up in the cache seems just as fast/slow. |
854 | if pkgname in cache and cache[pkgname].candidate: |
855 | for origin in cache[pkgname].candidate.origins: |
856 | - if (origin.origin == "Ubuntu" and |
857 | - origin.trusted and |
858 | + if (origin.origin == "Ubuntu" and |
859 | + origin.trusted and |
860 | (origin.component == "main" or |
861 | origin.component == "restricted")): |
862 | return True |
863 | @@ -129,25 +139,26 @@ |
864 | |
865 | def get_supported_query(self): |
866 | import xapian |
867 | - query1 = xapian.Query("XOL"+"Ubuntu") |
868 | - query2a = xapian.Query("XOC"+"main") |
869 | - query2b = xapian.Query("XOC"+"restricted") |
870 | + query1 = xapian.Query("XOL" + "Ubuntu") |
871 | + query2a = xapian.Query("XOC" + "main") |
872 | + query2b = xapian.Query("XOC" + "restricted") |
873 | query2 = xapian.Query(xapian.Query.OP_OR, query2a, query2b) |
874 | return xapian.Query(xapian.Query.OP_AND, query1, query2) |
875 | |
876 | def get_supported_filter_name(self): |
877 | return _("Canonical-Maintained Software") |
878 | |
879 | - def get_maintenance_status(self, cache, appname, pkgname, component, channelname): |
880 | + def get_maintenance_status(self, cache, appname, pkgname, component, |
881 | + channelname): |
882 | # try to figure out the support dates of the release and make |
883 | # sure to look only for stuff in "Ubuntu" and "distro_codename" |
884 | - # (to exclude stuff in ubuntu-updates for the support time |
885 | + # (to exclude stuff in ubuntu-updates for the support time |
886 | # calculation because the "Release" file time for that gets |
887 | # updated regularly) |
888 | if not hasattr(cache, '_cache') or not pkgname: |
889 | return |
890 | - releasef = get_release_filename_for_pkg(cache._cache, pkgname, |
891 | - "Ubuntu", |
892 | + releasef = get_release_filename_for_pkg(cache._cache, pkgname, |
893 | + "Ubuntu", |
894 | self.get_codename()) |
895 | time_t = get_release_date_from_release_file(releasef) |
896 | # check the release date and show support information |
897 | @@ -165,23 +176,27 @@ |
898 | # see if we have a "Supported" entry in the pkg record |
899 | if (pkgname in cache and |
900 | cache[pkgname].candidate): |
901 | - support_time = cache._cache[pkgname].candidate.record.get("Supported") |
902 | + support_time = cache._cache[pkgname].candidate.record.get( |
903 | + "Supported") |
904 | if support_time: |
905 | if support_time.endswith("y"): |
906 | - support_month = 12*int(support_time.strip("y")) |
907 | + support_month = 12 * int(support_time.strip("y")) |
908 | elif support_time.endswith("m"): |
909 | support_month = int(support_time.strip("m")) |
910 | else: |
911 | - LOG.warning("unsupported 'Supported' string '%s'" % support_time) |
912 | + LOG.warning("unsupported 'Supported' string '%s'" % |
913 | + support_time) |
914 | |
915 | # mvo: we do not define the end date very precisely |
916 | # currently this is why it will just display a end |
917 | # range |
918 | # print release_date, support_month |
919 | - (support_end_year, support_end_month) = get_maintenance_end_date(release_date, support_month) |
920 | - support_end_month_str = locale.nl_langinfo(getattr(locale,"MON_%d" % support_end_month)) |
921 | + (support_end_year, support_end_month) = get_maintenance_end_date( |
922 | + release_date, support_month) |
923 | + support_end_month_str = locale.nl_langinfo( |
924 | + getattr(locale, "MON_%d" % support_end_month)) |
925 | # check if the support has ended |
926 | - support_ended = (now.year >= support_end_year and |
927 | + support_ended = (now.year >= support_end_year and |
928 | now.month > support_end_month) |
929 | if component == "main": |
930 | if support_ended: |
931 | @@ -192,9 +207,10 @@ |
932 | else: |
933 | return _("Canonical provides critical updates for " |
934 | "%(appname)s until %(support_end_month_str)s " |
935 | - "%(support_end_year)s.") % {'appname' : appname, |
936 | - 'support_end_month_str' : support_end_month_str, |
937 | - 'support_end_year' : support_end_year} |
938 | + "%(support_end_year)s.") % { |
939 | + 'appname': appname, |
940 | + 'support_end_month_str': support_end_month_str, |
941 | + 'support_end_year': support_end_year} |
942 | elif component == "restricted": |
943 | if support_ended: |
944 | return _("Canonical does no longer provide " |
945 | @@ -205,10 +221,12 @@ |
946 | return _("Canonical provides critical updates supplied " |
947 | "by the developers of %(appname)s until " |
948 | "%(support_end_month_str)s " |
949 | - "%(support_end_year)s.") % {'appname' : appname, |
950 | - 'support_end_month_str' : support_end_month_str, |
951 | - 'support_end_year' : support_end_year} |
952 | - |
953 | + "%(support_end_year)s.") % { |
954 | + 'appname': appname, |
955 | + 'support_end_month_str': support_end_month_str, |
956 | + 'support_end_year': support_end_year, |
957 | + } |
958 | + |
959 | # if we couldn't determine a support date, use a generic maintenance |
960 | # string without the date |
961 | if (channelname or |
962 | @@ -223,8 +241,8 @@ |
963 | return _("Canonical does not provide updates for %s. " |
964 | "Some updates may be provided by the " |
965 | "Ubuntu community.") % appname |
966 | - #return _("Application %s has an unknown maintenance status.") % appname |
967 | - return |
968 | + #return (_("Application %s has an unknown maintenance status.") % |
969 | + # appname) |
970 | |
971 | def get_downloadable_icon_url(self, full_archive_url, icon_filename): |
972 | """ |
973 | @@ -250,12 +268,16 @@ |
974 | downloadable_icon_url.append(icon_filename) |
975 | return "".join(downloadable_icon_url) |
976 | else: |
977 | - #raise ValueError, "we currently support downloadable icons in ppa's only" |
978 | - LOG.warning("downloadable icon is not supported for archive: '%s'" % full_archive_url) |
979 | + #raise ValueError("we currently support downloadable icons in " |
980 | + # "ppa's only") |
981 | + LOG.warning("downloadable icon is not supported for archive: '%s'" |
982 | + % full_archive_url) |
983 | return '' |
984 | |
985 | if __name__ == "__main__": |
986 | import apt |
987 | cache = apt.Cache() |
988 | - print cache.get_maintenance_status(cache, "synaptic app", "synaptic", "main", None) |
989 | - print cache.get_maintenance_status(cache, "3dchess app", "3dchess", "universe", None) |
990 | + print cache.get_maintenance_status(cache, "synaptic app", "synaptic", |
991 | + "main", None) |
992 | + print cache.get_maintenance_status(cache, "3dchess app", "3dchess", |
993 | + "universe", None) |
994 | |
995 | === modified file 'softwarecenter/distro/__init__.py' |
996 | --- softwarecenter/distro/__init__.py 2012-01-27 09:46:41 +0000 |
997 | +++ softwarecenter/distro/__init__.py 2012-03-16 18:55:25 +0000 |
998 | @@ -36,9 +36,12 @@ |
999 | # are found |
1000 | DISTROSERIES = [] |
1001 | |
1002 | - # base path for the review summary, the JS will append %i.png (with i={1,5}) |
1003 | - REVIEW_SUMMARY_STARS_BASE_PATH = "/usr/share/software-center/images/review-summary" |
1004 | - REVIEWS_SERVER = os.environ.get("SOFTWARE_CENTER_REVIEWS_HOST") or "http://localhost:8000" |
1005 | + # base path for the review summary, the JS will append %i.png |
1006 | + # (with i={1,5}) |
1007 | + REVIEW_SUMMARY_STARS_BASE_PATH = ("/usr/share/software-center/images/" |
1008 | + "review-summary") |
1009 | + REVIEWS_SERVER = (os.environ.get("SOFTWARE_CENTER_REVIEWS_HOST") or |
1010 | + "http://localhost:8000") |
1011 | |
1012 | # You need to set this var to enable purchases |
1013 | PURCHASE_APP_URL = "" |
1014 | @@ -50,23 +53,23 @@ |
1015 | """Return a new generic Distro instance.""" |
1016 | |
1017 | def get_app_name(self): |
1018 | - """ |
1019 | - The name of the application (as displayed in the main window and |
1020 | + """ |
1021 | + The name of the application (as displayed in the main window and |
1022 | the about window) |
1023 | """ |
1024 | return _("Software Center") |
1025 | |
1026 | def get_app_description(self): |
1027 | - """ |
1028 | + """ |
1029 | The description of the application displayed in the about dialog |
1030 | """ |
1031 | - return _("Lets you choose from thousands of applications available for your system.") |
1032 | - |
1033 | + return _("Lets you choose from thousands of applications available " |
1034 | + "for your system.") |
1035 | |
1036 | def get_distro_channel_name(self): |
1037 | """ The name of the main channel in the Release file (e.g. Ubuntu)""" |
1038 | return "none" |
1039 | - |
1040 | + |
1041 | def get_distro_channel_description(self): |
1042 | """ The description for the main distro channel """ |
1043 | return "none" |
1044 | @@ -83,15 +86,16 @@ |
1045 | self._distro_code_name = platform.dist()[2] |
1046 | return self._distro_code_name |
1047 | |
1048 | - def get_maintenance_status(self, cache, appname, pkgname, component, channelname): |
1049 | + def get_maintenance_status(self, cache, appname, pkgname, component, |
1050 | + channelname): |
1051 | raise UnimplementedError |
1052 | |
1053 | def get_license_text(self, component): |
1054 | raise UnimplementedError |
1055 | |
1056 | def is_supported(self, cache, doc, pkgname): |
1057 | - """ |
1058 | - return True if the given document and pkgname is supported by |
1059 | + """ |
1060 | + return True if the given document and pkgname is supported by |
1061 | the distribution |
1062 | """ |
1063 | raise UnimplementedError |
1064 | @@ -105,7 +109,8 @@ |
1065 | return _("Supported Software") |
1066 | |
1067 | def get_install_warning_text(self, cache, pkg, appname, depends): |
1068 | - primary = utf8(_("To install %s, these items must be removed:")) % utf8(appname) |
1069 | + primary = (utf8(_("To install %s, these items must be removed:")) % |
1070 | + utf8(appname)) |
1071 | button_text = _("Install Anyway") |
1072 | |
1073 | # alter it if a meta-package is affected |
1074 | @@ -113,7 +118,8 @@ |
1075 | if cache[m].section == "metapackages": |
1076 | primary = utf8(_("If you install %s, future updates will not " |
1077 | "include new items in <b>%s</b> set. " |
1078 | - "Are you sure you want to continue?")) % (utf8(appname), cache[m].installed.summary) |
1079 | + "Are you sure you want to continue?")) % ( |
1080 | + utf8(appname), cache[m].installed.summary) |
1081 | button_text = _("Install Anyway") |
1082 | depends = [] |
1083 | break |
1084 | @@ -121,9 +127,9 @@ |
1085 | # alter it if an important meta-package is affected |
1086 | for m in self.IMPORTANT_METAPACKAGES: |
1087 | if m in depends: |
1088 | - primary = utf8(_("Installing %s may cause core applications to " |
1089 | - "be removed. " |
1090 | - "Are you sure you want to continue?")) % utf8(appname) |
1091 | + primary = utf8(_("Installing %s may cause core applications " |
1092 | + "to be removed. Are you sure you want to " |
1093 | + "continue?")) % utf8(appname) |
1094 | button_text = _("Install Anyway") |
1095 | depends = None |
1096 | break |
1097 | @@ -133,16 +139,17 @@ |
1098 | def get_deauthorize_text(self, account_name, purchased_packages): |
1099 | if len(purchased_packages) == 0: |
1100 | if account_name: |
1101 | - primary = _('Are you sure you want to deauthorize this computer ' |
1102 | - 'from the "%s" account?') % account_name |
1103 | + primary = _('Are you sure you want to deauthorize this ' |
1104 | + 'computer from the "%s" account?') % account_name |
1105 | else: |
1106 | - primary = _('Are you sure you want to deauthorize this computer ' |
1107 | - 'for purchases?') |
1108 | + primary = _('Are you sure you want to deauthorize this ' |
1109 | + 'computer for purchases?') |
1110 | button_text = _('Deauthorize') |
1111 | else: |
1112 | if account_name: |
1113 | - primary = _('Deauthorizing this computer from the "%s" account ' |
1114 | - 'will remove this purchased software:') % account_name |
1115 | + primary = _('Deauthorizing this computer from the "%s" ' |
1116 | + 'account will remove this purchased ' |
1117 | + 'software:') % account_name |
1118 | else: |
1119 | primary = _('Deauthorizing this computer for purchases ' |
1120 | 'will remove the following purchased software:') |
1121 | @@ -151,7 +158,7 @@ |
1122 | |
1123 | # generic architecture detection code |
1124 | def get_architecture(self): |
1125 | - return None |
1126 | + pass |
1127 | |
1128 | |
1129 | def _get_distro(): |
1130 | @@ -159,16 +166,18 @@ |
1131 | distro_id = distro_info[0] |
1132 | LOG.debug("get_distro: '%s'", distro_id) |
1133 | # start with a import, this gives us only a softwarecenter module |
1134 | - module = __import__(distro_id, globals(), locals(), [], -1) |
1135 | + module = __import__(distro_id, globals(), locals(), [], -1) |
1136 | # get the right class and instanciate it |
1137 | distro_class = getattr(module, distro_id) |
1138 | instance = distro_class() |
1139 | return instance |
1140 | |
1141 | + |
1142 | def get_distro(): |
1143 | """ factory to return the right Distro object """ |
1144 | return distro_instance |
1145 | |
1146 | + |
1147 | def get_current_arch(): |
1148 | # for tests and similar |
1149 | if "SOFTWARE_CENTER_ARCHITECTURE" in os.environ: |
1150 | @@ -177,11 +186,12 @@ |
1151 | return arch |
1152 | return get_distro().get_architecture() |
1153 | |
1154 | + |
1155 | def get_foreign_architectures(): |
1156 | return get_distro().get_foreign_architectures() |
1157 | |
1158 | # singelton |
1159 | -distro_instance=_get_distro() |
1160 | +distro_instance = _get_distro() |
1161 | |
1162 | |
1163 | if __name__ == "__main__": |
1164 | |
1165 | === modified file 'test/test_pep8.py' |
1166 | --- test/test_pep8.py 2012-03-15 10:43:13 +0000 |
1167 | +++ test/test_pep8.py 2012-03-16 18:55:25 +0000 |
1168 | @@ -9,13 +9,15 @@ |
1169 | # Only test these two packages for now: |
1170 | import softwarecenter.db |
1171 | import softwarecenter.ui |
1172 | +import softwarecenter.distro |
1173 | |
1174 | class PackagePep8TestCase(unittest.TestCase): |
1175 | maxDiff = None |
1176 | packages = [softwarecenter.ui, |
1177 | softwarecenter.db, |
1178 | + softwarecenter.distro, |
1179 | ] |
1180 | - exclude = ['application.py', 'appfilter.py'] |
1181 | + exclude = [] |
1182 | |
1183 | def message(self, text): |
1184 | self.errors.append(text) |
Pins pep8 badge to achuni's chest. Salutes.