Merge lp:~robin-gloster/ubuntu-accomplishments-viewer/pep8 into lp:ubuntu-accomplishments-viewer

Proposed by Robin Gloster
Status: Merged
Merged at revision: 223
Proposed branch: lp:~robin-gloster/ubuntu-accomplishments-viewer/pep8
Merge into: lp:ubuntu-accomplishments-viewer
Diff against target: 2812 lines (+637/-620)
16 files modified
Changelog (+3/-1)
accomplishments_viewer/AboutAccomplishmentsViewerDialog.py (+18/-16)
accomplishments_viewer/AccomplishmentsViewerWindow.py (+365/-354)
accomplishments_viewer/EditExtrainfoDialog.py (+74/-79)
accomplishments_viewer/PreferencesAccomplishmentsViewerDialog.py (+23/-26)
accomplishments_viewer/__init__.py (+18/-15)
accomplishments_viewer_lib/AboutDialog.py (+13/-13)
accomplishments_viewer_lib/Builder.py (+20/-21)
accomplishments_viewer_lib/PreferencesDialog.py (+13/-13)
accomplishments_viewer_lib/Window.py (+20/-19)
accomplishments_viewer_lib/__init__.py (+8/-9)
accomplishments_viewer_lib/accomplishments_viewerconfig.py (+9/-10)
accomplishments_viewer_lib/helpers.py (+18/-12)
bin/accomplishments-viewer (+11/-11)
tests/test_example.py (+13/-10)
tests/test_lint.py (+11/-11)
To merge this branch: bzr merge lp:~robin-gloster/ubuntu-accomplishments-viewer/pep8
Reviewer Review Type Date Requested Status
Rafał Cieślak Approve
Matt Fischer Approve
Review via email: mp+136211@code.launchpad.net

Description of the change

Fixed most pep8 issues

To post a comment you must log in.
Revision history for this message
Matt Fischer (mfisch) wrote :

Here's a diff with all whitespace changes removed:

http://paste.ubuntu.com/1390196/

Revision history for this message
Matt Fischer (mfisch) wrote :

Looks fine to me, but Cielak should also look, also what testing did you do?

review: Approve
Revision history for this message
Robin Gloster (robin-gloster) wrote :

Visited all pages and changed everything in the viewer i could find and
think of.
From what I could tell it should work exactly as before except for the k ->
kid fix which should have killed the viewer before.

2012/11/26 Matt Fischer <email address hidden>

> Review: Approve
>
> Looks fine to me, but Cielak should also look, also what testing did you
> do?
> --
>
> https://code.launchpad.net/~robin-gloster/ubuntu-accomplishments-viewer/pep8/+merge/136211
> You are the owner of lp:~robin-gloster/ubuntu-accomplishments-viewer/pep8.
>

Revision history for this message
Rafał Cieślak (rafalcieslak256) wrote :

I have carefully reviewed these changes, and they seem perfectly fine. I have also did a bunch of tests for the viewer, and as expected - nothing suspicious could be detected. Thanks Robin for these fixes!

review: Approve
221. By Rafał Cieślak

Merging in the branch that introduces use of GtkInfoBars for notifications

222. By Rafał Cieślak

Fixed #1084058.

Revision history for this message
Matt Fischer (mfisch) wrote :

Rafal,

Are you going to merge this?

223. By Rafał Cieślak

Merged in Robin's PEP fixes

Revision history for this message
Rafał Cieślak (rafalcieslak256) wrote :

Just merged it in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Changelog'
--- Changelog 2012-11-22 10:45:38 +0000
+++ Changelog 2012-11-26 16:03:25 +0000
@@ -6,7 +6,7 @@
6Add items using the following format:6Add items using the following format:
77
8 [Name]8 [Name]
9 * What you did 9 * What you did
10 * If a bug (LP: #BUGNUMBER)10 * If a bug (LP: #BUGNUMBER)
1111
12 For example:12 For example:
@@ -30,4 +30,6 @@
30 * Fix lintian issues30 * Fix lintian issues
31 * Added a manpage (LP: #1069264)31 * Added a manpage (LP: #1069264)
3232
33 [Robin Gloster]
34 * Fixed most PEP8 issues
33-------------------------------------------------------------------------35-------------------------------------------------------------------------
3436
=== modified file 'accomplishments_viewer/AboutAccomplishmentsViewerDialog.py'
--- accomplishments_viewer/AboutAccomplishmentsViewerDialog.py 2012-09-13 19:19:11 +0000
+++ accomplishments_viewer/AboutAccomplishmentsViewerDialog.py 2012-11-26 16:03:25 +0000
@@ -1,24 +1,25 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2### BEGIN LICENSE2### BEGIN LICENSE
3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>
4# This program is free software: you can redistribute it and/or modify it 4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published 5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.6# by the Free Software Foundation.
7# 7#
8# This program is distributed in the hope that it will be useful, but 8# This program is distributed in the hope that it will be useful, but
9# WITHOUT ANY WARRANTY; without even the implied warranties of 9# WITHOUT ANY WARRANTY; without even the implied warranties of
10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11# PURPOSE. See the GNU General Public License for more details.11# PURPOSE. See the GNU General Public License for more details.
12# 12#
13# You should have received a copy of the GNU General Public License along 13# You should have received a copy of the GNU General Public License along
14# with this program. If not, see <http://www.gnu.org/licenses/>.14# with this program. If not, see <http://www.gnu.org/licenses/>.
15### END LICENSE15### END LICENSE
1616
17import gettext, locale17import gettext
18import locale
18from locale import gettext as _19from locale import gettext as _
19from accomplishments.util.paths import locale_dir20from accomplishments.util.paths import locale_dir
20locale.bindtextdomain('accomplishments-viewer', locale_dir)21locale.bindtextdomain('accomplishments-viewer', locale_dir)
21gettext.bindtextdomain('accomplishments-viewer',locale_dir)22gettext.bindtextdomain('accomplishments-viewer', locale_dir)
22locale.textdomain('accomplishments-viewer')23locale.textdomain('accomplishments-viewer')
2324
24from accomplishments.daemon import dbusapi25from accomplishments.daemon import dbusapi
@@ -28,11 +29,12 @@
2829
29from accomplishments_viewer_lib.AboutDialog import AboutDialog30from accomplishments_viewer_lib.AboutDialog import AboutDialog
3031
32
31# See accomplishments_viewer_lib.AboutDialog.py for more details about how this class works.33# See accomplishments_viewer_lib.AboutDialog.py for more details about how this class works.
32class AboutAccomplishmentsViewerDialog(AboutDialog):34class AboutAccomplishmentsViewerDialog(AboutDialog):
33 __gtype_name__ = "AboutAccomplishmentsViewerDialog"35 __gtype_name__ = "AboutAccomplishmentsViewerDialog"
34 36
35 def finish_initializing(self, builder): # pylint: disable=E100237 def finish_initializing(self, builder): # pylint: disable=E1002
36 """Set up the about dialog"""38 """Set up the about dialog"""
37 super(AboutAccomplishmentsViewerDialog, self).finish_initializing(builder)39 super(AboutAccomplishmentsViewerDialog, self).finish_initializing(builder)
3840
@@ -41,17 +43,17 @@
41 self.libaccom = dbusapi.Accomplishments()43 self.libaccom = dbusapi.Accomplishments()
4244
43 # add app authors45 # add app authors
44 authors = sorted([ "Jono Bacon <jono@ubuntu.com>", "Rafal Cieślak <rafalcieslak256@gmail.com>", "Matt Fischer <matt@mattfischer.com>", "Stuart Langridge <sil@kryogenix.org>"])46 authors = sorted(["Jono Bacon <jono@ubuntu.com>", "Rafal Cieślak <rafalcieslak256@gmail.com>", "Matt Fischer <matt@mattfischer.com>", "Stuart Langridge <sil@kryogenix.org>"])
45 47
46 for col in self.libaccom.list_collections():48 for col in self.libaccom.list_collections():
47 authors.append(" ")49 authors.append(" ")
48 authors.append("'" + self.libaccom.get_collection_name(col) + "' " + _("Collection Authors:"))50 authors.append("'" + self.libaccom.get_collection_name(col) + "' " + _("Collection Authors:"))
49 authors.append(" ")51 authors.append(" ")
50 52
51 tempauthors = []53 tempauthors = []
52 for a in self.libaccom.get_collection_authors(col):54 for a in self.libaccom.get_collection_authors(col):
53 tempauthors.append(a)55 tempauthors.append(a)
5456
55 authors = authors + sorted(tempauthors)57 authors = authors + sorted(tempauthors)
56 58
57 self.set_authors(authors)59 self.set_authors(authors)
5860
=== modified file 'accomplishments_viewer/AccomplishmentsViewerWindow.py'
--- accomplishments_viewer/AccomplishmentsViewerWindow.py 2012-11-22 10:04:35 +0000
+++ accomplishments_viewer/AccomplishmentsViewerWindow.py 2012-11-26 16:03:25 +0000
@@ -1,25 +1,27 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2### BEGIN LICENSE2### BEGIN LICENSE
3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>
4# This program is free software: you can redistribute it and/or modify it 4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published 5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.6# by the Free Software Foundation.
7# 7#
8# This program is distributed in the hope that it will be useful, but 8# This program is distributed in the hope that it will be useful, but
9# WITHOUT ANY WARRANTY; without even the implied warranties of 9# WITHOUT ANY WARRANTY; without even the implied warranties of
10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11# PURPOSE. See the GNU General Public License for more details.11# PURPOSE. See the GNU General Public License for more details.
12# 12#
13# You should have received a copy of the GNU General Public License along 13# You should have received a copy of the GNU General Public License along
14# with this program. If not, see <http://www.gnu.org/licenses/>.14# with this program. If not, see <http://www.gnu.org/licenses/>.
15### END LICENSE15### END LICENSE
1616
17import urllib217import urllib2
18import gettext, locale, datetime18import gettext
19import locale
20import datetime
19from locale import gettext as _21from locale import gettext as _
20from accomplishments.util.paths import locale_dir22from accomplishments.util.paths import locale_dir
21locale.bindtextdomain('accomplishments-viewer', locale_dir)23locale.bindtextdomain('accomplishments-viewer', locale_dir)
22gettext.bindtextdomain('accomplishments-viewer',locale_dir)24gettext.bindtextdomain('accomplishments-viewer', locale_dir)
23locale.textdomain('accomplishments-viewer')25locale.textdomain('accomplishments-viewer')
2426
25import traceback27import traceback
@@ -32,7 +34,7 @@
32import dbus.service34import dbus.service
33from dbus.mainloop.glib import DBusGMainLoop35from dbus.mainloop.glib import DBusGMainLoop
3436
35from gi.repository import Gtk, GObject, GdkPixbuf, WebKit # pylint: disable=E061137from gi.repository import Gtk, GObject, GdkPixbuf, WebKit # pylint: disable=E0611
36from gi.repository import Unity38from gi.repository import Unity
3739
38import logging40import logging
@@ -96,23 +98,24 @@
9698
97TROPHY_GALLERY_URL = 'http://213.138.100.229:8000'99TROPHY_GALLERY_URL = 'http://213.138.100.229:8000'
98100
101
99# See accomplishments_viewer_lib.Window.py for more details about how this class works102# See accomplishments_viewer_lib.Window.py for more details about how this class works
100class AccomplishmentsViewerWindow(Window):103class AccomplishmentsViewerWindow(Window):
101 __gtype_name__ = "AccomplishmentsViewerWindow"104 __gtype_name__ = "AccomplishmentsViewerWindow"
102 105
103 def finish_initializing(self, builder): # pylint: disable=E1002106 def finish_initializing(self, builder): # pylint: disable=E1002
104 """Set up the main window."""107 """Set up the main window."""
105 108
106 super(AccomplishmentsViewerWindow, self).finish_initializing(builder)109 super(AccomplishmentsViewerWindow, self).finish_initializing(builder)
107110
108 self.AboutDialog = AboutAccomplishmentsViewerDialog111 self.AboutDialog = AboutAccomplishmentsViewerDialog
109 self.PreferencesDialog = PreferencesAccomplishmentsViewerDialog #class112 self.PreferencesDialog = PreferencesAccomplishmentsViewerDialog # class
110 self.preferences_dialog = None #instance113 self.preferences_dialog = None # instance
111 self.EditExtraDialog = EditExtrainfoDialog()114 self.EditExtraDialog = EditExtrainfoDialog()
112 self.EditExtraDialog.parent = self115 self.EditExtraDialog.parent = self
113 self.curr_height = 0116 self.curr_height = 0
114 self.curr_width = 0117 self.curr_width = 0
115 118
116 # Following variables store current display settings.119 # Following variables store current display settings.
117 self.display_mytrophies_filtermode = MYTROPHIES_FILTER_ALL120 self.display_mytrophies_filtermode = MYTROPHIES_FILTER_ALL
118 self.display_mode = DISPLAY_MODE_OPPORTUNITIES121 self.display_mode = DISPLAY_MODE_OPPORTUNITIES
@@ -121,13 +124,12 @@
121 self.display_filter_category = ""124 self.display_filter_category = ""
122 self.display_filter_subcat = ""125 self.display_filter_subcat = ""
123 self.display_filter_search = ""126 self.display_filter_search = ""
124 127
125 # These two store list of pairs [filter, iconview] for all accomplishment groups in mytrophies view.128 # These two store list of pairs [filter, iconview] for all accomplishment groups in mytrophies view.
126 self.trophies_collection_filters = []129 self.trophies_collection_filters = []
127 self.mytrophies_latest_boxes = []130 self.mytrophies_latest_boxes = []
128 # Code for other initialization actions should be added here.131 # Code for other initialization actions should be added here.
129132
130
131 # set up autostart dir133 # set up autostart dir
132 self.autostartdir = None134 self.autostartdir = None
133135
@@ -144,7 +146,7 @@
144 # reference to the Unity Launchcher146 # reference to the Unity Launchcher
145 self.launcher = Unity.LauncherEntry.get_for_desktop_id("accomplishments-viewer.desktop")147 self.launcher = Unity.LauncherEntry.get_for_desktop_id("accomplishments-viewer.desktop")
146 self.newtrophies = 0148 self.newtrophies = 0
147 149
148 # set up all of the different UI references150 # set up all of the different UI references
149 self.tb_mytrophies = self.builder.get_object("tb_mytrophies")151 self.tb_mytrophies = self.builder.get_object("tb_mytrophies")
150 self.tb_opportunities = self.builder.get_object("tb_opportunities")152 self.tb_opportunities = self.builder.get_object("tb_opportunities")
@@ -192,38 +194,38 @@
192 sb_v = self.subcats_scroll.get_vscrollbar()194 sb_v = self.subcats_scroll.get_vscrollbar()
193 sb_h.set_child_visible(False)195 sb_h.set_child_visible(False)
194 sb_v.set_child_visible(False)196 sb_v.set_child_visible(False)
195 197
196 #h = self.subcats_scroll.get_hadjustment()198 #h = self.subcats_scroll.get_hadjustment()
197 self.subcat = None199 self.subcat = None
198 self.subcats_container.hide()200 self.subcats_container.hide()
199 201
200 # make the toolbar black in Ubuntu202 # make the toolbar black in Ubuntu
201 context = self.toolbar.get_style_context()203 context = self.toolbar.get_style_context()
202 context.add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)204 context.add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
203205
204 # Create stores and corelated filters206 # Create stores and corelated filters
205207
206 self.oppstore = Gtk.ListStore(str, GdkPixbuf.Pixbuf, bool, bool, str, str, str, str, str) # title, icon, accomplished, locked, col, accomplishment, date-accomplished, categories, keywords208 self.oppstore = Gtk.ListStore(str, GdkPixbuf.Pixbuf, bool, bool, str, str, str, str, str) # title, icon, accomplished, locked, col, accomplishment, date-accomplished, categories, keywords
207 self.oppstore.set_sort_column_id(COL_TITLE, Gtk.SortType.ASCENDING)209 self.oppstore.set_sort_column_id(COL_TITLE, Gtk.SortType.ASCENDING)
208 self.oppstore_filtered = self.oppstore.filter_new()210 self.oppstore_filtered = self.oppstore.filter_new()
209 # The following sets the function for tree model filter. That function has211 # The following sets the function for tree model filter. That function has
210 # to return true if a given row has to be visible. This way we can control212 # to return true if a given row has to be visible. This way we can control
211 # which opportunities are displayed, and which are not.213 # which opportunities are displayed, and which are not.
212 self.oppstore_filtered.set_visible_func(self._opp_visible_func)214 self.oppstore_filtered.set_visible_func(self._opp_visible_func)
213 215
214 self.trophiesstore = Gtk.ListStore(str, GdkPixbuf.Pixbuf, bool, bool, str, str, str, str, str) # title, icon, accomplished, locked, col, accomplishment, date-accomplished, categories, keywords216 self.trophiesstore = Gtk.ListStore(str, GdkPixbuf.Pixbuf, bool, bool, str, str, str, str, str) # title, icon, accomplished, locked, col, accomplishment, date-accomplished, categories, keywords
215 self.trophiesstore.set_sort_column_id(COL_TITLE, Gtk.SortType.ASCENDING)217 self.trophiesstore.set_sort_column_id(COL_TITLE, Gtk.SortType.ASCENDING)
216 self.trophiesstore_filter_today = self.trophiesstore.filter_new()218 self.trophiesstore_filter_today = self.trophiesstore.filter_new()
217 self.trophiesstore_filter_today.set_visible_func(self._trophy_recent_visible_func,TROPHIES_FILTER_TODAY)219 self.trophiesstore_filter_today.set_visible_func(self._trophy_recent_visible_func, TROPHIES_FILTER_TODAY)
218 self.trophiesstore_filter_week = self.trophiesstore.filter_new()220 self.trophiesstore_filter_week = self.trophiesstore.filter_new()
219 self.trophiesstore_filter_week.set_visible_func(self._trophy_recent_visible_func,TROPHIES_FILTER_WEEK)221 self.trophiesstore_filter_week.set_visible_func(self._trophy_recent_visible_func, TROPHIES_FILTER_WEEK)
220 self.trophiesstore_filter_month = self.trophiesstore.filter_new()222 self.trophiesstore_filter_month = self.trophiesstore.filter_new()
221 self.trophiesstore_filter_month.set_visible_func(self._trophy_recent_visible_func,TROPHIES_FILTER_MONTH)223 self.trophiesstore_filter_month.set_visible_func(self._trophy_recent_visible_func, TROPHIES_FILTER_MONTH)
222 self.trophiesstore_filter_sixmonths = self.trophiesstore.filter_new()224 self.trophiesstore_filter_sixmonths = self.trophiesstore.filter_new()
223 self.trophiesstore_filter_sixmonths.set_visible_func(self._trophy_recent_visible_func,TROPHIES_FILTER_SIXMONTHS)225 self.trophiesstore_filter_sixmonths.set_visible_func(self._trophy_recent_visible_func, TROPHIES_FILTER_SIXMONTHS)
224 self.trophiesstore_filter_earlier = self.trophiesstore.filter_new()226 self.trophiesstore_filter_earlier = self.trophiesstore.filter_new()
225 self.trophiesstore_filter_earlier.set_visible_func(self._trophy_recent_visible_func,TROPHIES_FILTER_EARLIER)227 self.trophiesstore_filter_earlier.set_visible_func(self._trophy_recent_visible_func, TROPHIES_FILTER_EARLIER)
226 228
227 self.opp_icon.set_model(self.oppstore_filtered)229 self.opp_icon.set_model(self.oppstore_filtered)
228 self.opp_icon.set_text_column(COL_TITLE)230 self.opp_icon.set_text_column(COL_TITLE)
229 self.opp_icon.set_pixbuf_column(COL_PIXBUF)231 self.opp_icon.set_pixbuf_column(COL_PIXBUF)
@@ -232,13 +234,13 @@
232 self.webview = WebKit.WebView()234 self.webview = WebKit.WebView()
233 self.scrolledwindow.add(self.webview)235 self.scrolledwindow.add(self.webview)
234 self.webview.props.settings.props.enable_default_context_menu = False236 self.webview.props.settings.props.enable_default_context_menu = False
235 self.webkitlink = self.webview.connect("navigation-policy-decision-requested",self.webkit_link_clicked)237 self.webkitlink = self.webview.connect("navigation-policy-decision-requested", self.webkit_link_clicked)
236238
237 self.webview.show()239 self.webview.show()
238 240
239 if GWIBBER_OK:241 if GWIBBER_OK:
240 self.messageentry = GwibberGtk.Entry() 242 self.messageentry = GwibberGtk.Entry()
241 self.messageentry.text_view.connect("submit",self.close_gwibber_window)243 self.messageentry.text_view.connect("submit", self.close_gwibber_window)
242 self.messagewindow = Gtk.Window()244 self.messagewindow = Gtk.Window()
243 self.messagewindow.set_transient_for(self)245 self.messagewindow.set_transient_for(self)
244 self.messagevbox = Gtk.VBox()246 self.messagevbox = Gtk.VBox()
@@ -246,15 +248,15 @@
246 self.messagewindow.set_icon_name("gwibber")248 self.messagewindow.set_icon_name("gwibber")
247 self.messagewindow.resize(400, 150)249 self.messagewindow.resize(400, 150)
248 self.messagewindow.set_resizable(False)250 self.messagewindow.set_resizable(False)
249 self.messagevbox.pack_start(self.messageentry,True,True,0)251 self.messagevbox.pack_start(self.messageentry, True, True, 0)
250 self.messagelabel = Gtk.Label()252 self.messagelabel = Gtk.Label()
251 self.messagelabel.set_markup(_("<b>Always add the link to your trophy on the web when sharing a trophy.</b>\nThis link works as a <b>proof</b> that you have really accomplished this trophy."))253 self.messagelabel.set_markup(_("<b>Always add the link to your trophy on the web when sharing a trophy.</b>\nThis link works as a <b>proof</b> that you have really accomplished this trophy."))
252 self.messagevbox.pack_start(self.messagelabel,False,False,0)254 self.messagevbox.pack_start(self.messagelabel, False, False, 0)
253 self.messagewindow.add(self.messagevbox)255 self.messagewindow.add(self.messagevbox)
254 self.messagevbox.show_all() 256 self.messagevbox.show_all()
255 self.messagewindow.hide()257 self.messagewindow.hide()
256 self.messagewindow.connect("delete-event",self.close_gwibber_window)258 self.messagewindow.connect("delete-event", self.close_gwibber_window)
257 259
258 self.opp_col_store = Gtk.ListStore(str, str)260 self.opp_col_store = Gtk.ListStore(str, str)
259 self.col_combo_renderer_text = Gtk.CellRendererText()261 self.col_combo_renderer_text = Gtk.CellRendererText()
260 self.opp_combo_col.pack_start(self.col_combo_renderer_text, True)262 self.opp_combo_col.pack_start(self.col_combo_renderer_text, True)
@@ -291,26 +293,23 @@
291 os.makedirs(os.path.join(self.dir_cache, "logs"))293 os.makedirs(os.path.join(self.dir_cache, "logs"))
292294
293 # IMPORTANT: This function should do no initialisations that depend295 # IMPORTANT: This function should do no initialisations that depend
294 # on having the daemon running. This is because if the daemon is not 296 # on having the daemon running. This is because if the daemon is not
295 # yet started it will take some time to connect to it. Such 297 # yet started it will take some time to connect to it. Such
296 # initialistions should land in appropriate place in finalise_daemon_connection(...).298 # initialistions should land in appropriate place in finalise_daemon_connection(...).
297299
298 self.datapath = get_data_path()300 self.datapath = get_data_path()
299301
300 self.update_widgets_sensitivity()302 self.update_widgets_sensitivity()
301303
302
303
304 def add_no_collections_installed(self):304 def add_no_collections_installed(self):
305 """Display the message that no collections are installed."""305 """Display the message that no collections are installed."""
306 306
307 ### Commented out the following as it is confusing, and opens a lot of307 ### Commented out the following as it is confusing, and opens a lot of
308 ### possible scenarios where these buttons are left insensitive.308 ### possible scenarios where these buttons are left insensitive.
309 ## set bits of the user interface to be insensitive309 ## set bits of the user interface to be insensitive
310 # self.tb_mytrophies.set_sensitive(False)310 # self.tb_mytrophies.set_sensitive(False)
311 # self.opp_frame.set_visible(False)311 # self.opp_frame.set_visible(False)
312 312
313
314 # show the message313 # show the message
315 self.additional_no_collections.set_visible(True)314 self.additional_no_collections.set_visible(True)
316315
@@ -322,28 +321,28 @@
322 self.additional_no_collections.set_visible(False)321 self.additional_no_collections.set_visible(False)
323 self.reload_accomplishments()322 self.reload_accomplishments()
324 self.set_display(DISPLAY_MODE_OPPORTUNITIES)323 self.set_display(DISPLAY_MODE_OPPORTUNITIES)
325 324
326 def reload_accomplishments(self):325 def reload_accomplishments(self):
327 if not self.connected:326 if not self.connected:
328 return327 return
329 328
330 self.statusbar_reload_msg_start()329 self.statusbar_reload_msg_start()
331 Gtk.main_iteration_do(False) # Force UI refresh330 Gtk.main_iteration_do(False) # Force UI refresh
332 self.libaccom.reload_accom_database()331 self.libaccom.reload_accom_database()
333 self.statusbar_reload_msg_stop()332 self.statusbar_reload_msg_stop()
334 333
335 self._load_accomplishments()334 self._load_accomplishments()
336 if len(self.accomdb) == 0:335 if len(self.accomdb) == 0:
337 self.add_no_collections_installed()336 self.add_no_collections_installed()
338 337
339 def statusbar_reload_msg_start(self):338 def statusbar_reload_msg_start(self):
340 self.statusbar.set_text(_("Reloading accomplishments collections..."))339 self.statusbar.set_text(_("Reloading accomplishments collections..."))
341 self.spinner.start()340 self.spinner.start()
342 self.spinner.show()341 self.spinner.show()
343 self.statusbox.show()342 self.statusbox.show()
344 self.statusbar_reload_msg = 0343 self.statusbar_reload_msg = 0
345 GObject.timeout_add(1000,self.statusbar_reload_msg_stop)344 GObject.timeout_add(1000, self.statusbar_reload_msg_stop)
346 345
347 def statusbar_reload_msg_stop(self):346 def statusbar_reload_msg_stop(self):
348 if self.statusbar_reload_msg is 0:347 if self.statusbar_reload_msg is 0:
349 # That would be too quick and the user wouldn't even notice the message348 # That would be too quick and the user wouldn't even notice the message
@@ -351,23 +350,22 @@
351 elif self.statusbar_reload_msg is 1:350 elif self.statusbar_reload_msg is 1:
352 self.spinner.hide()351 self.spinner.hide()
353 self.statusbox.hide()352 self.statusbox.hide()
354 353
355
356 def trophy_received(self, message):354 def trophy_received(self, message):
357 """Called when a new trophy is detected on the system."""355 """Called when a new trophy is detected on the system."""
358 356
359 self.newtrophies = self.newtrophies + 1357 self.newtrophies = self.newtrophies + 1
360 358
361 # run this to refresh our accomplishments list359 # run this to refresh our accomplishments list
362 self._load_accomplishments()360 self._load_accomplishments()
363 361
364 #XXX: It would be MUCH faster if we determined the new accomID and added just it, not recreating whole trees!362 #XXX: It would be MUCH faster if we determined the new accomID and added just it, not recreating whole trees!
365 self.prepare_models()363 self.prepare_models()
366 364
367 # set the Launcher icon to be urgent and show new trophy count365 # set the Launcher icon to be urgent and show new trophy count
368 self.launcher.set_property("urgent", True)366 self.launcher.set_property("urgent", True)
369 self.launcher.set_property("count", self.newtrophies)367 self.launcher.set_property("count", self.newtrophies)
370 368
371 if self.newtrophies > 0:369 if self.newtrophies > 0:
372 self.launcher.set_property("count_visible", True)370 self.launcher.set_property("count_visible", True)
373 else:371 else:
@@ -379,10 +377,10 @@
379 def check_and_ask_for_info(self):377 def check_and_ask_for_info(self):
380 """Asks the daemon for additional info needed, and asks378 """Asks the daemon for additional info needed, and asks
381 the user for it, in case it has not been yet given"""379 the user for it, in case it has not been yet given"""
382 380
383 if self.connected is False:381 if self.connected is False:
384 return382 return
385 383
386 self.has_u1 = self.libaccom.get_config_value("config", "has_u1")384 self.has_u1 = self.libaccom.get_config_value("config", "has_u1")
387 self.has_verif = self.libaccom.get_config_value("config", "has_verif")385 self.has_verif = self.libaccom.get_config_value("config", "has_verif")
388386
@@ -397,90 +395,90 @@
397395
398 def connect_to_daemon(self):396 def connect_to_daemon(self):
399 """Tries to connect to the daemon"""397 """Tries to connect to the daemon"""
400 398
401 self.connected = False399 self.connected = False
402 400
403 if dbusapi.daemon_is_registered():401 if dbusapi.daemon_is_registered():
404 self.libaccom = dbusapi.Accomplishments()402 self.libaccom = dbusapi.Accomplishments()
405 else:403 else:
406 return False404 return False
407 405
408 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)406 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
409407
410 bus = dbus.SessionBus()408 bus = dbus.SessionBus()
411 409
412 try:410 try:
413 object = bus.get_object("org.ubuntu.accomplishments",411 object = bus.get_object("org.ubuntu.accomplishments",
414 "/org/ubuntu/accomplishments")412 "/org/ubuntu/accomplishments")
415 object.connect_to_signal("trophy_recieved",413 object.connect_to_signal("trophy_recieved",
416 self.trophy_received,414 self.trophy_received,
417 dbus_interface="org.ubuntu.accomplishments", arg0="Hello")415 dbus_interface="org.ubuntu.accomplishments", arg0="Hello")
418 object.connect_to_signal("publish_trophies_online_completed",416 object.connect_to_signal("publish_trophies_online_completed",
419 self.publish_trophies_online_completed,417 self.publish_trophies_online_completed,
420 dbus_interface="org.ubuntu.accomplishments", arg0="Hello") 418 dbus_interface="org.ubuntu.accomplishments", arg0="Hello")
421 object.connect_to_signal("scriptrunner_start",419 object.connect_to_signal("scriptrunner_start",
422 self.scriptrunner_start,420 self.scriptrunner_start,
423 dbus_interface="org.ubuntu.accomplishments")421 dbus_interface="org.ubuntu.accomplishments")
424 object.connect_to_signal("scriptrunner_finish",422 object.connect_to_signal("scriptrunner_finish",
425 self.scriptrunner_finish,423 self.scriptrunner_finish,
426 dbus_interface="org.ubuntu.accomplishments")424 dbus_interface="org.ubuntu.accomplishments")
427 object.connect_to_signal("ubuntu_one_account_ready",425 object.connect_to_signal("ubuntu_one_account_ready",
428 self.ubuntu_one_account_ready,426 self.ubuntu_one_account_ready,
429 dbus_interface="org.ubuntu.accomplishments", arg0="Hello")427 dbus_interface="org.ubuntu.accomplishments", arg0="Hello")
430 428
431 except dbus.DBusException:429 except dbus.DBusException:
432 print "DBus exception when connecting to daemon."430 print "DBus exception when connecting to daemon."
433 traceback.print_exc()431 traceback.print_exc()
434 return False432 return False
435433
436 bus.add_signal_receiver(self.trophy_received,434 bus.add_signal_receiver(self.trophy_received,
437 dbus_interface = "org.ubuntu.accomplishments",435 dbus_interface="org.ubuntu.accomplishments",
438 signal_name = "trophy_received")436 signal_name="trophy_received")
439 bus.add_signal_receiver(self.publish_trophies_online_completed,437 bus.add_signal_receiver(self.publish_trophies_online_completed,
440 dbus_interface = "org.ubuntu.accomplishments",438 dbus_interface="org.ubuntu.accomplishments",
441 signal_name = "publish_trophies_online_completed")439 signal_name="publish_trophies_online_completed")
442 bus.add_signal_receiver(self.scriptrunner_start,440 bus.add_signal_receiver(self.scriptrunner_start,
443 dbus_interface = "org.ubuntu.accomplishments",441 dbus_interface="org.ubuntu.accomplishments",
444 signal_name = "scriptrunner_start")442 signal_name="scriptrunner_start")
445 bus.add_signal_receiver(self.scriptrunner_finish,443 bus.add_signal_receiver(self.scriptrunner_finish,
446 dbus_interface = "org.ubuntu.accomplishments",444 dbus_interface="org.ubuntu.accomplishments",
447 signal_name = "scriptrunner_finish")445 signal_name="scriptrunner_finish")
448 bus.add_signal_receiver(self.ubuntu_one_account_ready,446 bus.add_signal_receiver(self.ubuntu_one_account_ready,
449 dbus_interface = "org.ubuntu.accomplishments",447 dbus_interface="org.ubuntu.accomplishments",
450 signal_name = "ubuntu_one_account_ready")448 signal_name="ubuntu_one_account_ready")
451 449
452 self.connected = True450 self.connected = True
453 451
454 self.check_daemon_session()452 self.check_daemon_session()
455 453
456 return True454 return True
457455
458 def publish_trophies_online_completed(self, url):456 def publish_trophies_online_completed(self, url):
459 webbrowser.open(url)457 webbrowser.open(url)
460458
461 def ubuntu_one_account_ready(self): 459 def ubuntu_one_account_ready(self):
462 if not self.has_u1 == 1:460 if not self.has_u1 == 1:
463 self.register_with_verif(None)461 self.register_with_verif(None)
464 462
465 def run_daemon(self):463 def run_daemon(self):
466 """Starts the daemon process""" 464 """Starts the daemon process"""
467 465
468 # Not importing this globally, as it will be very rarely used.466 # Not importing this globally, as it will be very rarely used.
469 import subprocess467 import subprocess
470 import threading468 import threading
471 469
472 # Starting the daemon is realised in a separete thread, it can470 # Starting the daemon is realised in a separete thread, it can
473 # wait for launcher to exit without blocking gtk main event loop.471 # wait for launcher to exit without blocking gtk main event loop.
474 def run_in_thread_and_call_when_done(args,onexit):472 def run_in_thread_and_call_when_done(args, onexit):
475 launcher_process = subprocess.Popen(args.split(" "))473 launcher_process = subprocess.Popen(args.split(" "))
476 launcher_process.wait()474 launcher_process.wait()
477 GObject.idle_add(onexit)475 GObject.idle_add(onexit)
478 return476 return
479 command = os.path.join(daemon_exec_dir, "accomplishments-daemon") + " --start"477 command = os.path.join(daemon_exec_dir, "accomplishments-daemon") + " --start"
480 print ("Starting the daemon using command `%s`" % command)478 print ("Starting the daemon using command `%s`" % command)
481 th = threading.Thread(target=run_in_thread_and_call_when_done,args=(command, self.run_daemon_continue))479 th = threading.Thread(target=run_in_thread_and_call_when_done, args=(command, self.run_daemon_continue))
482 th.start()480 th.start()
483 481
484 self.statusbar.set_text(_("Starting the daemon..."))482 self.statusbar.set_text(_("Starting the daemon..."))
485 self.spinner.start()483 self.spinner.start()
486 self.spinner.show()484 self.spinner.show()
@@ -489,26 +487,26 @@
489 def run_daemon_continue(self):487 def run_daemon_continue(self):
490 """Called from run_daemon when the daemon launcher exits.488 """Called from run_daemon when the daemon launcher exits.
491 Finishes what run_daemon would do"""489 Finishes what run_daemon would do"""
492 490
493 self.connect_to_daemon()491 self.connect_to_daemon()
494 492
495 self.statusbox.hide()493 self.statusbox.hide()
496 494
497 if self.connected is False:495 if self.connected is False:
498 #Either failed to start the daemon, or failed to connect to496 #Either failed to start the daemon, or failed to connect to
499 #It may either be not installed, or may have crashed on startup497 #It may either be not installed, or may have crashed on startup
500 self.statusbar.set_text("Failed to connect to the daemon.")498 self.statusbar.set_text("Failed to connect to the daemon.")
501 self.spinner.hide()499 self.spinner.hide()
502 self.statusbox.show()500 self.statusbox.show()
503 GObject.timeout_add(10000,self.run_daemon)501 GObject.timeout_add(10000, self.run_daemon)
504 else:502 else:
505 #successfully started and connected503 #successfully started and connected
506 self.finalise_daemon_connection()504 self.finalise_daemon_connection()
507 505
508 self.update_widgets_sensitivity()506 self.update_widgets_sensitivity()
509 507
510 #returning false removes the timeout508 #returning false removes the timeout
511 return False 509 return False
512510
513 def finalise_daemon_connection(self):511 def finalise_daemon_connection(self):
514 self.libaccom.create_all_trophy_icons()512 self.libaccom.create_all_trophy_icons()
@@ -518,7 +516,6 @@
518 if len(self.accomdb) == 0:516 if len(self.accomdb) == 0:
519 self.add_no_collections_installed()517 self.add_no_collections_installed()
520 self.set_display(DISPLAY_MODE_OPPORTUNITIES)518 self.set_display(DISPLAY_MODE_OPPORTUNITIES)
521
522519
523 def update_widgets_sensitivity(self):520 def update_widgets_sensitivity(self):
524 """Disables/enables some GUI elemets, according to whether the client is connected to the daemon or nor"""521 """Disables/enables some GUI elemets, according to whether the client is connected to the daemon or nor"""
@@ -532,7 +529,7 @@
532 self.mnu_edit_ident.set_sensitive(False)529 self.mnu_edit_ident.set_sensitive(False)
533 return530 return
534531
535 def edit_identification_clicked(self,w):532 def edit_identification_clicked(self, w):
536 """Called when user clicks Edit->Identification..."""533 """Called when user clicks Edit->Identification..."""
537 if self.connected is False:534 if self.connected is False:
538 return535 return
@@ -544,9 +541,9 @@
544 pass541 pass
545542
546 self.EditExtraDialog.prepare(self.libaccom)543 self.EditExtraDialog.prepare(self.libaccom)
547 result = self.EditExtraDialog.run() #the dialog's response handlers will take care about storing the result544 result = self.EditExtraDialog.run() # the dialog's response handlers will take care about storing the result
548 self.EditExtraDialog.hide()545 self.EditExtraDialog.hide()
549 546
550 # re-load accoms and show the opps view, which will update both views547 # re-load accoms and show the opps view, which will update both views
551 # XXX we should probably do this inside EditExtraInfoDialog.py548 # XXX we should probably do this inside EditExtraInfoDialog.py
552 self._load_accomplishments()549 self._load_accomplishments()
@@ -558,7 +555,7 @@
558 self.subcats_forward.set_sensitive(True)555 self.subcats_forward.set_sensitive(True)
559556
560 def subcat_clicked(self, button, data):557 def subcat_clicked(self, button, data):
561 self.set_display(filter_subcat = data)558 self.set_display(filter_subcat=data)
562559
563 def subcats_back_button(self, widget):560 def subcats_back_button(self, widget):
564 h = self.subcats_scroll.get_hadjustment()561 h = self.subcats_scroll.get_hadjustment()
@@ -572,33 +569,33 @@
572 h.set_value(new)569 h.set_value(new)
573 self.subcats_scroll.set_hadjustment(h)570 self.subcats_scroll.set_hadjustment(h)
574571
575 def show_gwibber_widget(self,accomID,name):572 def show_gwibber_widget(self, accomID, name):
576 if GWIBBER_OK:573 if GWIBBER_OK:
577 # Temporarily using trophies.ubuntu.com574 # Temporarily using trophies.ubuntu.com
578 #trophyURL = TROPHY_GALLERY_URL+'/gallery/trophies/'+name+'/'+accomID575 #trophyURL = TROPHY_GALLERY_URL+'/gallery/trophies/'+name+'/'+accomID
579 trophyURL = 'http://trophies.ubuntu.com/gallery/trophies/'+name+'/'+accomID576 trophyURL = 'http://trophies.ubuntu.com/gallery/trophies/' + name + '/' + accomID
580 trophy_name = self.libaccom.get_accom_title(accomID);577 trophy_name = self.libaccom.get_accom_title(accomID)
581 self.messageentry.text_view.get_buffer().set_text(_("I've just got the trophy '%s' in #ubuntu accomplishments!") % (trophy_name))578 self.messageentry.text_view.get_buffer().set_text(_("I've just got the trophy '%s' in #ubuntu accomplishments!") % (trophy_name))
582 self.messagewindow.show()579 self.messagewindow.show()
583 self.messagewindow.present()580 self.messagewindow.present()
584581
585 def close_gwibber_window(self,widget=None,event=None):582 def close_gwibber_window(self, widget=None, event=None):
586 self.messagewindow.hide()583 self.messagewindow.hide()
587 return True584 return True
588 585
589 def webkit_link_clicked(self, view, frame, net_req, nav_act, pol_dec):586 def webkit_link_clicked(self, view, frame, net_req, nav_act, pol_dec):
590 """Load a link from the webkit view in an external system browser."""587 """Load a link from the webkit view in an external system browser."""
591588
592 uri=net_req.get_uri()589 uri = net_req.get_uri()
593 if uri.startswith ('file:///gwibber-share'):590 if uri.startswith('file:///gwibber-share'):
594 if GWIBBER_OK:591 if GWIBBER_OK:
595 share_name = self.libaccom.get_share_name()592 share_name = self.libaccom.get_share_name()
596 share_name = urllib2.quote(share_name.encode('utf8'))593 share_name = urllib2.quote(share_name.encode('utf8'))
597 share_ID = self.libaccom.get_share_id()594 share_ID = self.libaccom.get_share_id()
598 nameURL = TROPHY_GALLERY_URL+"/user/getusername?share_name="+share_name+"&share_id="+share_ID595 nameURL = TROPHY_GALLERY_URL + "/user/getusername?share_name=" + share_name + "&share_id=" + share_ID
599596
600 publish_status = self.libaccom.get_published_status()597 publish_status = self.libaccom.get_published_status()
601 if publish_status==0:598 if publish_status == 0:
602 dialog = Gtk.MessageDialog(self, Gtk.DialogFlags.MODAL, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, _("Your trophies are not yet published"))599 dialog = Gtk.MessageDialog(self, Gtk.DialogFlags.MODAL, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, _("Your trophies are not yet published"))
603 dialog.format_secondary_text(_("You can do it from Edit->Preferences menu."))600 dialog.format_secondary_text(_("You can do it from Edit->Preferences menu."))
604 dialog.run()601 dialog.run()
@@ -608,9 +605,9 @@
608 response = urllib2.urlopen(nameURL)605 response = urllib2.urlopen(nameURL)
609 for line in response:606 for line in response:
610 name = line.rstrip()607 name = line.rstrip()
611 break 608 break
612 uri = uri.replace("file:///gwibber-share?accomID=", '');609 uri = uri.replace("file:///gwibber-share?accomID=", '')
613 gwibberPopup = self.show_gwibber_widget(uri,name)610 gwibberPopup = self.show_gwibber_widget(uri, name)
614 except urllib2.HTTPError:611 except urllib2.HTTPError:
615 print 'HTTPError while getting username.'612 print 'HTTPError while getting username.'
616 return True613 return True
@@ -621,23 +618,23 @@
621 return False618 return False
622619
623 if uri.startswith('file:'):620 if uri.startswith('file:'):
624 return False 621 return False
625 622
626 if uri.startswith('http'):623 if uri.startswith('http'):
627 webbrowser.open_new_tab(uri)624 webbrowser.open_new_tab(uri)
628 return True625 return True
629626
630 if uri.startswith('accomplishment:'):627 if uri.startswith('accomplishment:'):
631 id = uri[17:]628 id = uri[17:]
632 self.set_display(DISPLAY_MODE_DETAILS,accomID=id)629 self.set_display(DISPLAY_MODE_DETAILS, accomID=id)
633 return True630 return True
634631
635 pol_dec.ignore()632 pol_dec.ignore()
636 return True 633 return True
637634
638 def scriptrunner_start(self):635 def scriptrunner_start(self):
639 """Indicate that the script runner is starting."""636 """Indicate that the script runner is starting."""
640 637
641 self.statusbar.set_text("Checking for new accomplishments...")638 self.statusbar.set_text("Checking for new accomplishments...")
642 self.spinner.start()639 self.spinner.start()
643 self.spinner.show()640 self.spinner.show()
@@ -645,7 +642,7 @@
645642
646 def scriptrunner_finish(self):643 def scriptrunner_finish(self):
647 """Indicate that the script runner has stopped."""644 """Indicate that the script runner has stopped."""
648 645
649 self.statusbar.set_text("")646 self.statusbar.set_text("")
650 self.spinner.stop()647 self.spinner.stop()
651 self.spinner.hide()648 self.spinner.hide()
@@ -663,7 +660,7 @@
663 def verify_u1_account(self):660 def verify_u1_account(self):
664 ver = self.libaccom.verify_ubuntu_one_account()661 ver = self.libaccom.verify_ubuntu_one_account()
665662
666 if bool(ver) == True:663 if bool(ver) is True:
667 self.u1_button.disconnect(self.u1_button_sig)664 self.u1_button.disconnect(self.u1_button_sig)
668 self.u1_button.set_label("Click here to confirm your Ubuntu One account")665 self.u1_button.set_label("Click here to confirm your Ubuntu One account")
669 self.u1_button_sig = self.u1_button.connect("clicked", self.register_with_verif)666 self.u1_button_sig = self.u1_button.connect("clicked", self.register_with_verif)
@@ -694,7 +691,7 @@
694 def complete_share_process(self):691 def complete_share_process(self):
695 self.has_u1 = True692 self.has_u1 = True
696 self.libaccom.write_config_file_item("config", "has_u1", True)693 self.libaccom.write_config_file_item("config", "has_u1", True)
697 694
698 self.additional_ubuntu1.set_visible(False)695 self.additional_ubuntu1.set_visible(False)
699696
700 # ACCOMPLISHMENT: Editing Credentials697 # ACCOMPLISHMENT: Editing Credentials
@@ -702,7 +699,7 @@
702 self.libaccom.accomplish("ubuntu-desktop/accomplishments-shared-with-validation-server")699 self.libaccom.accomplish("ubuntu-desktop/accomplishments-shared-with-validation-server")
703 except:700 except:
704 pass701 pass
705 702
706 self.check_for_extra_info_required()703 self.check_for_extra_info_required()
707704
708 def register_with_verif(self, widget):705 def register_with_verif(self, widget):
@@ -716,20 +713,20 @@
716 self.u1_button.show()713 self.u1_button.show()
717 self.additional_ubuntu1.set_visible(True)714 self.additional_ubuntu1.set_visible(True)
718715
719 def on_window_resized(self,widget):716 def on_window_resized(self, widget):
720 # Workaround for GtkIconView bug in precise717 # Workaround for GtkIconView bug in precise
721 if self.display_mode is DISPLAY_MODE_OPPORTUNITIES:718 if self.display_mode is DISPLAY_MODE_OPPORTUNITIES:
722 self._update_opportunities_view()719 self._update_opportunities_view()
723 elif self.display_mode is DISPLAY_MODE_TROPHIES:720 elif self.display_mode is DISPLAY_MODE_TROPHIES:
724 self._update_mytrophy_view()721 self._update_mytrophy_view()
725 722
726 def populate_opp_combos(self):723 def populate_opp_combos(self):
727 temp = []724 temp = []
728 for i in self.accomdb:725 for i in self.accomdb:
729 temp.append({i["collection"] : i["collection-human"] })726 temp.append({i["collection"]: i["collection-human"]})
730 # uniqify the values727 # uniqify the values
731 result = [dict(tupleized) for tupleized in set(tuple(item.items()) for item in temp)]728 result = [dict(tupleized) for tupleized in set(tuple(item.items()) for item in temp)]
732 729
733 # set up app730 # set up app
734 self.opp_col_store.append(["", "All"])731 self.opp_col_store.append(["", "All"])
735 for i in sorted(result):732 for i in sorted(result):
@@ -741,73 +738,73 @@
741 # Prepare categories combo738 # Prepare categories combo
742 self.opp_combo_cat.set_model(self.opp_cat_store)739 self.opp_combo_cat.set_model(self.opp_cat_store)
743 self.opp_combo_cat.show()740 self.opp_combo_cat.show()
744 741
745 def on_filter_collection_changed(self,widget):742 def on_filter_collection_changed(self, widget):
746 tree_iter = widget.get_active_iter()743 tree_iter = widget.get_active_iter()
747 model = widget.get_model()744 model = widget.get_model()
748 collection, name = model[tree_iter][:2]745 collection, name = model[tree_iter][:2]
749 self.set_display(filter_collection = collection)746 self.set_display(filter_collection=collection)
750747
751 def on_filter_category_changed(self, widget):748 def on_filter_category_changed(self, widget):
752 tree_iter = widget.get_active_iter()749 tree_iter = widget.get_active_iter()
753 if tree_iter == None: # Special case if the categories combo is not sensitive750 if tree_iter is None: # Special case if the categories combo is not sensitive
754 return751 return
755 model = widget.get_model()752 model = widget.get_model()
756 category, name = model[tree_iter][:2]753 category, name = model[tree_iter][:2]
757 self.set_display(filter_category = category)754 self.set_display(filter_category=category)
758 755
759 def on_filter_show_locked_clicked(self, widget):756 def on_filter_show_locked_clicked(self, widget):
760 if widget.get_active():757 if widget.get_active():
761 self.set_display(filter_locked=DISPLAY_FILTER_LOCKED_SHOW)758 self.set_display(filter_locked=DISPLAY_FILTER_LOCKED_SHOW)
762 else:759 else:
763 self.set_display(filter_locked=DISPLAY_FILTER_LOCKED_HIDE)760 self.set_display(filter_locked=DISPLAY_FILTER_LOCKED_HIDE)
764 761
765 def on_search_changed(self,widget):762 def on_search_changed(self, widget):
766 value = widget.get_text()763 value = widget.get_text()
767 self.set_display(search_query=value)764 self.set_display(search_query=value)
768765
769 def on_search_clear_clicked(self,widget,icon,data):766 def on_search_clear_clicked(self, widget, icon, data):
770 self.searchbar.set_text("")767 self.searchbar.set_text("")
771 768
772 def check_accomplishments(self, widget):769 def check_accomplishments(self, widget):
773 """Called when Check Accomplishments is selected in the interface."""770 """Called when Check Accomplishments is selected in the interface."""
774 self.libaccom.run_scripts(True)771 self.libaccom.run_scripts(True)
775 772
776 def on_mytrophies_filter_latest_toggled(self, widget):773 def on_mytrophies_filter_latest_toggled(self, widget):
777 self.set_display(trophies_mode=MYTROPHIES_FILTER_LATEST)774 self.set_display(trophies_mode=MYTROPHIES_FILTER_LATEST)
778775
779 def on_mytrophies_filter_all_toggled(self, widget): 776 def on_mytrophies_filter_all_toggled(self, widget):
780 self.set_display(trophies_mode=MYTROPHIES_FILTER_ALL)777 self.set_display(trophies_mode=MYTROPHIES_FILTER_ALL)
781778
782 def on_tb_mytrophies_clicked(self, widget):779 def on_tb_mytrophies_clicked(self, widget):
783 """Called when the My Trophies button is clicked."""780 """Called when the My Trophies button is clicked."""
784 781
785 mytrophies_toggled = self.tb_mytrophies.get_active()782 mytrophies_toggled = self.tb_mytrophies.get_active()
786 opportunities_toggled = self.tb_opportunities.get_active()783 opportunities_toggled = self.tb_opportunities.get_active()
787 784
788 if mytrophies_toggled == True:785 if mytrophies_toggled is True:
789 self.set_display(DISPLAY_MODE_TROPHIES)786 self.set_display(DISPLAY_MODE_TROPHIES)
790 else:787 else:
791 self.tb_mytrophies.set_active(True) # This also fires the signal handler788 self.tb_mytrophies.set_active(True) # This also fires the signal handler
792789
793 def on_tb_opportunities_clicked(self, widget):790 def on_tb_opportunities_clicked(self, widget):
794 """Called when the Opportunities button is clicked."""791 """Called when the Opportunities button is clicked."""
795 792
796 self.launcher.set_property("urgent", False)793 self.launcher.set_property("urgent", False)
797 self.newtrophies = 0794 self.newtrophies = 0
798 self.launcher.set_property("count_visible", False)795 self.launcher.set_property("count_visible", False)
799 796
800 mytrophies_toggled = self.tb_mytrophies.get_active()797 mytrophies_toggled = self.tb_mytrophies.get_active()
801 opportunities_toggled = self.tb_opportunities.get_active()798 opportunities_toggled = self.tb_opportunities.get_active()
802 799
803 if opportunities_toggled == True:800 if opportunities_toggled is True:
804 self.set_display(DISPLAY_MODE_OPPORTUNITIES)801 self.set_display(DISPLAY_MODE_OPPORTUNITIES)
805 else:802 else:
806 self.tb_opportunities.set_active(True) # This also fires the signal handler803 self.tb_opportunities.set_active(True) # This also fires the signal handler
807804
808 def menu_prefs_clicked(self,widget):805 def menu_prefs_clicked(self, widget):
809 """Display the preferences window."""806 """Display the preferences window."""
810 807
811 # If the window already is in use, when user clicks the menu808 # If the window already is in use, when user clicks the menu
812 # item, present() is used instead, to bring the window to front809 # item, present() is used instead, to bring the window to front
813 # etc.810 # etc.
@@ -819,24 +816,24 @@
819 self.preferences_dialog.prepare(self.libaccom)816 self.preferences_dialog.prepare(self.libaccom)
820 self.preferences_dialog.connect('destroy', self.on_preferences_dialog_destroyed)817 self.preferences_dialog.connect('destroy', self.on_preferences_dialog_destroyed)
821 self.preferences_dialog.show()818 self.preferences_dialog.show()
822 819
823 def on_preferences_dialog_destroyed(self,widget):820 def on_preferences_dialog_destroyed(self, widget):
824 self.preferences_dialog = None821 self.preferences_dialog = None
825 822
826 def get_icon(self, name):823 def get_icon(self, name):
827 theme = Gtk.IconTheme.get_default()824 theme = Gtk.IconTheme.get_default()
828 return theme.load_icon(name, 48, 0)825 return theme.load_icon(name, 48, 0)
829826
830 def check_for_extra_info_required(self):827 def check_for_extra_info_required(self):
831 """Check if the installed accomplishments require additional information to be gathered from the user."""828 """Check if the installed accomplishments require additional information to be gathered from the user."""
832 829
833 infoneeded = self.libaccom.get_all_extra_information_required()830 infoneeded = self.libaccom.get_all_extra_information_required()
834831
835 if len(infoneeded) is not 0:832 if len(infoneeded) is not 0:
836 # kick of the process of gathering the information needed833 # kick of the process of gathering the information needed
837 try:834 try:
838 seen = self.libaccom.get_config_value("config", "extrainfo_seen")835 seen = self.libaccom.get_config_value("config", "extrainfo_seen")
839 836
840 if seen == "NoOption" or seen == 0:837 if seen == "NoOption" or seen == 0:
841 self.additional_info_req.set_visible(True)838 self.additional_info_req.set_visible(True)
842 self.libaccom.write_config_file_item("config", "extrainfo_seen", 1)839 self.libaccom.write_config_file_item("config", "extrainfo_seen", 1)
@@ -857,22 +854,22 @@
857 self.libaccom.set_daemon_session_start(True)854 self.libaccom.set_daemon_session_start(True)
858 self.additional_daemon_session.set_visible(False)855 self.additional_daemon_session.set_visible(False)
859856
860 def edit_auth_info(self,widget):857 def edit_auth_info(self, widget):
861 """Called when user clicks "Edit credentials" from notification"""858 """Called when user clicks "Edit credentials" from notification"""
862 self.additional_info_req.set_visible(False)859 self.additional_info_req.set_visible(False)
863 self.edit_identification_clicked(widget) #that's maily the same thing860 self.edit_identification_clicked(widget) # that's maily the same thing
864 return861 return
865862
866 def edit_auth_info_cancel(self,widget):863 def edit_auth_info_cancel(self, widget):
867 """Called when user clicks "Later" from extrainfo-needed notification"""864 """Called when user clicks "Later" from extrainfo-needed notification"""
868 self.additional_info_req.set_visible(False)865 self.additional_info_req.set_visible(False)
869 return866 return
870 867
871 def _load_accomplishments(self):868 def _load_accomplishments(self):
872 # clear the local cache of accomplishments869 # clear the local cache of accomplishments
873 self.accomdb = []870 self.accomdb = []
874 self.accomdb = self.libaccom.build_viewer_database()871 self.accomdb = self.libaccom.build_viewer_database()
875 872
876 def opp_clicked(self, widget):873 def opp_clicked(self, widget):
877 selection = widget.get_selected_items()874 selection = widget.get_selected_items()
878 if len(selection) is 0:875 if len(selection) is 0:
@@ -881,7 +878,7 @@
881 widget.unselect_path(item)878 widget.unselect_path(item)
882 model = widget.get_model()879 model = widget.get_model()
883 accomID = model[item][COL_ID]880 accomID = model[item][COL_ID]
884 self.set_display(DISPLAY_MODE_DETAILS,accomID=accomID)881 self.set_display(DISPLAY_MODE_DETAILS, accomID=accomID)
885882
886 def mytrophy_clicked(self, widget):883 def mytrophy_clicked(self, widget):
887 selection = widget.get_selected_items()884 selection = widget.get_selected_items()
@@ -891,7 +888,7 @@
891 widget.unselect_path(item)888 widget.unselect_path(item)
892 model = widget.get_model()889 model = widget.get_model()
893 accomID = model[item][COL_ID]890 accomID = model[item][COL_ID]
894 self.set_display(DISPLAY_MODE_DETAILS,accomID=accomID)891 self.set_display(DISPLAY_MODE_DETAILS, accomID=accomID)
895892
896 def optparse_accomplishment(self, accom_id):893 def optparse_accomplishment(self, accom_id):
897 """Process the -a command line option"""894 """Process the -a command line option"""
@@ -899,8 +896,8 @@
899 # this accomplishment does not exist! aborting...896 # this accomplishment does not exist! aborting...
900 print "There is no accomplishment with this ID."897 print "There is no accomplishment with this ID."
901 return898 return
902 899
903 self.set_display(DISPLAY_MODE_DETAILS,accomID=accom_id)900 self.set_display(DISPLAY_MODE_DETAILS, accomID=accom_id)
904901
905 def prepare_models(self):902 def prepare_models(self):
906 """903 """
@@ -919,31 +916,31 @@
919 # Prepare latest trophies iconviews916 # Prepare latest trophies iconviews
920 if len(self.mytrophies_box_latest.get_children()) == 0:917 if len(self.mytrophies_box_latest.get_children()) == 0:
921 self.mytrophies_latest_boxes = []918 self.mytrophies_latest_boxes = []
922 box = self.add_mytrophies_view(self.mytrophies_box_latest,_("Today"), self.trophiesstore_filter_today)919 box = self.add_mytrophies_view(self.mytrophies_box_latest, _("Today"), self.trophiesstore_filter_today)
923 self.mytrophies_latest_boxes.append([self.trophiesstore_filter_today,box])920 self.mytrophies_latest_boxes.append([self.trophiesstore_filter_today, box])
924 box = self.add_mytrophies_view(self.mytrophies_box_latest,_("This Week"), self.trophiesstore_filter_week)921 box = self.add_mytrophies_view(self.mytrophies_box_latest, _("This Week"), self.trophiesstore_filter_week)
925 self.mytrophies_latest_boxes.append([self.trophiesstore_filter_week,box])922 self.mytrophies_latest_boxes.append([self.trophiesstore_filter_week, box])
926 box = self.add_mytrophies_view(self.mytrophies_box_latest,_("This Month"), self.trophiesstore_filter_month)923 box = self.add_mytrophies_view(self.mytrophies_box_latest, _("This Month"), self.trophiesstore_filter_month)
927 self.mytrophies_latest_boxes.append([self.trophiesstore_filter_month,box])924 self.mytrophies_latest_boxes.append([self.trophiesstore_filter_month, box])
928 box = self.add_mytrophies_view(self.mytrophies_box_latest,_("Last Six Months"), self.trophiesstore_filter_sixmonths)925 box = self.add_mytrophies_view(self.mytrophies_box_latest, _("Last Six Months"), self.trophiesstore_filter_sixmonths)
929 self.mytrophies_latest_boxes.append([self.trophiesstore_filter_sixmonths,box])926 self.mytrophies_latest_boxes.append([self.trophiesstore_filter_sixmonths, box])
930 box = self.add_mytrophies_view(self.mytrophies_box_latest,_("Earlier"), self.trophiesstore_filter_earlier)927 box = self.add_mytrophies_view(self.mytrophies_box_latest, _("Earlier"), self.trophiesstore_filter_earlier)
931 self.mytrophies_latest_boxes.append([self.trophiesstore_filter_earlier,box])928 self.mytrophies_latest_boxes.append([self.trophiesstore_filter_earlier, box])
932 929
933 # Prepare all trophies iconviews930 # Prepare all trophies iconviews
934 kids = self.mytrophies_box_all.get_children()931 kids = self.mytrophies_box_all.get_children()
935 for kid in kids:932 for kid in kids:
936 self.mytrophies_box_all.remove(k)933 self.mytrophies_box_all.remove(kid)
937 for f in self.trophies_collection_filters:934 for f in self.trophies_collection_filters:
938 del f[0] #Remove the filter!935 del f[0] # Remove the filter!
939 self.trophies_collection_filters = []936 self.trophies_collection_filters = []
940 collections = self.libaccom.list_collections()937 collections = self.libaccom.list_collections()
941 for c in collections:938 for c in collections:
942 new_filter = self.trophiesstore.filter_new()939 new_filter = self.trophiesstore.filter_new()
943 new_filter.set_visible_func(self._trophy_all_visible_func,c)940 new_filter.set_visible_func(self._trophy_all_visible_func, c)
944 box = self.add_mytrophies_view(self.mytrophies_box_all, self.libaccom.get_collection_name(c), new_filter)941 box = self.add_mytrophies_view(self.mytrophies_box_all, self.libaccom.get_collection_name(c), new_filter)
945 self.trophies_collection_filters.append([new_filter,box])942 self.trophies_collection_filters.append([new_filter, box])
946 943
947 def add_mytrophies_view(self, parent, section, model):944 def add_mytrophies_view(self, parent, section, model):
948 """945 """
949 This function is used for adding a new group of accomplishments in mytrophies view.946 This function is used for adding a new group of accomplishments in mytrophies view.
@@ -961,95 +958,95 @@
961 separator = Gtk.Separator()958 separator = Gtk.Separator()
962 separator.set_property("margin_left", 10)959 separator.set_property("margin_left", 10)
963 separator.set_property("margin_right", 10)960 separator.set_property("margin_right", 10)
964 961
965 iconview = Gtk.IconView()962 iconview = Gtk.IconView()
966 iconview.set_model(model)963 iconview.set_model(model)
967 iconview.set_text_column(COL_TITLE)964 iconview.set_text_column(COL_TITLE)
968 iconview.set_pixbuf_column(COL_PIXBUF)965 iconview.set_pixbuf_column(COL_PIXBUF)
969 iconview.set_item_width(120)966 iconview.set_item_width(120)
970 iconview.set_columns(-1)967 iconview.set_columns(-1)
971 iconview.connect("selection-changed",self.mytrophy_clicked)968 iconview.connect("selection-changed", self.mytrophy_clicked)
972969
973 outerbox.pack_start(header, False, False, 0)970 outerbox.pack_start(header, False, False, 0)
974 outerbox.pack_start(separator, False, False, 0)971 outerbox.pack_start(separator, False, False, 0)
975 outerbox.pack_start(iconview, False, False, 0)972 outerbox.pack_start(iconview, False, False, 0)
976 outerbox.show_all()973 outerbox.show_all()
977 974
978 parent.add(outerbox)975 parent.add(outerbox)
979 return outerbox976 return outerbox
980977
981 def set_display(self, 978 def set_display(self,
982 mode = DISPLAY_MODE_UNSPECIFIED,979 mode=DISPLAY_MODE_UNSPECIFIED,
983 accomID = "",980 accomID="",
984 trophies_mode = MYTROPHIES_FILTER_UNSPECIFIED,981 trophies_mode=MYTROPHIES_FILTER_UNSPECIFIED,
985 filter_locked = DISPLAY_FILTER_LOCKED_UNSPECIFIED,982 filter_locked=DISPLAY_FILTER_LOCKED_UNSPECIFIED,
986 filter_collection = DISPLAY_FILTER_COLLECTION_UNSPECIFIED,983 filter_collection=DISPLAY_FILTER_COLLECTION_UNSPECIFIED,
987 filter_category = DISPLAY_FILTER_CATEGORY_UNSPECIFIED,984 filter_category=DISPLAY_FILTER_CATEGORY_UNSPECIFIED,
988 filter_subcat = DISPLAY_FILTER_SUBCAT_UNSPECIFIED,985 filter_subcat=DISPLAY_FILTER_SUBCAT_UNSPECIFIED,
989 search_query = DISPLAY_FILTER_SEARCH_UNSPECIFIED):986 search_query=DISPLAY_FILTER_SEARCH_UNSPECIFIED):
990 """987 """
991 Switches display mode as specified in arguments.988 Switches display mode as specified in arguments.
992 It takes care about flipping notebook pages, hiding unnecessary UI pieces etc.989 It takes care about flipping notebook pages, hiding unnecessary UI pieces etc.
993 This function shouldn't be called with many arguments, pass only these that you want to override.990 This function shouldn't be called with many arguments, pass only these that you want to override.
994 """991 """
995 # The ordering of following IF statements *IS* important!992 # The ordering of following IF statements *IS* important!
996 # For example, passing both collection and category to this function993 # For example, passing both collection and category to this function
997 # may not result in skipping some of these data as they get cleared994 # may not result in skipping some of these data as they get cleared
998 # later on. Therefore hierarhical order is desired.995 # later on. Therefore hierarhical order is desired.
999 if mode is not DISPLAY_MODE_UNSPECIFIED:996 if mode is not DISPLAY_MODE_UNSPECIFIED:
1000 self.display_mode = mode997 self.display_mode = mode
1001 # Reflect changes in the UI998 # Reflect changes in the UI
1002 if self.display_mode is DISPLAY_MODE_DETAILS:999 if self.display_mode is DISPLAY_MODE_DETAILS:
1003 #Displaying details for an accomplishment1000 #Displaying details for an accomplishment
1004 1001
1005 if accomID == "":1002 if accomID == "":
1006 print "Unable to display details view, you probably forgot the accomID argument."1003 print "Unable to display details view, you probably forgot the accomID argument."
1007 return1004 return
1008 1005
1009 # Set togglable buttons to reflect current state1006 # Set togglable buttons to reflect current state
1010 self.tb_mytrophies.handler_block_by_func(self.on_tb_mytrophies_clicked) 1007 self.tb_mytrophies.handler_block_by_func(self.on_tb_mytrophies_clicked)
1011 self.tb_opportunities.handler_block_by_func(self.on_tb_opportunities_clicked) 1008 self.tb_opportunities.handler_block_by_func(self.on_tb_opportunities_clicked)
1012 self.tb_mytrophies.set_active(False) 1009 self.tb_mytrophies.set_active(False)
1013 self.tb_opportunities.set_active(False)1010 self.tb_opportunities.set_active(False)
1014 self.tb_mytrophies.handler_unblock_by_func(self.on_tb_mytrophies_clicked)1011 self.tb_mytrophies.handler_unblock_by_func(self.on_tb_mytrophies_clicked)
1015 self.tb_opportunities.handler_unblock_by_func(self.on_tb_opportunities_clicked)1012 self.tb_opportunities.handler_unblock_by_func(self.on_tb_opportunities_clicked)
1016 1013
1017 # Select all characters in searchbar1014 # Select all characters in searchbar
1018 self.searchbar.grab_focus()1015 self.searchbar.grab_focus()
1019 1016
1020 self.notebook.set_current_page(0)1017 self.notebook.set_current_page(0)
1021 self.searchbar_box.hide()1018 self.searchbar_box.hide()
1022 1019
1023 elif self.display_mode is DISPLAY_MODE_TROPHIES:1020 elif self.display_mode is DISPLAY_MODE_TROPHIES:
1024 #Display the list of trophies1021 #Display the list of trophies
1025 1022
1026 # Set togglable buttons to reflect current state1023 # Set togglable buttons to reflect current state
1027 self.tb_mytrophies.handler_block_by_func(self.on_tb_mytrophies_clicked) 1024 self.tb_mytrophies.handler_block_by_func(self.on_tb_mytrophies_clicked)
1028 self.tb_opportunities.handler_block_by_func(self.on_tb_opportunities_clicked) 1025 self.tb_opportunities.handler_block_by_func(self.on_tb_opportunities_clicked)
1029 self.tb_mytrophies.set_active(True) 1026 self.tb_mytrophies.set_active(True)
1030 self.tb_opportunities.set_active(False)1027 self.tb_opportunities.set_active(False)
1031 self.tb_mytrophies.handler_unblock_by_func(self.on_tb_mytrophies_clicked)1028 self.tb_mytrophies.handler_unblock_by_func(self.on_tb_mytrophies_clicked)
1032 self.tb_opportunities.handler_unblock_by_func(self.on_tb_opportunities_clicked)1029 self.tb_opportunities.handler_unblock_by_func(self.on_tb_opportunities_clicked)
1033 1030
1034 # Select all characters in searchbar1031 # Select all characters in searchbar
1035 self.searchbar.grab_focus()1032 self.searchbar.grab_focus()
1036 1033
1037 self.notebook.set_current_page(1)1034 self.notebook.set_current_page(1)
1038 self.searchbar_box.show()1035 self.searchbar_box.show()
1039 1036
1040 elif self.display_mode is DISPLAY_MODE_OPPORTUNITIES:1037 elif self.display_mode is DISPLAY_MODE_OPPORTUNITIES:
1041 1038
1042 # Set togglable buttons to reflect current state1039 # Set togglable buttons to reflect current state
1043 self.tb_mytrophies.handler_block_by_func(self.on_tb_mytrophies_clicked) 1040 self.tb_mytrophies.handler_block_by_func(self.on_tb_mytrophies_clicked)
1044 self.tb_opportunities.handler_block_by_func(self.on_tb_opportunities_clicked) 1041 self.tb_opportunities.handler_block_by_func(self.on_tb_opportunities_clicked)
1045 self.tb_mytrophies.set_active(False) 1042 self.tb_mytrophies.set_active(False)
1046 self.tb_opportunities.set_active(True)1043 self.tb_opportunities.set_active(True)
1047 self.tb_mytrophies.handler_unblock_by_func(self.on_tb_mytrophies_clicked)1044 self.tb_mytrophies.handler_unblock_by_func(self.on_tb_mytrophies_clicked)
1048 self.tb_opportunities.handler_unblock_by_func(self.on_tb_opportunities_clicked)1045 self.tb_opportunities.handler_unblock_by_func(self.on_tb_opportunities_clicked)
1049 1046
1050 self.notebook.set_current_page(2)1047 self.notebook.set_current_page(2)
1051 self.searchbar_box.show()1048 self.searchbar_box.show()
1052 1049
1053 if trophies_mode is not MYTROPHIES_FILTER_UNSPECIFIED:1050 if trophies_mode is not MYTROPHIES_FILTER_UNSPECIFIED:
1054 self.display_mytrophies_filtermode = trophies_mode1051 self.display_mytrophies_filtermode = trophies_mode
1055 # Show/hide appropriate iconview1052 # Show/hide appropriate iconview
@@ -1057,12 +1054,12 @@
1057 self.mytrophies_notebook.set_current_page(0)1054 self.mytrophies_notebook.set_current_page(0)
1058 elif self.display_mytrophies_filtermode is MYTROPHIES_FILTER_LATEST:1055 elif self.display_mytrophies_filtermode is MYTROPHIES_FILTER_LATEST:
1059 self.mytrophies_notebook.set_current_page(1)1056 self.mytrophies_notebook.set_current_page(1)
1060 1057
1061 if filter_locked is not DISPLAY_FILTER_LOCKED_UNSPECIFIED:1058 if filter_locked is not DISPLAY_FILTER_LOCKED_UNSPECIFIED:
1062 self.display_filter_locked = filter_locked1059 self.display_filter_locked = filter_locked
1063 if filter_collection is not DISPLAY_FILTER_COLLECTION_UNSPECIFIED:1060 if filter_collection is not DISPLAY_FILTER_COLLECTION_UNSPECIFIED:
1064 self.display_filter_collection = filter_collection1061 self.display_filter_collection = filter_collection
1065 1062
1066 # As the requested collection changed, we need to update the categories combo.1063 # As the requested collection changed, we need to update the categories combo.
1067 if filter_collection == "":1064 if filter_collection == "":
1068 self.opp_cat_store.clear()1065 self.opp_cat_store.clear()
@@ -1075,28 +1072,27 @@
1075 for i in sorted(cats):1072 for i in sorted(cats):
1076 self.opp_cat_store.append([i, i])1073 self.opp_cat_store.append([i, i])
1077 self.opp_combo_cat.set_sensitive(True)1074 self.opp_combo_cat.set_sensitive(True)
1078 1075
1079 # Set the active item to "everything".1076 # Set the active item to "everything".
1080 self.display_filter_category = ""1077 self.display_filter_category = ""
1081 self.opp_combo_cat.handler_block_by_func(self.on_filter_category_changed)1078 self.opp_combo_cat.handler_block_by_func(self.on_filter_category_changed)
1082 self.opp_combo_cat.set_active(0)1079 self.opp_combo_cat.set_active(0)
1083 self.opp_combo_cat.handler_unblock_by_func(self.on_filter_category_changed)1080 self.opp_combo_cat.handler_unblock_by_func(self.on_filter_category_changed)
1084 1081
1085 # It is likely that we need to update the subcategories.1082 # It is likely that we need to update the subcategories.
1086 # A special case is when it needs to be hidden after collection change.1083 # A special case is when it needs to be hidden after collection change.
1087 self._update_subcats()1084 self._update_subcats()
1088 1085
1089 if filter_category is not DISPLAY_FILTER_CATEGORY_UNSPECIFIED:1086 if filter_category is not DISPLAY_FILTER_CATEGORY_UNSPECIFIED:
1090 self.display_filter_category = filter_category1087 self.display_filter_category = filter_category
1091 1088
1092 # Changing category, therefore we should display the subcats bar too.1089 # Changing category, therefore we should display the subcats bar too.
1093 self._update_subcats()1090 self._update_subcats()
1094 1091
1095 if filter_subcat is not DISPLAY_FILTER_SUBCAT_UNSPECIFIED:1092 if filter_subcat is not DISPLAY_FILTER_SUBCAT_UNSPECIFIED:
1096 self.display_filter_subcat = filter_subcat1093 self.display_filter_subcat = filter_subcat
1097 if search_query is not DISPLAY_FILTER_SEARCH_UNSPECIFIED:1094 if search_query is not DISPLAY_FILTER_SEARCH_UNSPECIFIED:
1098 self.display_filter_search = search_query1095 self.display_filter_search = search_query
1099
11001096
1101 # Finally, pass refreshing/rerendering to specialised functions1097 # Finally, pass refreshing/rerendering to specialised functions
1102 if self.display_mode is DISPLAY_MODE_DETAILS:1098 if self.display_mode is DISPLAY_MODE_DETAILS:
@@ -1105,7 +1101,7 @@
1105 self._update_mytrophy_view()1101 self._update_mytrophy_view()
1106 elif self.display_mode is DISPLAY_MODE_OPPORTUNITIES:1102 elif self.display_mode is DISPLAY_MODE_OPPORTUNITIES:
1107 self._update_opportunities_view()1103 self._update_opportunities_view()
1108 1104
1109 def _update_mytrophy_view(self):1105 def _update_mytrophy_view(self):
1110 # Causes the treemodel to call visible_func for all rows.1106 # Causes the treemodel to call visible_func for all rows.
1111 # It also hides/shows boxes depending on whether they are empty.1107 # It also hides/shows boxes depending on whether they are empty.
@@ -1113,7 +1109,7 @@
1113 filterlist = self.trophies_collection_filters1109 filterlist = self.trophies_collection_filters
1114 elif self.display_mytrophies_filtermode is MYTROPHIES_FILTER_LATEST:1110 elif self.display_mytrophies_filtermode is MYTROPHIES_FILTER_LATEST:
1115 filterlist = self.mytrophies_latest_boxes1111 filterlist = self.mytrophies_latest_boxes
1116 1112
1117 for f in filterlist:1113 for f in filterlist:
1118 f[0].refilter()1114 f[0].refilter()
1119 if len(f[0]) is 0:1115 if len(f[0]) is 0:
@@ -1124,7 +1120,7 @@
1124 def _update_opportunities_view(self):1120 def _update_opportunities_view(self):
1125 # Causes the treemodel to call visible_func for all rows.1121 # Causes the treemodel to call visible_func for all rows.
1126 self.oppstore_filtered.refilter()1122 self.oppstore_filtered.refilter()
1127 1123
1128 def _opp_visible_func(self, model, iterator, data):1124 def _opp_visible_func(self, model, iterator, data):
1129 """1125 """
1130 This function is crucial for filtering opportunities. It is called1126 This function is crucial for filtering opportunities. It is called
@@ -1133,26 +1129,29 @@
1133 should be displayed or not.1129 should be displayed or not.
1134 """1130 """
1135 # If we are hiding locked accoms:1131 # If we are hiding locked accoms:
1136 if (self.display_filter_locked is DISPLAY_FILTER_LOCKED_HIDE) and model.get_value(iterator,COL_LOCKED):1132 if (self.display_filter_locked is DISPLAY_FILTER_LOCKED_HIDE) and model.get_value(iterator, COL_LOCKED):
1137 return False1133 return False
1138 # If we ale looking for a certain collection:1134 # If we ale looking for a certain collection:
1139 if (self.display_filter_collection != "") and (self.display_filter_collection != model.get_value(iterator,COL_COLLECTION)):1135 if (self.display_filter_collection != "") and (self.display_filter_collection != model.get_value(iterator, COL_COLLECTION)):
1140 return False1136 return False
1141 # If we ale looking for a certain category...1137 # If we ale looking for a certain category...
1142 if (self.display_filter_category != ""):1138 if (self.display_filter_category != ""):
1143 #...and a subcategory1139 #...and a subcategory
1144 if (self.display_filter_subcat != ""):1140 if (self.display_filter_subcat != ""):
1145 q = self.display_filter_category + ":" + self.display_filter_subcat1141 q = self.display_filter_category + ":" + self.display_filter_subcat
1146 if not (q in model.get_value(iterator,COL_CATEGORIES)):1142 if not (q in model.get_value(iterator, COL_CATEGORIES)):
1147 return False1143 return False
1148 if not (self.display_filter_category in model.get_value(iterator,COL_CATEGORIES)):1144 if not (self.display_filter_category in model.get_value(iterator, COL_CATEGORIES)):
1149 return False1145 return False
1150 # If there is a search term and this row does not match the query:1146 # If there is a search term and this row does not match the query:
1151 if (self.display_filter_search != "") and not (self.display_filter_search.lower() in model.get_value(iterator,COL_TITLE).lower()) and not (self.display_filter_search.lower() in model.get_value(iterator,COL_KEYWORDS).lower()) and not (self.display_filter_search.lower() in model.get_value(iterator,COL_ID).split("/")[1].lower()):1147 if (self.display_filter_search != "") \
1152 return False1148 and not (self.display_filter_search.lower() in model.get_value(iterator, COL_TITLE).lower()) \
1149 and not (self.display_filter_search.lower() in model.get_value(iterator, COL_KEYWORDS).lower()) \
1150 and not (self.display_filter_search.lower() in model.get_value(iterator, COL_ID).split("/")[1].lower()):
1151 return False
1153 return True1152 return True
11541153
1155 def _trophy_recent_visible_func(self,model,iterator,data):1154 def _trophy_recent_visible_func(self, model, iterator, data):
1156 """1155 """
1157 This function is crucial for filtering recently awarded trophies. It is called1156 This function is crucial for filtering recently awarded trophies. It is called
1158 by some internal GTK callbacks, whenever the treemodel changes.1157 by some internal GTK callbacks, whenever the treemodel changes.
@@ -1164,50 +1163,53 @@
11641163
1165 #XXX: Making these constants global might save some filtering time.1164 #XXX: Making these constants global might save some filtering time.
1166 today = datetime.date.today()1165 today = datetime.date.today()
1167 margin_today = datetime.timedelta(days = 1)1166 margin_today = datetime.timedelta(days=1)
1168 margin_week = datetime.timedelta(days = 7)1167 margin_week = datetime.timedelta(days=7)
1169 margin_month = datetime.timedelta(days = 31)1168 margin_month = datetime.timedelta(days=31)
1170 margin_sixmonths = datetime.timedelta(days = 180)1169 margin_sixmonths = datetime.timedelta(days=180)
1171 1170
1172 when = model.get_value(iterator,COL_DATE_ACCOMPLISHED)1171 when = model.get_value(iterator, COL_DATE_ACCOMPLISHED)
1173 if when == "None":1172 if when == "None":
1174 return False1173 return False
1175 year, month, day = when.split("-")1174 year, month, day = when.split("-")
1176 when = datetime.date(int(year), int(month), int(day.split(" ")[0]))1175 when = datetime.date(int(year), int(month), int(day.split(" ")[0]))
1177 1176
1178 if (today - margin_today <= when <= today + margin_today):1177 if (today - margin_today <= when <= today + margin_today):
1179 if data is TROPHIES_FILTER_TODAY:1178 if data is TROPHIES_FILTER_TODAY:
1180 pass #proceed to further filtering1179 pass # proceed to further filtering
1181 else:1180 else:
1182 return False1181 return False
1183 elif (today - margin_week <= when <= today + margin_week):1182 elif (today - margin_week <= when <= today + margin_week):
1184 if data is TROPHIES_FILTER_WEEK:1183 if data is TROPHIES_FILTER_WEEK:
1185 pass #proceed to further filtering1184 pass # proceed to further filtering
1186 else:1185 else:
1187 return False1186 return False
1188 elif (today - margin_month <= when <= today + margin_month):1187 elif (today - margin_month <= when <= today + margin_month):
1189 if data is TROPHIES_FILTER_MONTH:1188 if data is TROPHIES_FILTER_MONTH:
1190 pass #proceed to further filtering1189 pass # proceed to further filtering
1191 else:1190 else:
1192 return False1191 return False
1193 elif (today - margin_sixmonths <= when <= today + margin_sixmonths):1192 elif (today - margin_sixmonths <= when <= today + margin_sixmonths):
1194 if data is TROPHIES_FILTER_SIXMONTHS:1193 if data is TROPHIES_FILTER_SIXMONTHS:
1195 pass #proceed to further filtering1194 pass # proceed to further filtering
1196 else:1195 else:
1197 return False1196 return False
1198 else:1197 else:
1199 if data is TROPHIES_FILTER_EARLIER:1198 if data is TROPHIES_FILTER_EARLIER:
1200 pass #proceed to further filtering1199 pass # proceed to further filtering
1201 else:1200 else:
1202 return False1201 return False
1203 1202
1204 # If there is a search term and this row does not match the query:1203 # If there is a search term and this row does not match the query:
1205 if (self.display_filter_search != "") and not (self.display_filter_search.lower() in model.get_value(iterator,COL_TITLE).lower()) and not (self.display_filter_search.lower() in model.get_value(iterator,COL_KEYWORDS).lower()) and not (self.display_filter_search.lower() in model.get_value(iterator,COL_ID).split("/")[1].lower()):1204 if (self.display_filter_search != "") \
1206 return False1205 and not (self.display_filter_search.lower() in model.get_value(iterator, COL_TITLE).lower()) \
1207 1206 and not (self.display_filter_search.lower() in model.get_value(iterator, COL_KEYWORDS).lower()) \
1207 and not (self.display_filter_search.lower() in model.get_value(iterator, COL_ID).split("/")[1].lower()):
1208 return False
1209
1208 return True1210 return True
1209 1211
1210 def _trophy_all_visible_func(self,model,iterator,collection):1212 def _trophy_all_visible_func(self, model, iterator, collection):
1211 """1213 """
1212 This function is crucial for filtering mytrophies. It is called1214 This function is crucial for filtering mytrophies. It is called
1213 by some internal GTK callbacks, whenever the treemodel changes.1215 by some internal GTK callbacks, whenever the treemodel changes.
@@ -1216,14 +1218,16 @@
1216 The @data argument specifies filtered collection.1218 The @data argument specifies filtered collection.
1217 """1219 """
1218 # If row's collection matches the desired for this filter1220 # If row's collection matches the desired for this filter
1219 if (collection != model.get_value(iterator,COL_COLLECTION)):1221 if (collection != model.get_value(iterator, COL_COLLECTION)):
1220 return False1222 return False
1221 # If there is a search term and this row does not match the query:1223 # If there is a search term and this row does not match the query:
1222 if (self.display_filter_search != "") and not (self.display_filter_search.lower() in model.get_value(iterator,COL_TITLE).lower()) and not (self.display_filter_search.lower() in model.get_value(iterator,COL_ID).split("/")[1].lower()):1224 if (self.display_filter_search != "") \
1223 return False1225 and not (self.display_filter_search.lower() in model.get_value(iterator, COL_TITLE).lower()) \
1226 and not (self.display_filter_search.lower() in model.get_value(iterator, COL_ID).split("/")[1].lower()):
1227 return False
1224 return True1228 return True
12251229
1226 def _update_subcats(self): 1230 def _update_subcats(self):
1227 """1231 """
1228 This function creates the buttons for subcategories, requesting required data from the daemon.1232 This function creates the buttons for subcategories, requesting required data from the daemon.
1229 """1233 """
@@ -1238,15 +1242,17 @@
1238 tempcats = cats[c]1242 tempcats = cats[c]
12391243
1240 finalcats = []1244 finalcats = []
1241 1245
1242 for s in tempcats:1246 for s in tempcats:
1243 for i in self.accomdb:1247 for i in self.accomdb:
1244 if i["collection"] == self.display_filter_collection and i["categories"][0] == self.display_filter_category + ":" + s and i["accomplished"] == False:1248 if i["collection"] == self.display_filter_collection \
1249 and i["categories"][0] == self.display_filter_category + ":" + s \
1250 and i["accomplished"] is False:
1245 finalcats.append(s)1251 finalcats.append(s)
12461252
1247 # convert to a set to remove dupes1253 # convert to a set to remove dupes
1248 finalcats = set(finalcats)1254 finalcats = set(finalcats)
1249 1255
1250 # remove previous buttons from the button box1256 # remove previous buttons from the button box
1251 for b in self.subcats_buttonbox.get_children():1257 for b in self.subcats_buttonbox.get_children():
1252 self.subcats_buttonbox.remove(b)1258 self.subcats_buttonbox.remove(b)
@@ -1258,7 +1264,7 @@
1258 button.connect("clicked", self.subcat_clicked, "")1264 button.connect("clicked", self.subcat_clicked, "")
1259 self.subcats_buttonbox.add(button)1265 self.subcats_buttonbox.add(button)
1260 button.show()1266 button.show()
1261 1267
1262 # fill the button box with the sub categories1268 # fill the button box with the sub categories
1263 for s in finalcats:1269 for s in finalcats:
1264 button = Gtk.Button(s)1270 button = Gtk.Button(s)
@@ -1266,34 +1272,37 @@
1266 button.connect("clicked", self.subcat_clicked, s)1272 button.connect("clicked", self.subcat_clicked, s)
1267 self.subcats_buttonbox.add(button)1273 self.subcats_buttonbox.add(button)
1268 button.show()1274 button.show()
1269 1275
1270 self.subcats_buttonbox.show_all()1276 self.subcats_buttonbox.show_all()
1271 self.subcats_container.show()1277 self.subcats_container.show()
1272 else:1278 else:
1273 self.subcats_container.hide()1279 self.subcats_container.hide()
1274 1280
1275 def _accomplishment_info(self, accomID):1281 def _accomplishment_info(self, accomID):
1276 """Display information about the selected accomplishment."""1282 """Display information about the selected accomplishment."""
1277 data = []1283 data = []
1278 1284
1279 # determine dependencies1285 # determine dependencies
1280 1286
1281 deps = []1287 deps = []
1282 depstatus = []1288 depstatus = []
1283 1289
1284 deps = self.libaccom.get_accom_depends(accomID)1290 deps = self.libaccom.get_accom_depends(accomID)
1285 1291
1286 for acc in self.accomdb:1292 for acc in self.accomdb:
1287 for d in deps:1293 for d in deps:
1288 if acc["id"] == d:1294 if acc["id"] == d:
1289 depstatus.append({ "id" : acc["id"], "accomplished" : acc["accomplished"], "collection-human" : acc["collection-human"], "title" : acc["title"] })1295 depstatus.append({
1290 1296 "id": acc["id"],
1291 1297 "accomplished": acc["accomplished"],
1298 "collection-human": acc["collection-human"],
1299 "title": acc["title"]
1300 })
1301
1292 achieved = self.libaccom.get_accom_is_accomplished(accomID)1302 achieved = self.libaccom.get_accom_is_accomplished(accomID)
1293 data = self.libaccom.get_accom_data(accomID)1303 data = self.libaccom.get_accom_data(accomID)
1294 if achieved:1304 if achieved:
1295 trophydata = self.libaccom.get_trophy_data(accomID)1305 trophydata = self.libaccom.get_trophy_data(accomID)
1296
12971306
1298 html = None1307 html = None
12991308
@@ -1311,17 +1320,16 @@
1311 html = html + "<div id='header' class='grid_8'> \1320 html = html + "<div id='header' class='grid_8'> \
1312 <h1>" + data['title'] + "</h1> \1321 <h1>" + data['title'] + "</h1> \
1313 </div>"1322 </div>"
1314
1315
13161323
1317 ## summary table1324 ## summary table
1318 html = html + "<div id='accomplishment' class='grid_8 clearfix'> \1325 html = html + "<div id='accomplishment' class='grid_8 clearfix'> \
1319 <div id='accomplishment-badge' class='grid_8 clearfix'>"1326 <div id='accomplishment-badge' class='grid_8 clearfix'>"
13201327
1321 if achieved and GWIBBER_OK:1328 if achieved and GWIBBER_OK:
1322 html = html + "<div id='social-share'><a href='gwibber-share?accomID="+accomID+"' id='gwibber-share'>+SHARE</a></div>"1329 html = html + "<div id='social-share'><a href='gwibber-share?accomID=" + accomID + \
1330 "' id='gwibber-share'>+SHARE</a></div>"
13231331
1324 html = html +"<img class='icon' src='" + str(iconpath) + "'> \1332 html = html + "<img class='icon' src='" + str(iconpath) + "'> \
1325 <div class='grid_3 block'> \1333 <div class='grid_3 block'> \
1326 <h4>" + _("Opportunity Information").decode('utf-8') + ":</h4> \1334 <h4>" + _("Opportunity Information").decode('utf-8') + ":</h4> \
1327 <ul class='none'> \1335 <ul class='none'> \
@@ -1332,53 +1340,59 @@
1332 html = html + description1340 html = html + description
1333 else:1341 else:
1334 html = html + _("No information available.").decode('utf-8')1342 html = html + _("No information available.").decode('utf-8')
1335 1343
1336
1337 html = html + "</li> \1344 html = html + "</li> \
1338 </ul> \1345 </ul> \
1339 </div>"1346 </div>"
13401347
1341 if not achieved:1348 if not achieved:
1342 1349
1343 html = html + "<div class='grid_3 block'> \1350 html = html + "<div class='grid_3 block'> \
1344 <h4>" + _("Getting Help").decode('utf-8') + ":</h4> \1351 <h4>" + _("Getting Help").decode('utf-8') + ":</h4> \
1345 <ul class='none'>"1352 <ul class='none'>"
1346 1353
1347 if "help" in data:1354 if "help" in data:
1348 help = data["help"]1355 help = data["help"]
13491356
1350 for l in help.split('\n'):1357 for l in help.split('\n'):
1351 channelName = l[l.find("#")+1:l.find(" ")]1358 channelName = l[l.find("#") + 1:l.find(" ")]
1352 if l.startswith( '#'+channelName ):1359 if l.startswith('#' + channelName):
1353 l = "<a style='color:#FFF' href='http://webchat.freenode.net/?channels="+channelName+"'>"+'#'+channelName+" on freenode</a>" 1360 l = "<a style='color:#FFF' href='http://webchat.freenode.net/?channels=" + channelName + "'>" \
1361 + '#' + channelName + " on freenode</a>"
1354 html = html + "<li>" + l + "</li>"1362 html = html + "<li>" + l + "</li>"
1355 else:1363 else:
1356 html = html + "<li>" + l + "</li>" 1364 html = html + "<li>" + l + "</li>"
1357 else:1365 else:
1358 html = html + "<li>" + _("No help available.").decode('utf-8') + "</li>"1366 html = html + "<li>" + _("No help available.").decode('utf-8') + "</li>"
1359 1367
1360 html = html + "</ul></div>"1368 html = html + "</ul></div>"
13611369
1362
1363 html = html + "</div>"1370 html = html + "</div>"
13641371
1365 html = html + "<div id='accomplishment-conditions' class='grid_8'> \1372 html = html + "<div id='accomplishment-conditions' class='grid_8'> \
1366 <ul class='none'>"1373 <ul class='none'>"
1367 1374
1368 if "depends" in data:1375 if "depends" in data:
1369 # check if it is locked1376 # check if it is locked
1370 if not self.libaccom.get_accom_is_unlocked(accomID):1377 if not self.libaccom.get_accom_is_unlocked(accomID):
1371 if len(depstatus) > 0:1378 if len(depstatus) > 0:
1372 if len(depstatus) == 1:1379 if len(depstatus) == 1:
1373 html = html + "<li><i class='icon-key icon-large'></i>" + _("This opportunity is locked. You need to complete").decode('utf-8') + " <a href='accomplishment://" + depstatus[0]["id"] + "'><strong>" + depstatus[0]["title"] + "</strong></a> " + _("from").decode('utf-8') +" <strong>" + depstatus[0]["collection-human"] + "</strong> " + _("first").decode('utf-8') + ".</li>"1380 html = html + "<li><i class='icon-key icon-large'></i>" + \
1381 _("This opportunity is locked. You need to complete").decode('utf-8') + \
1382 " <a href='accomplishment://" + depstatus[0]["id"] + "'><strong>" + \
1383 depstatus[0]["title"] + "</strong></a> " + _("from").decode('utf-8') + \
1384 " <strong>" + depstatus[0]["collection-human"] + "</strong> " + \
1385 _("first").decode('utf-8') + ".</li>"
1374 else:1386 else:
1375 html = html + "<li><i class='icon-key icon-large'></i>" + _("This opportunity is locked. You need to complete the following opportunities first:").decode('utf-8') + "</li>"1387 html = html + "<li><i class='icon-key icon-large'></i>" + _("This opportunity is locked. You need to complete the following opportunities first:").decode('utf-8') + "</li>"
1376 for d in depstatus:1388 for d in depstatus:
1377 if d["accomplished"] == False:1389 if d["accomplished"] is False:
1378 html = html + "<li class='deps_child'><a href='accomplishment://" + d["id"] + "'><strong>" + d["title"] + "</strong></a> " + _("from").decode('utf-8') +" <strong>" + d["collection-human"] + "</strong></li>"1390 html = html + "<li class='deps_child'><a href='accomplishment://" + d["id"] + \
1391 "'><strong>" + d["title"] + "</strong></a> " + _("from").decode('utf-8') + \
1392 " <strong>" + d["collection-human"] + "</strong></li>"
1379 if achieved:1393 if achieved:
1380 #achieved1394 #achieved
1381 1395
1382 html = html + "<li><img src='" + str(get_media_file("verify-icon.png")) + "' height='20' />" + _("This trophy <strong>was awarded</strong>").decode('utf-8')1396 html = html + "<li><img src='" + str(get_media_file("verify-icon.png")) + "' height='20' />" + _("This trophy <strong>was awarded</strong>").decode('utf-8')
13831397
1384 if "date-accomplished" in trophydata:1398 if "date-accomplished" in trophydata:
@@ -1389,10 +1403,10 @@
1389 extrainfo = trophydata["needs-information"].split(" ")1403 extrainfo = trophydata["needs-information"].split(" ")
1390 html = html + ", " + _("using the following credentials").decode('utf-8') + ":</li><li><ul class='big'>"1404 html = html + ", " + _("using the following credentials").decode('utf-8') + ":</li><li><ul class='big'>"
1391 for i in extrainfo:1405 for i in extrainfo:
1392 e = self.libaccom.get_extra_information(accomID.split("/")[0],i)1406 e = self.libaccom.get_extra_information(accomID.split("/")[0], i)
1393 html = html + "<li>" + e[0]["label"] + ": " + trophydata[i] + "</li>"1407 html = html + "<li>" + e[0]["label"] + ": " + trophydata[i] + "</li>"
1394 html = html + "</ul></li>"1408 html = html + "</ul></li>"
1395 else: 1409 else:
1396 html = html + ".</li>"1410 html = html + ".</li>"
13971411
1398 if "needs-signing" in data:1412 if "needs-signing" in data:
@@ -1430,17 +1444,15 @@
1430 else:1444 else:
1431 #details not hidden by default1445 #details not hidden by default
1432 html = html + "<div>"1446 html = html + "<div>"
1433 1447
1434
1435 if "summary" in data:1448 if "summary" in data:
1436 html = html + "<div id='accompilshment-info' class='grid_8'>"1449 html = html + "<div id='accompilshment-info' class='grid_8'>"
1437 summary = data["summary"]1450 summary = data["summary"]
1438 for l in summary.split('\n'):1451 for l in summary.split('\n'):
1439 html = html + "<p>" + l + "</p>"1452 html = html + "<p>" + l + "</p>"
1440 html = html + "</div>"1453 html = html + "</div>"
14411454
14421455 html = html + "<div id='accomplishment-more' class='grid_8'>"
1443 html = html + "<div id='accomplishment-more' class='grid_8'>"
14441456
1445 if "steps" in data:1457 if "steps" in data:
14461458
@@ -1448,7 +1460,7 @@
1448 <i class='icon-list'></i> \1460 <i class='icon-list'></i> \
1449 <h2>" + _("How to accomplish this opportunity").decode('utf-8') + "</h2> \1461 <h2>" + _("How to accomplish this opportunity").decode('utf-8') + "</h2> \
1450 <ol>"1462 <ol>"
1451 1463
1452 steps = data["steps"]1464 steps = data["steps"]
1453 for l in steps.split('\n'):1465 for l in steps.split('\n'):
1454 html = html + "<li class='icon-pushpin'>" + l + "</li>"1466 html = html + "<li class='icon-pushpin'>" + l + "</li>"
@@ -1458,7 +1470,7 @@
1458 showtipspitfalls = False1470 showtipspitfalls = False
1459 haspitfalls = False1471 haspitfalls = False
1460 hastips = False1472 hastips = False
1461 1473
1462 if "tips" in data or "pitfalls" in data:1474 if "tips" in data or "pitfalls" in data:
1463 try:1475 try:
1464 if not data["tips"] == "None":1476 if not data["tips"] == "None":
@@ -1466,51 +1478,51 @@
1466 hastips = True1478 hastips = True
1467 except:1479 except:
1468 hastips = False1480 hastips = False
1469 1481
1470 try:1482 try:
1471 if not data["pitfalls"] == "None":1483 if not data["pitfalls"] == "None":
1472 showtipspitfalls = True 1484 showtipspitfalls = True
1473 haspitfalls = True1485 haspitfalls = True
1474 except:1486 except:
1475 haspitfalls = False1487 haspitfalls = False
1476 1488
1477 if showtipspitfalls == True:1489 if showtipspitfalls is True:
1478 html = html + " <div id='tipspitfalls' class='grid_8 clearfix'>"1490 html = html + " <div id='tipspitfalls' class='grid_8 clearfix'>"
1479 else:1491 else:
1480 showtipspitfalls == False1492 showtipspitfalls is False
1481 1493
1482 if showtipspitfalls == True:1494 if showtipspitfalls is True:
1483 html = html + "<div class='grid_4 block left' id='tips'>"1495 html = html + "<div class='grid_4 block left' id='tips'>"
1484 html = html + "<h2>" + _("Tips and Tricks").decode('utf-8') + ":</h2>"1496 html = html + "<h2>" + _("Tips and Tricks").decode('utf-8') + ":</h2>"
1485 1497
1486 if hastips == True:1498 if hastips is True:
1487 tips = data["tips"]1499 tips = data["tips"]
1488 else:1500 else:
1489 tips = None1501 tips = None
1490 1502
1491 html = html + "<ul>"1503 html = html + "<ul>"
14921504
1493 if tips == None:1505 if tips is None:
1494 html = html + "<li class='icon-ok'>" + _("None.").decode('utf-8') + "</li>"1506 html = html + "<li class='icon-ok'>" + _("None.").decode('utf-8') + "</li>"
1495 else:1507 else:
1496 for t in tips.split('\n'):1508 for t in tips.split('\n'):
1497 html = html + "<li class='icon-ok'>" + t + "</li>"1509 html = html + "<li class='icon-ok'>" + t + "</li>"
1498 1510
1499 html = html + "</ul>"1511 html = html + "</ul>"
1500 html = html + "</div>"1512 html = html + "</div>"
15011513
1502 html = html + "<div id='divider' class='left'>&nbsp;</div>"1514 html = html + "<div id='divider' class='left'>&nbsp;</div>"
1503 html = html + "<div class='grid_3 block left' id='pitfals'>"1515 html = html + "<div class='grid_3 block left' id='pitfals'>"
1504 html = html + "<h2>" + _("Pitfalls To Avoid").decode('utf-8') + ":</h2>"1516 html = html + "<h2>" + _("Pitfalls To Avoid").decode('utf-8') + ":</h2>"
1505 1517
1506 if haspitfalls == True:1518 if haspitfalls is True:
1507 pitfalls = data["pitfalls"]1519 pitfalls = data["pitfalls"]
1508 else:1520 else:
1509 pitfalls = None1521 pitfalls = None
1510 1522
1511 html = html + "<ul>"1523 html = html + "<ul>"
15121524
1513 if pitfalls == None:1525 if pitfalls is None:
1514 html = html + "<li class='icon-remove'>" + _("None.").decode('utf-8') + "</li>"1526 html = html + "<li class='icon-remove'>" + _("None.").decode('utf-8') + "</li>"
1515 else:1527 else:
1516 for p in pitfalls.split('\n'):1528 for p in pitfalls.split('\n'):
@@ -1537,4 +1549,3 @@
15371549
1538 self.webview.load_html_string(html, "file:///")1550 self.webview.load_html_string(html, "file:///")
1539 self.webview.show()1551 self.webview.show()
1540
15411552
=== modified file 'accomplishments_viewer/EditExtrainfoDialog.py'
--- accomplishments_viewer/EditExtrainfoDialog.py 2012-11-22 10:42:15 +0000
+++ accomplishments_viewer/EditExtrainfoDialog.py 2012-11-26 16:03:25 +0000
@@ -1,48 +1,45 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2### BEGIN LICENSE2### BEGIN LICENSE
3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>
4# This program is free software: you can redistribute it and/or modify it 4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published 5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.6# by the Free Software Foundation.
7# 7#
8# This program is distributed in the hope that it will be useful, but 8# This program is distributed in the hope that it will be useful, but
9# WITHOUT ANY WARRANTY; without even the implied warranties of 9# WITHOUT ANY WARRANTY; without even the implied warranties of
10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11# PURPOSE. See the GNU General Public License for more details.11# PURPOSE. See the GNU General Public License for more details.
12# 12#
13# You should have received a copy of the GNU General Public License along 13# You should have received a copy of the GNU General Public License along
14# with this program. If not, see <http://www.gnu.org/licenses/>.14# with this program. If not, see <http://www.gnu.org/licenses/>.
15### END LICENSE15### END LICENSE
16import logging
1716
18from gi.repository import Gtk # pylint: disable=E061117from gi.repository import Gtk # pylint: disable=E0611
19from operator import itemgetter18from operator import itemgetter
20from accomplishments_viewer_lib.helpers import get_builder19from accomplishments_viewer_lib.helpers import get_builder
21from accomplishments.daemon import dbusapi
2220
23import gettext, locale21import gettext
24from locale import gettext as _22import locale
25from accomplishments.util.paths import locale_dir23from accomplishments.util.paths import locale_dir
26locale.bindtextdomain('accomplishments-viewer', locale_dir)24locale.bindtextdomain('accomplishments-viewer', locale_dir)
27gettext.bindtextdomain('accomplishments-viewer',locale_dir)25gettext.bindtextdomain('accomplishments-viewer', locale_dir)
28locale.textdomain('accomplishments-viewer')26locale.textdomain('accomplishments-viewer')
29 27
30 28
31
32class EditExtrainfoDialog(Gtk.Dialog):29class EditExtrainfoDialog(Gtk.Dialog):
33 __gtype_name__ = "EditExtrainfoDialog"30 __gtype_name__ = "EditExtrainfoDialog"
34 31
35 def __new__(cls):32 def __new__(cls):
36 """Special static method that's automatically called by Python when 33 """Special static method that's automatically called by Python when
37 constructing a new instance of this class.34 constructing a new instance of this class.
38 35
39 Returns a fully instantiated EditExtrainfoDialog object.36 Returns a fully instantiated EditExtrainfoDialog object.
40 """37 """
41 builder = get_builder('EditExtrainfoDialog')38 builder = get_builder('EditExtrainfoDialog')
42 new_object = builder.get_object('edit_extrainfo_dialog')39 new_object = builder.get_object('edit_extrainfo_dialog')
43 new_object.finish_initializing(builder)40 new_object.finish_initializing(builder)
44 return new_object41 return new_object
45 42
46 def finish_initializing(self, builder):43 def finish_initializing(self, builder):
47 """Called when we're finished initializing.44 """Called when we're finished initializing.
4845
@@ -54,33 +51,33 @@
54 # Get a reference to the builder and set up the signals.51 # Get a reference to the builder and set up the signals.
55 self.builder = builder52 self.builder = builder
56 self.ui = builder.get_ui(self)53 self.ui = builder.get_ui(self)
57 self.auth_box = builder.get_object('auth_box') 54 self.auth_box = builder.get_object('auth_box')
58 self.btn_ok = builder.get_object('btn_ok') 55 self.btn_ok = builder.get_object('btn_ok')
59 56
60 def prepare(self,libaccom):57 def prepare(self, libaccom):
61 """Called before run()nig, setups the window"""58 """Called before run()nig, setups the window"""
62 # use self.parent.libaccom for calling59 # use self.parent.libaccom for calling
63 # use self.parent.connected to check if connected to daemon60 # use self.parent.connected to check if connected to daemon
64 self.libaccom = libaccom61 self.libaccom = libaccom
65 62
66 i = self.libaccom.get_all_extra_information()63 i = self.libaccom.get_all_extra_information()
67 64
68 self.entries_map = {}65 self.entries_map = {}
69 66
70 #remove all widgets that are contained in the auth_box67 #remove all widgets that are contained in the auth_box
71 #they will be there since the previous prepare() call68 #they will be there since the previous prepare() call
72 c = self.auth_box.get_child()69 c = self.auth_box.get_child()
73 if c is not None:70 if c is not None:
74 self.auth_box.remove(c)71 self.auth_box.remove(c)
75 72
76 if len(i) is not 0:73 if len(i) is not 0:
77 #there what to ask for74 #there what to ask for
78 self.main_box = Gtk.VBox()75 self.main_box = Gtk.VBox()
79 self.auth_box.add(self.main_box)76 self.auth_box.add(self.main_box)
80 77
81 #essential. It ensures we'll append items to section_dict, in an unchanging order.78 #essential. It ensures we'll append items to section_dict, in an unchanging order.
82 infoneeded = sorted(i, key=itemgetter('collection'))79 infoneeded = sorted(i, key=itemgetter('collection'))
83 80
84 section_dict = {}81 section_dict = {}
85 extrainfo_dict = {}82 extrainfo_dict = {}
86 #section dict looks like: { "launchpad-email" : ["ubuntu-community","ubuntu-community-italy"],83 #section dict looks like: { "launchpad-email" : ["ubuntu-community","ubuntu-community-italy"],
@@ -96,43 +93,42 @@
96 extrainfo_dict[i["needs-information"]] = i93 extrainfo_dict[i["needs-information"]] = i
97 for a in section_dict:94 for a in section_dict:
98 section_dict[a] = tuple(section_dict[a])95 section_dict[a] = tuple(section_dict[a])
99 96
100
101 rev_section_dict = {}97 rev_section_dict = {}
102 #the rev_section_dict shal be the grouped inverse of section_dict:98 #the rev_section_dict shal be the grouped inverse of section_dict:
103 # { ("ubuntu-community","ubuntu-community-italy",) : ["launchpad-email","magic-token"],99 # { ("ubuntu-community","ubuntu-community-italy",) : ["launchpad-email","magic-token"],
104 # ("askubuntu",) : ["askubuntu-login"],100 # ("askubuntu",) : ["askubuntu-login"],
105 # ("openshot", "otherapp",) : ["github-id"] }101 # ("openshot", "otherapp",) : ["github-id"] }
106 # 102 #
107 103
108 for i in section_dict:104 for i in section_dict:
109 d = section_dict[i]105 d = section_dict[i]
110 if d not in rev_section_dict:106 if d not in rev_section_dict:
111 rev_section_dict[d] = list([i])107 rev_section_dict[d] = list([i])
112 else:108 else:
113 rev_section_dict[d].append(i)109 rev_section_dict[d].append(i)
114 110
115 #print rev_section_dict 111 #print rev_section_dict
116 112
117 for i in sorted(rev_section_dict.keys(), reverse=True, key=len):113 for i in sorted(rev_section_dict.keys(), reverse=True, key=len):
118 #the gui code is here - done for every GROUP of entry fields114 #the gui code is here - done for every GROUP of entry fields
119 d = rev_section_dict[i]115 d = rev_section_dict[i]
120 116
121 g_box = Gtk.VBox()117 g_box = Gtk.VBox()
122 g_box.set_margin_bottom(20)118 g_box.set_margin_bottom(20)
123 g_box.set_margin_left(10)119 g_box.set_margin_left(10)
124 self.main_box.pack_start(g_box,True,False,0)120 self.main_box.pack_start(g_box, True, False, 0)
125 121
126 g_upbox = Gtk.HBox()122 g_upbox = Gtk.HBox()
127 g_box.pack_start(g_upbox,True,False,0)123 g_box.pack_start(g_upbox, True, False, 0)
128 124
129 g_upimage = Gtk.Image()125 g_upimage = Gtk.Image()
130 g_upimage.set_margin_left(5)126 g_upimage.set_margin_left(5)
131 g_upimage.set_margin_top(5)127 g_upimage.set_margin_top(5)
132 g_upimage.set_margin_bottom(5)128 g_upimage.set_margin_bottom(5)
133 g_upimage.set_margin_right(5)129 g_upimage.set_margin_right(5)
134 g_upimage.set_from_stock(Gtk.STOCK_GO_FORWARD,Gtk.IconSize.LARGE_TOOLBAR)130 g_upimage.set_from_stock(Gtk.STOCK_GO_FORWARD, Gtk.IconSize.LARGE_TOOLBAR)
135 131
136 #temporarily we'll use an ugly name132 #temporarily we'll use an ugly name
137 n = len(i)133 n = len(i)
138 if n is 1:134 if n is 1:
@@ -141,32 +137,32 @@
141 name = self.libaccom.get_collection_name(i[0]) + " and " + self.libaccom.get_collection_name(i[1])137 name = self.libaccom.get_collection_name(i[0]) + " and " + self.libaccom.get_collection_name(i[1])
142 else:138 else:
143 name = ""139 name = ""
144 for k in range(0,n):140 for k in range(0, n):
145 if n-k > 2:141 if n - k > 2:
146 name = name + self.libaccom.get_collection_name(i[k]) + ", "142 name = name + self.libaccom.get_collection_name(i[k]) + ", "
147 elif n-k is 2:143 elif n - k is 2:
148 name = name + self.libaccom.get_collection_name(i[k]) + " and "144 name = name + self.libaccom.get_collection_name(i[k]) + " and "
149 elif n-k is 1:145 elif n - k is 1:
150 name = name + self.libaccom.get_collection_name(i[k])146 name = name + self.libaccom.get_collection_name(i[k])
151 147
152 g_uplabel = Gtk.Label("<big><b>" + name + "</b></big>")148 g_uplabel = Gtk.Label("<big><b>" + name + "</b></big>")
153 g_uplabel.set_use_markup(True)149 g_uplabel.set_use_markup(True)
154 g_uplabel.set_margin_left(10)150 g_uplabel.set_margin_left(10)
155 #g_uplabel.set_halign(Gtk.Align.START)151 #g_uplabel.set_halign(Gtk.Align.START)
156 152
157 g_sep = Gtk.HSeparator()153 g_sep = Gtk.HSeparator()
158 g_box.pack_start(g_sep,True,False,0)154 g_box.pack_start(g_sep, True, False, 0)
159 155
160 for f in d:156 for f in d:
161 #for each information field in the group...157 #for each information field in the group...
162 extrainfo = extrainfo_dict[f]158 extrainfo = extrainfo_dict[f]
163 label = extrainfo['label']159 label = extrainfo['label']
164 label = label.replace("&","&amp;") #pango would complain on that160 label = label.replace("&", "&amp;") # pango would complain on that
165 description = extrainfo['description']161 description = extrainfo['description']
166 description = description.replace("&","&amp;") #pango would complain on that162 description = description.replace("&", "&amp;") # pango would complain on that
167 value = extrainfo['value']163 value = extrainfo['value']
168 example = extrainfo.get('example')164 example = extrainfo.get('example')
169 165
170 g_entrybox = Gtk.HBox()166 g_entrybox = Gtk.HBox()
171 g_mainlabel = Gtk.Label(label)167 g_mainlabel = Gtk.Label(label)
172 g_mainlabel.set_justify(Gtk.Justification.RIGHT)168 g_mainlabel.set_justify(Gtk.Justification.RIGHT)
@@ -177,31 +173,31 @@
177 g_entry.set_text(value)173 g_entry.set_text(value)
178 g_desclabel = Gtk.Label("<small><small><b>" + description + "</b></small></small>")174 g_desclabel = Gtk.Label("<small><small><b>" + description + "</b></small></small>")
179 g_desclabel.set_use_markup(True)175 g_desclabel.set_use_markup(True)
180 g_desclabel.set_alignment(1,0)176 g_desclabel.set_alignment(1, 0)
181177
182 if example:178 if example:
183 g_example = Gtk.Label("<small><small><b>Example: " + example + "</b></small></small>")179 g_example = Gtk.Label("<small><small><b>Example: " + example + "</b></small></small>")
184 g_example.set_use_markup(True)180 g_example.set_use_markup(True)
185 g_example.set_alignment(1,0)181 g_example.set_alignment(1, 0)
186 g_example.set_margin_right(20)182 g_example.set_margin_right(20)
187 183
188 g_entrybox.set_margin_right(20)184 g_entrybox.set_margin_right(20)
189 g_desclabel.set_margin_right(20)185 g_desclabel.set_margin_right(20)
190 186
191 g_box.pack_start(g_entrybox,True,False,0)187 g_box.pack_start(g_entrybox, True, False, 0)
192 g_box.pack_start(g_desclabel,True,False,0)188 g_box.pack_start(g_desclabel, True, False, 0)
193 if example:189 if example:
194 g_box.pack_start(g_example,True,False,0)190 g_box.pack_start(g_example, True, False, 0)
195 g_entrybox.pack_end(g_entry,False,False,0)191 g_entrybox.pack_end(g_entry, False, False, 0)
196 g_entrybox.pack_end(g_mainlabel,False,False,0)192 g_entrybox.pack_end(g_mainlabel, False, False, 0)
197 193
198 self.entries_map[f] = [g_entry,value]194 self.entries_map[f] = [g_entry, value]
199 195
200 g_upbox.pack_start(g_upimage,False,False,0)196 g_upbox.pack_start(g_upimage, False, False, 0)
201 g_upbox.pack_start(g_uplabel,False,True,0)197 g_upbox.pack_start(g_uplabel, False, True, 0)
202 198
203 self.auth_box.show_all()199 self.auth_box.show_all()
204 200
205 else:201 else:
206 #no point in asking at all202 #no point in asking at all
207 label = Gtk.Label("<i>(no extra-information is required, most likely there is something wrong with your installtion)</i>")203 label = Gtk.Label("<i>(no extra-information is required, most likely there is something wrong with your installtion)</i>")
@@ -214,26 +210,25 @@
214 """Proxy function that simply calls the OK button when the user210 """Proxy function that simply calls the OK button when the user
215 has pressed Enter on a textbox."""211 has pressed Enter on a textbox."""
216 self.btn_ok.clicked()212 self.btn_ok.clicked()
217
218213
219 def on_btn_ok_clicked(self, widget, data=None):214 def on_btn_ok_clicked(self, widget, data=None):
220 """The user has elected to save the changes.215 """The user has elected to save the changes.
221 Called before the dialog returns Gtk.ResponseType.OK from run().216 Called before the dialog returns Gtk.ResponseType.OK from run().
222 """ 217 """
223 218
224 #saving the data should happen here.219 #saving the data should happen here.
225 anything_changed = False220 anything_changed = False
226 for f in self.entries_map:221 for f in self.entries_map:
227 entry = self.entries_map[f][0]222 entry = self.entries_map[f][0]
228 origvalue = self.entries_map[f][1]223 origvalue = self.entries_map[f][1]
229 newvalue = entry.get_text()224 newvalue = entry.get_text()
230 if newvalue == origvalue:225 if newvalue == origvalue:
231 pass226 pass
232 else:227 else:
233 #print "value " + f + " changed"228 #print "value " + f + " changed"
234 anything_changed = True229 anything_changed = True
235 self.libaccom.write_extra_information_file(f,newvalue)230 self.libaccom.write_extra_information_file(f, newvalue)
236 231
237 if anything_changed:232 if anything_changed:
238 self.libaccom.run_scripts(True)233 self.libaccom.run_scripts(True)
239234
240235
=== modified file 'accomplishments_viewer/PreferencesAccomplishmentsViewerDialog.py'
--- accomplishments_viewer/PreferencesAccomplishmentsViewerDialog.py 2012-09-07 18:19:02 +0000
+++ accomplishments_viewer/PreferencesAccomplishmentsViewerDialog.py 2012-11-26 16:03:25 +0000
@@ -1,16 +1,16 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2### BEGIN LICENSE2### BEGIN LICENSE
3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>
4# This program is free software: you can redistribute it and/or modify it 4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published 5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.6# by the Free Software Foundation.
7# 7#
8# This program is distributed in the hope that it will be useful, but 8# This program is distributed in the hope that it will be useful, but
9# WITHOUT ANY WARRANTY; without even the implied warranties of 9# WITHOUT ANY WARRANTY; without even the implied warranties of
10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11# PURPOSE. See the GNU General Public License for more details.11# PURPOSE. See the GNU General Public License for more details.
12# 12#
13# You should have received a copy of the GNU General Public License along 13# You should have received a copy of the GNU General Public License along
14# with this program. If not, see <http://www.gnu.org/licenses/>.14# with this program. If not, see <http://www.gnu.org/licenses/>.
15### END LICENSE15### END LICENSE
1616
@@ -20,27 +20,24 @@
20# data/glib-2.0/schemas/net.launchpad.accomplishments-viewer.gschema.xml20# data/glib-2.0/schemas/net.launchpad.accomplishments-viewer.gschema.xml
21# See http://developer.gnome.org/gio/stable/GSettings.html for more info.21# See http://developer.gnome.org/gio/stable/GSettings.html for more info.
2222
23from gi.repository import Gio # pylint: disable=E061123import gettext
2424import locale
25import gettext, locale
26from locale import gettext as _25from locale import gettext as _
27from accomplishments.util.paths import locale_dir26from accomplishments.util.paths import locale_dir
28locale.bindtextdomain('accomplishments-viewer', locale_dir)27locale.bindtextdomain('accomplishments-viewer', locale_dir)
29gettext.bindtextdomain('accomplishments-viewer',locale_dir)28gettext.bindtextdomain('accomplishments-viewer', locale_dir)
30locale.textdomain('accomplishments-viewer')29locale.textdomain('accomplishments-viewer')
3130
32from accomplishments.daemon import dbusapi
33import os, xdg.BaseDirectory, ConfigParser
34
35import logging31import logging
36logger = logging.getLogger('accomplishments_viewer')32logger = logging.getLogger('accomplishments_viewer')
3733
38from accomplishments_viewer_lib.PreferencesDialog import PreferencesDialog34from accomplishments_viewer_lib.PreferencesDialog import PreferencesDialog
3935
36
40class PreferencesAccomplishmentsViewerDialog(PreferencesDialog):37class PreferencesAccomplishmentsViewerDialog(PreferencesDialog):
41 __gtype_name__ = "PreferencesAccomplishmentsViewerDialog"38 __gtype_name__ = "PreferencesAccomplishmentsViewerDialog"
4239
43 def finish_initializing(self, builder): # pylint: disable=E100240 def finish_initializing(self, builder): # pylint: disable=E1002
44 """Set up the preferences dialog"""41 """Set up the preferences dialog"""
45 super(PreferencesAccomplishmentsViewerDialog, self).finish_initializing(builder)42 super(PreferencesAccomplishmentsViewerDialog, self).finish_initializing(builder)
46 self.cb_daemonsessionstart = self.builder.get_object("cb_daemonsessionstart")43 self.cb_daemonsessionstart = self.builder.get_object("cb_daemonsessionstart")
@@ -49,9 +46,9 @@
49 self.pref_publish_label = self.builder.get_object("pref_publish_label")46 self.pref_publish_label = self.builder.get_object("pref_publish_label")
50 self.pref_publish_icon = self.builder.get_object("pref_publish_icon")47 self.pref_publish_icon = self.builder.get_object("pref_publish_icon")
51 self.publishedstatus = None48 self.publishedstatus = None
52 49
53 #trophydir = self.libaccom.get_config_value("config", "trophypath")50 #trophydir = self.libaccom.get_config_value("config", "trophypath")
54 51
55 # Bind each preference widget to gsettings52 # Bind each preference widget to gsettings
56 #settings = Gio.Settings("net.launchpad.accomplishments-viewer")53 #settings = Gio.Settings("net.launchpad.accomplishments-viewer")
57 #widget = self.builder.get_object('example_entry')54 #widget = self.builder.get_object('example_entry')
@@ -59,21 +56,21 @@
5956
60 # Code for other initialization actions should be added here.57 # Code for other initialization actions should be added here.
6158
62 def prepare(self,daemon_handle):59 def prepare(self, daemon_handle):
63 self.libaccom = daemon_handle60 self.libaccom = daemon_handle
64 self.populate_settings()61 self.populate_settings()
65 62
66 self.publishedstatus = self.libaccom.get_published_status()63 self.publishedstatus = self.libaccom.get_published_status()
67 64
68 if self.publishedstatus == 0:65 if self.publishedstatus == 0:
69 self.pref_publish.set_label(_("Publish..."))66 self.pref_publish.set_label(_("Publish..."))
70 else:67 else:
71 self.pref_publish.set_label(_("Stop Publishing"))68 self.pref_publish.set_label(_("Stop Publishing"))
72 69
73 def populate_settings(self):70 def populate_settings(self):
74 self.cb_daemonsessionstart.handler_block_by_func(self.cb_daemonsessionstart_toggled)71 self.cb_daemonsessionstart.handler_block_by_func(self.cb_daemonsessionstart_toggled)
75 self.cb_hideu1bubbles.handler_block_by_func(self.cb_hideu1bubbles_toggled)72 self.cb_hideu1bubbles.handler_block_by_func(self.cb_hideu1bubbles_toggled)
76 73
77 self.cb_daemonsessionstart.set_active(bool(self.libaccom.get_daemon_session_start()))74 self.cb_daemonsessionstart.set_active(bool(self.libaccom.get_daemon_session_start()))
78 print self.libaccom.get_daemon_session_start()75 print self.libaccom.get_daemon_session_start()
79 print type(self.libaccom.get_daemon_session_start())76 print type(self.libaccom.get_daemon_session_start())
@@ -81,13 +78,13 @@
8178
82 self.cb_daemonsessionstart.handler_unblock_by_func(self.cb_daemonsessionstart_toggled)79 self.cb_daemonsessionstart.handler_unblock_by_func(self.cb_daemonsessionstart_toggled)
83 self.cb_hideu1bubbles.handler_unblock_by_func(self.cb_hideu1bubbles_toggled)80 self.cb_hideu1bubbles.handler_unblock_by_func(self.cb_hideu1bubbles_toggled)
84 81
85 def cb_daemonsessionstart_toggled(self, widget):82 def cb_daemonsessionstart_toggled(self, widget):
86 print widget.get_active()83 print widget.get_active()
87 self.libaccom.set_daemon_session_start( widget.get_active() )84 self.libaccom.set_daemon_session_start(widget.get_active())
8885
89 def cb_hideu1bubbles_toggled(self, widget):86 def cb_hideu1bubbles_toggled(self, widget):
90 self.libaccom.set_block_ubuntuone_notification_bubbles( widget.get_active() )87 self.libaccom.set_block_ubuntuone_notification_bubbles(widget.get_active())
9188
92 def on_pref_publish_clicked(self, widget):89 def on_pref_publish_clicked(self, widget):
93 if self.publishedstatus == 0:90 if self.publishedstatus == 0:
9491
=== modified file 'accomplishments_viewer/__init__.py'
--- accomplishments_viewer/__init__.py 2012-11-22 10:04:35 +0000
+++ accomplishments_viewer/__init__.py 2012-11-26 16:03:25 +0000
@@ -1,34 +1,36 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2### BEGIN LICENSE2### BEGIN LICENSE
3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>
4# This program is free software: you can redistribute it and/or modify it 4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published 5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.6# by the Free Software Foundation.
7# 7#
8# This program is distributed in the hope that it will be useful, but 8# This program is distributed in the hope that it will be useful, but
9# WITHOUT ANY WARRANTY; without even the implied warranties of 9# WITHOUT ANY WARRANTY; without even the implied warranties of
10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11# PURPOSE. See the GNU General Public License for more details.11# PURPOSE. See the GNU General Public License for more details.
12# 12#
13# You should have received a copy of the GNU General Public License along 13# You should have received a copy of the GNU General Public License along
14# with this program. If not, see <http://www.gnu.org/licenses/>.14# with this program. If not, see <http://www.gnu.org/licenses/>.
15### END LICENSE15### END LICENSE
1616
17import optparse17import optparse
1818
19import gettext, locale19import gettext
20import locale
20from locale import gettext as _21from locale import gettext as _
21from accomplishments.util.paths import locale_dir22from accomplishments.util.paths import locale_dir
22locale.bindtextdomain('accomplishments-viewer', locale_dir)23locale.bindtextdomain('accomplishments-viewer', locale_dir)
23gettext.bindtextdomain('accomplishments-viewer',locale_dir)24gettext.bindtextdomain('accomplishments-viewer', locale_dir)
24locale.textdomain('accomplishments-viewer')25locale.textdomain('accomplishments-viewer')
2526
26from gi.repository import Gtk, GObject # pylint: disable=E061127from gi.repository import Gtk, GObject # pylint: disable=E0611
2728
28from accomplishments_viewer import AccomplishmentsViewerWindow29from accomplishments_viewer import AccomplishmentsViewerWindow
2930
30from accomplishments_viewer_lib import set_up_logging, get_version31from accomplishments_viewer_lib import set_up_logging, get_version
3132
33
32def parse_options():34def parse_options():
33 """Support for command line options"""35 """Support for command line options"""
34 parser = optparse.OptionParser(version="%%prog %s" % get_version())36 parser = optparse.OptionParser(version="%%prog %s" % get_version())
@@ -39,20 +41,21 @@
39 "-a", "--accomplishment", action="store", dest="id",41 "-a", "--accomplishment", action="store", dest="id",
40 help=_("Display information about the provided accomplishment ID (e.g. 'ubuntu-community/registered-on-launchpad')").decode('utf-8'))42 help=_("Display information about the provided accomplishment ID (e.g. 'ubuntu-community/registered-on-launchpad')").decode('utf-8'))
41 (options, args) = parser.parse_args()43 (options, args) = parser.parse_args()
42 44
43 set_up_logging(options)45 set_up_logging(options)
44 return options46 return options
4547
48
46def main():49def main():
47 'constructor for your class instances'50 'constructor for your class instances'
48 GObject.threads_init()51 GObject.threads_init()
49 options = parse_options()52 options = parse_options()
5053
51 # Run the application. 54 # Run the application.
52 window = AccomplishmentsViewerWindow.AccomplishmentsViewerWindow()55 window = AccomplishmentsViewerWindow.AccomplishmentsViewerWindow()
53 56
54 if options.id:57 if options.id:
55 window.optparse_accomplishment(options.id)58 window.optparse_accomplishment(options.id)
56 59
57 window.show()60 window.show()
58 Gtk.main()61 Gtk.main()
5962
=== modified file 'accomplishments_viewer_lib/AboutDialog.py'
--- accomplishments_viewer_lib/AboutDialog.py 2012-09-07 18:19:02 +0000
+++ accomplishments_viewer_lib/AboutDialog.py 2012-11-26 16:03:25 +0000
@@ -1,32 +1,33 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2### BEGIN LICENSE2### BEGIN LICENSE
3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>
4# This program is free software: you can redistribute it and/or modify it 4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published 5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.6# by the Free Software Foundation.
7# 7#
8# This program is distributed in the hope that it will be useful, but 8# This program is distributed in the hope that it will be useful, but
9# WITHOUT ANY WARRANTY; without even the implied warranties of 9# WITHOUT ANY WARRANTY; without even the implied warranties of
10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11# PURPOSE. See the GNU General Public License for more details.11# PURPOSE. See the GNU General Public License for more details.
12# 12#
13# You should have received a copy of the GNU General Public License along 13# You should have received a copy of the GNU General Public License along
14# with this program. If not, see <http://www.gnu.org/licenses/>.14# with this program. If not, see <http://www.gnu.org/licenses/>.
15### END LICENSE15### END LICENSE
1616
17### DO NOT EDIT THIS FILE ###17### DO NOT EDIT THIS FILE ###
1818
19from gi.repository import Gtk # pylint: disable=E061119from gi.repository import Gtk # pylint: disable=E0611
2020
21from . helpers import get_builder21from . helpers import get_builder
2222
23
23class AboutDialog(Gtk.AboutDialog):24class AboutDialog(Gtk.AboutDialog):
24 __gtype_name__ = "AboutDialog"25 __gtype_name__ = "AboutDialog"
2526
26 def __new__(cls):27 def __new__(cls):
27 """Special static method that's automatically called by Python when 28 """Special static method that's automatically called by Python when
28 constructing a new instance of this class.29 constructing a new instance of this class.
29 30
30 Returns a fully instantiated AboutDialog object.31 Returns a fully instantiated AboutDialog object.
31 """32 """
32 builder = get_builder('AboutAccomplishmentsViewerDialog')33 builder = get_builder('AboutAccomplishmentsViewerDialog')
@@ -41,10 +42,9 @@
41 and creating a AboutDialog object with it in order42 and creating a AboutDialog object with it in order
42 to finish initializing the start of the new AboutAccomplishmentsViewerDialog43 to finish initializing the start of the new AboutAccomplishmentsViewerDialog
43 instance.44 instance.
44 45
45 Put your initialization code in here and leave __init__ undefined.46 Put your initialization code in here and leave __init__ undefined.
46 """47 """
47 # Get a reference to the builder and set up the signals.48 # Get a reference to the builder and set up the signals.
48 self.builder = builder49 self.builder = builder
49 self.ui = builder.get_ui(self)50 self.ui = builder.get_ui(self)
50
5151
=== modified file 'accomplishments_viewer_lib/Builder.py'
--- accomplishments_viewer_lib/Builder.py 2012-09-07 18:19:02 +0000
+++ accomplishments_viewer_lib/Builder.py 2012-11-26 16:03:25 +0000
@@ -1,16 +1,16 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2### BEGIN LICENSE2### BEGIN LICENSE
3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>
4# This program is free software: you can redistribute it and/or modify it 4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published 5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.6# by the Free Software Foundation.
7# 7#
8# This program is distributed in the hope that it will be useful, but 8# This program is distributed in the hope that it will be useful, but
9# WITHOUT ANY WARRANTY; without even the implied warranties of 9# WITHOUT ANY WARRANTY; without even the implied warranties of
10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11# PURPOSE. See the GNU General Public License for more details.11# PURPOSE. See the GNU General Public License for more details.
12# 12#
13# You should have received a copy of the GNU General Public License along 13# You should have received a copy of the GNU General Public License along
14# with this program. If not, see <http://www.gnu.org/licenses/>.14# with this program. If not, see <http://www.gnu.org/licenses/>.
15### END LICENSE15### END LICENSE
1616
@@ -18,7 +18,7 @@
1818
19'''Enhances builder connections, provides object to access glade objects'''19'''Enhances builder connections, provides object to access glade objects'''
2020
21from gi.repository import GObject, Gtk # pylint: disable=E061121from gi.repository import GObject, Gtk # pylint: disable=E0611
2222
23import inspect23import inspect
24import functools24import functools
@@ -54,8 +54,7 @@
5454
55# pylint: disable=R020155# pylint: disable=R0201
56# this is a method so that a subclass of Builder can redefine it56# this is a method so that a subclass of Builder can redefine it
57 def default_handler(self,57 def default_handler(self, handler_name, filename, *args, **kwargs):
58 handler_name, filename, *args, **kwargs):
59 '''helps the apprentice guru58 '''helps the apprentice guru
6059
61 glade defined handlers that do not exist come here instead.60 glade defined handlers that do not exist come here instead.
@@ -108,7 +107,8 @@
108 ele_signals = tree.getiterator("signal")107 ele_signals = tree.getiterator("signal")
109 for ele_signal in ele_signals:108 for ele_signal in ele_signals:
110 self.glade_handler_dict.update(109 self.glade_handler_dict.update(
111 {ele_signal.attrib["handler"]: None})110 {ele_signal.attrib["handler"]: None}
111 )
112112
113 def connect_signals(self, callback_obj):113 def connect_signals(self, callback_obj):
114 '''connect the handlers defined in glade114 '''connect the handlers defined in glade
@@ -129,8 +129,7 @@
129 connection_dict[item[0]] = handler129 connection_dict[item[0]] = handler
130130
131 # replace the run time warning131 # replace the run time warning
132 logger.warn("expected handler '%s' in %s",132 logger.warn("expected handler '%s' in %s", item[0], filename)
133 item[0], filename)
134133
135 # connect glade define handlers134 # connect glade define handlers
136 Gtk.Builder.connect_signals(self, connection_dict)135 Gtk.Builder.connect_signals(self, connection_dict)
@@ -139,7 +138,7 @@
139 for connection in self.connections:138 for connection in self.connections:
140 widget_name, signal_name, handler_name = connection139 widget_name, signal_name, handler_name = connection
141 logger.debug("connect builder by design '%s', '%s', '%s'",140 logger.debug("connect builder by design '%s', '%s', '%s'",
142 widget_name, signal_name, handler_name)141 widget_name, signal_name, handler_name)
143142
144 def get_ui(self, callback_obj=None, by_name=True):143 def get_ui(self, callback_obj=None, by_name=True):
145 '''Creates the ui object with widgets as attributes144 '''Creates the ui object with widgets as attributes
@@ -175,7 +174,7 @@
175 cannot_message = """cannot bind ui.%s, name already exists174 cannot_message = """cannot bind ui.%s, name already exists
176 consider using a pythonic name instead of design name '%s'"""175 consider using a pythonic name instead of design name '%s'"""
177 consider_message = """consider using a pythonic name instead of design name '%s'"""176 consider_message = """consider using a pythonic name instead of design name '%s'"""
178 177
179 for (widget_name, widget) in widget_dict.items():178 for (widget_name, widget) in widget_dict.items():
180 pyname = make_pyname(widget_name)179 pyname = make_pyname(widget_name)
181 if pyname != widget_name:180 if pyname != widget_name:
@@ -201,14 +200,14 @@
201 pyname = ''200 pyname = ''
202 for character in name:201 for character in name:
203 if (character.isalpha() or character == '_' or202 if (character.isalpha() or character == '_' or
204 (pyname and character.isdigit())):203 (pyname and character.isdigit())):
205 pyname += character204 pyname += character
206 else:205 else:
207 pyname += '_'206 pyname += '_'
208 return pyname207 return pyname
209208
210209
211# Until bug https://bugzilla.gnome.org/show_bug.cgi?id=652127 is fixed, we 210# Until bug https://bugzilla.gnome.org/show_bug.cgi?id=652127 is fixed, we
212# need to reimplement inspect.getmembers. GObject introspection doesn't211# need to reimplement inspect.getmembers. GObject introspection doesn't
213# play nice with it.212# play nice with it.
214def getmembers(obj, check):213def getmembers(obj, check):
@@ -285,13 +284,13 @@
285 handler_names.append("on_%s" % sig)284 handler_names.append("on_%s" % sig)
286285
287 do_connect(item, sig, handler_names,286 do_connect(item, sig, handler_names,
288 callback_handler_dict, builder.connections)287 callback_handler_dict, builder.connections)
289288
290 log_unconnected_functions(callback_handler_dict, builder.connections)289 log_unconnected_functions(callback_handler_dict, builder.connections)
291290
292291
293def do_connect(item, signal_name, handler_names,292def do_connect(item, signal_name, handler_names,
294 callback_handler_dict, connections):293 callback_handler_dict, connections):
295 '''connect this signal to an unused handler'''294 '''connect this signal to an unused handler'''
296 widget_name, widget = item295 widget_name, widget = item
297296
@@ -304,7 +303,7 @@
304 connections.append(connection)303 connections.append(connection)
305304
306 logger.debug("connect builder by name '%s','%s', '%s'",305 logger.debug("connect builder by name '%s','%s', '%s'",
307 widget_name, signal_name, handler_name)306 widget_name, signal_name, handler_name)
308307
309308
310def log_unconnected_functions(callback_handler_dict, connections):309def log_unconnected_functions(callback_handler_dict, connections):
311310
=== modified file 'accomplishments_viewer_lib/PreferencesDialog.py'
--- accomplishments_viewer_lib/PreferencesDialog.py 2012-09-07 18:19:02 +0000
+++ accomplishments_viewer_lib/PreferencesDialog.py 2012-11-26 16:03:25 +0000
@@ -1,16 +1,16 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2### BEGIN LICENSE2### BEGIN LICENSE
3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>
4# This program is free software: you can redistribute it and/or modify it 4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published 5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.6# by the Free Software Foundation.
7# 7#
8# This program is distributed in the hope that it will be useful, but 8# This program is distributed in the hope that it will be useful, but
9# WITHOUT ANY WARRANTY; without even the implied warranties of 9# WITHOUT ANY WARRANTY; without even the implied warranties of
10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11# PURPOSE. See the GNU General Public License for more details.11# PURPOSE. See the GNU General Public License for more details.
12# 12#
13# You should have received a copy of the GNU General Public License along 13# You should have received a copy of the GNU General Public License along
14# with this program. If not, see <http://www.gnu.org/licenses/>.14# with this program. If not, see <http://www.gnu.org/licenses/>.
15### END LICENSE15### END LICENSE
1616
@@ -19,19 +19,20 @@
19"""this dialog adjusts values in gsettings19"""this dialog adjusts values in gsettings
20"""20"""
2121
22from gi.repository import Gtk # pylint: disable=E061122from gi.repository import Gtk # pylint: disable=E0611
23import logging23import logging
24logger = logging.getLogger('accomplishments_viewer_lib')24logger = logging.getLogger('accomplishments_viewer_lib')
2525
26from . helpers import get_builder, show_uri, get_help_uri26from . helpers import get_builder, show_uri, get_help_uri
2727
28
28class PreferencesDialog(Gtk.Dialog):29class PreferencesDialog(Gtk.Dialog):
29 __gtype_name__ = "PreferencesDialog"30 __gtype_name__ = "PreferencesDialog"
3031
31 def __new__(cls):32 def __new__(cls):
32 """Special static method that's automatically called by Python when 33 """Special static method that's automatically called by Python when
33 constructing a new instance of this class.34 constructing a new instance of this class.
34 35
35 Returns a fully instantiated PreferencesDialog object.36 Returns a fully instantiated PreferencesDialog object.
36 """37 """
37 builder = get_builder('PreferencesAccomplishmentsViewerDialog')38 builder = get_builder('PreferencesAccomplishmentsViewerDialog')
@@ -46,7 +47,7 @@
46 and creating a PreferencesDialog object with it in order to47 and creating a PreferencesDialog object with it in order to
47 finish initializing the start of the new PerferencesAccomplishmentsViewerDialog48 finish initializing the start of the new PerferencesAccomplishmentsViewerDialog
48 instance.49 instance.
49 50
50 Put your initialization code in here and leave __init__ undefined.51 Put your initialization code in here and leave __init__ undefined.
51 """52 """
5253
@@ -61,4 +62,3 @@
6162
62 def on_btn_help_clicked(self, widget, data=None):63 def on_btn_help_clicked(self, widget, data=None):
63 show_uri(self, "ghelp:%s" % get_help_uri('preferences'))64 show_uri(self, "ghelp:%s" % get_help_uri('preferences'))
64
6565
=== modified file 'accomplishments_viewer_lib/Window.py'
--- accomplishments_viewer_lib/Window.py 2012-09-07 18:19:02 +0000
+++ accomplishments_viewer_lib/Window.py 2012-11-26 16:03:25 +0000
@@ -1,33 +1,34 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2### BEGIN LICENSE2### BEGIN LICENSE
3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>
4# This program is free software: you can redistribute it and/or modify it 4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published 5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.6# by the Free Software Foundation.
7# 7#
8# This program is distributed in the hope that it will be useful, but 8# This program is distributed in the hope that it will be useful, but
9# WITHOUT ANY WARRANTY; without even the implied warranties of 9# WITHOUT ANY WARRANTY; without even the implied warranties of
10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11# PURPOSE. See the GNU General Public License for more details.11# PURPOSE. See the GNU General Public License for more details.
12# 12#
13# You should have received a copy of the GNU General Public License along 13# You should have received a copy of the GNU General Public License along
14# with this program. If not, see <http://www.gnu.org/licenses/>.14# with this program. If not, see <http://www.gnu.org/licenses/>.
15### END LICENSE15### END LICENSE
1616
17### DO NOT EDIT THIS FILE ###17### DO NOT EDIT THIS FILE ###
1818
19from gi.repository import Gio, Gtk # pylint: disable=E061119from gi.repository import Gio, Gtk # pylint: disable=E0611
20import logging20import logging
21logger = logging.getLogger('accomplishments_viewer_lib')21logger = logging.getLogger('accomplishments_viewer_lib')
2222
23from . helpers import get_builder, show_uri, get_help_uri23from . helpers import get_builder, show_uri, get_help_uri
2424
25
25# This class is meant to be subclassed by AccomplishmentsViewerWindow. It provides26# This class is meant to be subclassed by AccomplishmentsViewerWindow. It provides
26# common functions and some boilerplate.27# common functions and some boilerplate.
27class Window(Gtk.Window):28class Window(Gtk.Window):
28 __gtype_name__ = "Window"29 __gtype_name__ = "Window"
2930
30 # To construct a new instance of this method, the following notable 31 # To construct a new instance of this method, the following notable
31 # methods are called in this order:32 # methods are called in this order:
32 # __new__(cls)33 # __new__(cls)
33 # __init__(self)34 # __init__(self)
@@ -36,11 +37,11 @@
36 #37 #
37 # For this reason, it's recommended you leave __init__ empty and put38 # For this reason, it's recommended you leave __init__ empty and put
38 # your initialization code in finish_initializing39 # your initialization code in finish_initializing
39 40
40 def __new__(cls):41 def __new__(cls):
41 """Special static method that's automatically called by Python when 42 """Special static method that's automatically called by Python when
42 constructing a new instance of this class.43 constructing a new instance of this class.
43 44
44 Returns a fully instantiated BaseAccomplishmentsViewerWindow object.45 Returns a fully instantiated BaseAccomplishmentsViewerWindow object.
45 """46 """
46 builder = get_builder('AccomplishmentsViewerWindow')47 builder = get_builder('AccomplishmentsViewerWindow')
@@ -58,9 +59,9 @@
58 # Get a reference to the builder and set up the signals.59 # Get a reference to the builder and set up the signals.
59 self.builder = builder60 self.builder = builder
60 self.ui = builder.get_ui(self, True)61 self.ui = builder.get_ui(self, True)
61 self.PreferencesDialog = None # class62 self.PreferencesDialog = None # class
62 self.preferences_dialog = None # instance63 self.preferences_dialog = None # instance
63 self.AboutDialog = None # class64 self.AboutDialog = None # class
6465
65 self.settings = Gio.Settings("net.launchpad.accomplishments-viewer")66 self.settings = Gio.Settings("net.launchpad.accomplishments-viewer")
66 self.settings.connect('changed', self.on_preferences_changed)67 self.settings.connect('changed', self.on_preferences_changed)
@@ -84,7 +85,7 @@
84 def on_mnu_about_activate(self, widget, data=None):85 def on_mnu_about_activate(self, widget, data=None):
85 """Display the about box for accomplishments-viewer."""86 """Display the about box for accomplishments-viewer."""
86 if self.AboutDialog is not None:87 if self.AboutDialog is not None:
87 about = self.AboutDialog() # pylint: disable=E110288 about = self.AboutDialog() # pylint: disable=E1102
88 response = about.run()89 response = about.run()
89 about.destroy()90 about.destroy()
9091
@@ -101,7 +102,7 @@
101 self.preferences_dialog.present()102 self.preferences_dialog.present()
102 elif self.PreferencesDialog is not None:103 elif self.PreferencesDialog is not None:
103 logger.debug('create new preferences_dialog')104 logger.debug('create new preferences_dialog')
104 self.preferences_dialog = self.PreferencesDialog() # pylint: disable=E1102105 self.preferences_dialog = self.PreferencesDialog() # pylint: disable=E1102
105 self.preferences_dialog.connect('destroy', self.on_preferences_dialog_destroyed)106 self.preferences_dialog.connect('destroy', self.on_preferences_dialog_destroyed)
106 self.preferences_dialog.show()107 self.preferences_dialog.show()
107 # destroy command moved into dialog to allow for a help button108 # destroy command moved into dialog to allow for a help button
@@ -120,7 +121,7 @@
120121
121 def on_preferences_dialog_destroyed(self, widget, data=None):122 def on_preferences_dialog_destroyed(self, widget, data=None):
122 '''only affects gui123 '''only affects gui
123 124
124 logically there is no difference between the user closing,125 logically there is no difference between the user closing,
125 minimising or ignoring the preferences dialog'''126 minimising or ignoring the preferences dialog'''
126 logger.debug('on_preferences_dialog_destroyed')127 logger.debug('on_preferences_dialog_destroyed')
127128
=== modified file 'accomplishments_viewer_lib/__init__.py'
--- accomplishments_viewer_lib/__init__.py 2012-09-07 18:19:02 +0000
+++ accomplishments_viewer_lib/__init__.py 2012-11-26 16:03:25 +0000
@@ -1,16 +1,16 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2### BEGIN LICENSE2### BEGIN LICENSE
3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>
4# This program is free software: you can redistribute it and/or modify it 4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published 5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.6# by the Free Software Foundation.
7# 7#
8# This program is distributed in the hope that it will be useful, but 8# This program is distributed in the hope that it will be useful, but
9# WITHOUT ANY WARRANTY; without even the implied warranties of 9# WITHOUT ANY WARRANTY; without even the implied warranties of
10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11# PURPOSE. See the GNU General Public License for more details.11# PURPOSE. See the GNU General Public License for more details.
12# 12#
13# You should have received a copy of the GNU General Public License along 13# You should have received a copy of the GNU General Public License along
14# with this program. If not, see <http://www.gnu.org/licenses/>.14# with this program. If not, see <http://www.gnu.org/licenses/>.
15### END LICENSE15### END LICENSE
1616
@@ -22,4 +22,3 @@
22from . helpers import set_up_logging22from . helpers import set_up_logging
23from . Window import Window23from . Window import Window
24from . accomplishments_viewerconfig import get_version24from . accomplishments_viewerconfig import get_version
25
2625
=== modified file 'accomplishments_viewer_lib/accomplishments_viewerconfig.py'
--- accomplishments_viewer_lib/accomplishments_viewerconfig.py 2012-09-07 18:19:02 +0000
+++ accomplishments_viewer_lib/accomplishments_viewerconfig.py 2012-11-26 16:03:25 +0000
@@ -1,16 +1,16 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2### BEGIN LICENSE2### BEGIN LICENSE
3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>
4# This program is free software: you can redistribute it and/or modify it 4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published 5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.6# by the Free Software Foundation.
7# 7#
8# This program is distributed in the hope that it will be useful, but 8# This program is distributed in the hope that it will be useful, but
9# WITHOUT ANY WARRANTY; without even the implied warranties of 9# WITHOUT ANY WARRANTY; without even the implied warranties of
10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11# PURPOSE. See the GNU General Public License for more details.11# PURPOSE. See the GNU General Public License for more details.
12# 12#
13# You should have received a copy of the GNU General Public License along 13# You should have received a copy of the GNU General Public License along
14# with this program. If not, see <http://www.gnu.org/licenses/>.14# with this program. If not, see <http://www.gnu.org/licenses/>.
15### END LICENSE15### END LICENSE
1616
@@ -20,7 +20,7 @@
20 'project_path_not_found',20 'project_path_not_found',
21 'get_data_file',21 'get_data_file',
22 'get_data_path',22 'get_data_path',
23 ]23]
2424
25# Where your project will look for your data (for instance, images and ui25# Where your project will look for your data (for instance, images and ui
26# files). By default, this is ../data, relative your trunk layout26# files). By default, this is ../data, relative your trunk layout
@@ -30,7 +30,6 @@
3030
31import os31import os
3232
33from locale import gettext as _
3433
35class project_path_not_found(Exception):34class project_path_not_found(Exception):
36 """Raised when we can't find the project directory."""35 """Raised when we can't find the project directory."""
3736
=== modified file 'accomplishments_viewer_lib/helpers.py'
--- accomplishments_viewer_lib/helpers.py 2012-09-07 18:19:02 +0000
+++ accomplishments_viewer_lib/helpers.py 2012-11-26 16:03:25 +0000
@@ -1,16 +1,16 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2### BEGIN LICENSE2### BEGIN LICENSE
3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>3# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>
4# This program is free software: you can redistribute it and/or modify it 4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published 5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.6# by the Free Software Foundation.
7# 7#
8# This program is distributed in the hope that it will be useful, but 8# This program is distributed in the hope that it will be useful, but
9# WITHOUT ANY WARRANTY; without even the implied warranties of 9# WITHOUT ANY WARRANTY; without even the implied warranties of
10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 10# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11# PURPOSE. See the GNU General Public License for more details.11# PURPOSE. See the GNU General Public License for more details.
12# 12#
13# You should have received a copy of the GNU General Public License along 13# You should have received a copy of the GNU General Public License along
14# with this program. If not, see <http://www.gnu.org/licenses/>.14# with this program. If not, see <http://www.gnu.org/licenses/>.
15### END LICENSE15### END LICENSE
1616
@@ -25,10 +25,11 @@
2525
26from locale import gettext as _26from locale import gettext as _
2727
28
28def get_builder(builder_file_name):29def get_builder(builder_file_name):
29 """Return a fully-instantiated Gtk.Builder instance from specified ui 30 """Return a fully-instantiated Gtk.Builder instance from specified ui
30 file31 file
31 32
32 :param builder_file_name: The name of the builder file, without extension.33 :param builder_file_name: The name of the builder file, without extension.
33 Assumed to be in the 'ui' directory under the data path.34 Assumed to be in the 'ui' directory under the data path.
34 """35 """
@@ -49,12 +50,14 @@
49 if not os.path.exists(media_filename):50 if not os.path.exists(media_filename):
50 media_filename = None51 media_filename = None
5152
52 return "file:///"+media_filename53 return "file:///" + media_filename
54
5355
54class NullHandler(logging.Handler):56class NullHandler(logging.Handler):
55 def emit(self, record):57 def emit(self, record):
56 pass58 pass
5759
60
58def set_up_logging(opts):61def set_up_logging(opts):
59 # add a handler to prevent basicConfig62 # add a handler to prevent basicConfig
60 root = logging.getLogger()63 root = logging.getLogger()
@@ -80,6 +83,7 @@
80 if opts.verbose > 1:83 if opts.verbose > 1:
81 lib_logger.setLevel(logging.DEBUG)84 lib_logger.setLevel(logging.DEBUG)
8285
86
83def get_help_uri(page=None):87def get_help_uri(page=None):
84 # help_uri from source tree - default language88 # help_uri from source tree - default language
85 here = os.path.dirname(__file__)89 here = os.path.dirname(__file__)
@@ -95,11 +99,13 @@
9599
96 return help_uri100 return help_uri
97101
102
98def show_uri(parent, link):103def show_uri(parent, link):
99 from gi.repository import Gtk # pylint: disable=E0611104 from gi.repository import Gtk # pylint: disable=E0611
100 screen = parent.get_screen()105 screen = parent.get_screen()
101 Gtk.show_uri(screen, link, Gtk.get_current_event_time())106 Gtk.show_uri(screen, link, Gtk.get_current_event_time())
102107
108
103def alias(alternative_function_name):109def alias(alternative_function_name):
104 '''see http://www.drdobbs.com/web-development/184406073#l9'''110 '''see http://www.drdobbs.com/web-development/184406073#l9'''
105 def decorator(function):111 def decorator(function):
106112
=== modified file 'bin/accomplishments-viewer'
--- bin/accomplishments-viewer 2012-09-07 18:19:02 +0000
+++ bin/accomplishments-viewer 2012-11-26 16:03:25 +0000
@@ -2,16 +2,16 @@
2# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-2# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
3### BEGIN LICENSE3### BEGIN LICENSE
4# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>4# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>
5# This program is free software: you can redistribute it and/or modify it 5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 3, as published 6# under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.7# by the Free Software Foundation.
8# 8#
9# This program is distributed in the hope that it will be useful, but 9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranties of 10# WITHOUT ANY WARRANTY; without even the implied warranties of
11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12# PURPOSE. See the GNU General Public License for more details.12# PURPOSE. See the GNU General Public License for more details.
13# 13#
14# You should have received a copy of the GNU General Public License along 14# You should have received a copy of the GNU General Public License along
15# with this program. If not, see <http://www.gnu.org/licenses/>.15# with this program. If not, see <http://www.gnu.org/licenses/>.
16### END LICENSE16### END LICENSE
1717
@@ -30,18 +30,18 @@
30python_path = []30python_path = []
31if os.path.abspath(__file__).startswith('/opt'):31if os.path.abspath(__file__).startswith('/opt'):
32 locale.bindtextdomain('accomplishments-viewer', '/opt/extras.ubuntu.com/accomplishments-viewer/share/locale')32 locale.bindtextdomain('accomplishments-viewer', '/opt/extras.ubuntu.com/accomplishments-viewer/share/locale')
33 syspath = sys.path[:] # copy to avoid infinite loop in pending objects33 syspath = sys.path[:] # copy to avoid infinite loop in pending objects
34 for path in syspath:34 for path in syspath:
35 opt_path = path.replace('/usr', '/opt/extras.ubuntu.com/accomplishments-viewer')35 opt_path = path.replace('/usr', '/opt/extras.ubuntu.com/accomplishments-viewer')
36 python_path.insert(0, opt_path)36 python_path.insert(0, opt_path)
37 sys.path.insert(0, opt_path)37 sys.path.insert(0, opt_path)
38 os.putenv("XDG_DATA_DIRS", "%s:%s" % ("/opt/extras.ubuntu.com/accomplishments-viewer/share/", os.getenv("XDG_DATA_DIRS", "/usr/local/share/:/usr/share/")))38 os.putenv("XDG_DATA_DIRS", "%s:%s" % ("/opt/extras.ubuntu.com/accomplishments-viewer/share/", os.getenv("XDG_DATA_DIRS", "/usr/local/share/:/usr/share/")))
39if (os.path.exists(os.path.join(PROJECT_ROOT_DIRECTORY, 'accomplishments_viewer'))39if (os.path.exists(os.path.join(PROJECT_ROOT_DIRECTORY, 'accomplishments_viewer'))
40 and PROJECT_ROOT_DIRECTORY not in sys.path):40 and PROJECT_ROOT_DIRECTORY not in sys.path):
41 python_path.insert(0, PROJECT_ROOT_DIRECTORY)41 python_path.insert(0, PROJECT_ROOT_DIRECTORY)
42 sys.path.insert(0, PROJECT_ROOT_DIRECTORY)42 sys.path.insert(0, PROJECT_ROOT_DIRECTORY)
43if python_path:43if python_path:
44 os.putenv('PYTHONPATH', "%s:%s" % (os.getenv('PYTHONPATH', ''), ':'.join(python_path))) # for subprocesses44 os.putenv('PYTHONPATH', "%s:%s" % (os.getenv('PYTHONPATH', ''), ':'.join(python_path))) # for subprocesses
4545
46import accomplishments_viewer46import accomplishments_viewer
47accomplishments_viewer.main()47accomplishments_viewer.main()
4848
=== modified file 'tests/test_example.py'
--- tests/test_example.py 2012-09-07 18:40:05 +0000
+++ tests/test_example.py 2012-11-26 16:03:25 +0000
@@ -2,16 +2,16 @@
2# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-2# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
3### BEGIN LICENSE3### BEGIN LICENSE
4# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>4# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>
5# This program is free software: you can redistribute it and/or modify it 5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 3, as published 6# under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.7# by the Free Software Foundation.
8# 8#
9# This program is distributed in the hope that it will be useful, but 9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranties of 10# WITHOUT ANY WARRANTY; without even the implied warranties of
11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12# PURPOSE. See the GNU General Public License for more details.12# PURPOSE. See the GNU General Public License for more details.
13# 13#
14# You should have received a copy of the GNU General Public License along 14# You should have received a copy of the GNU General Public License along
15# with this program. If not, see <http://www.gnu.org/licenses/>.15# with this program. If not, see <http://www.gnu.org/licenses/>.
16### END LICENSE16### END LICENSE
1717
@@ -22,10 +22,13 @@
2222
23from accomplishments_viewer import AboutAccomplishmentsViewerDialog23from accomplishments_viewer import AboutAccomplishmentsViewerDialog
2424
25
25class TestExample(unittest.TestCase):26class TestExample(unittest.TestCase):
26 def setUp(self):27 def setUp(self):
27 self.AboutAccomplishmentsViewerDialog_members = [28 self.AboutAccomplishmentsViewerDialog_members = [
28 'AboutAccomplishmentsViewerDialog', 'AboutDialog', 'dbusapi', 'gettext', 'locale', 'locale_dir', 'logger', 'logging']29 'AboutAccomplishmentsViewerDialog', 'AboutDialog', 'dbusapi',
30 'gettext', 'locale', 'locale_dir', 'logger', 'logging'
31 ]
2932
30 def test_AboutAccomplishmentsViewerDialog_members(self):33 def test_AboutAccomplishmentsViewerDialog_members(self):
31 all_members = dir(AboutAccomplishmentsViewerDialog)34 all_members = dir(AboutAccomplishmentsViewerDialog)
@@ -33,5 +36,5 @@
33 public_members.sort()36 public_members.sort()
34 self.assertEqual(self.AboutAccomplishmentsViewerDialog_members, public_members)37 self.assertEqual(self.AboutAccomplishmentsViewerDialog_members, public_members)
3538
36if __name__ == '__main__': 39if __name__ == '__main__':
37 unittest.main()40 unittest.main()
3841
=== modified file 'tests/test_lint.py'
--- tests/test_lint.py 2012-09-07 18:19:02 +0000
+++ tests/test_lint.py 2012-11-26 16:03:25 +0000
@@ -2,16 +2,16 @@
2# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-2# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
3### BEGIN LICENSE3### BEGIN LICENSE
4# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>4# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>
5# This program is free software: you can redistribute it and/or modify it 5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 3, as published 6# under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.7# by the Free Software Foundation.
8# 8#
9# This program is distributed in the hope that it will be useful, but 9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranties of 10# WITHOUT ANY WARRANTY; without even the implied warranties of
11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12# PURPOSE. See the GNU General Public License for more details.12# PURPOSE. See the GNU General Public License for more details.
13# 13#
14# You should have received a copy of the GNU General Public License along 14# You should have received a copy of the GNU General Public License along
15# with this program. If not, see <http://www.gnu.org/licenses/>.15# with this program. If not, see <http://www.gnu.org/licenses/>.
16### END LICENSE16### END LICENSE
1717
@@ -21,17 +21,17 @@
21class TestPylint(unittest.TestCase):21class TestPylint(unittest.TestCase):
22 def test_project_errors_only(self):22 def test_project_errors_only(self):
23 '''run pylint in error only mode23 '''run pylint in error only mode
24 24
25 your code may well work even with pylint errors25 your code may well work even with pylint errors
26 but have some unusual code'''26 but have some unusual code'''
27 return_code = subprocess.call(["pylint", '-E', 'accomplishments_viewer'])27 return_code = subprocess.call(["pylint", '-E', 'accomplishments_viewer'])
28 # not needed because nosetests displays pylint console output28 # not needed because nosetests displays pylint console output
29 #self.assertEqual(return_code, 0)29 #self.assertEqual(return_code, 0)
3030
31 # un-comment the following for loads of diagnostics 31 # un-comment the following for loads of diagnostics
32 #~ def test_project_full_report(self):32 #~ def test_project_full_report(self):
33 #~ '''Only for the brave33 #~ '''Only for the brave
34#~ 34#~
35 #~ you will have to make judgement calls about your code standards35 #~ you will have to make judgement calls about your code standards
36 #~ that differ from the norm'''36 #~ that differ from the norm'''
37 #~ return_code = subprocess.call(["pylint", 'accomplishments_viewer'])37 #~ return_code = subprocess.call(["pylint", 'accomplishments_viewer'])

Subscribers

People subscribed via source and target branches

to all changes: