From 22e98a09059abbb9dce5109e3042080fd40afd7a Mon Sep 17 00:00:00 2001 From: Rafael Ortiz Date: Wed, 03 Aug 2011 18:42:14 +0000 Subject: pep8 fixes --- diff --git a/activity.py b/activity.py index d9c56dd..a4bfab6 100644 --- a/activity.py +++ b/activity.py @@ -1,17 +1,20 @@ from sugar.activity import activity + class ViewSourceActivity(activity.Activity): """Activity subclass which handles the 'view source' key.""" def __init__(self, handle): super(ViewSourceActivity, self).__init__(handle) - self.__source_object_id = None # XXX: persist this across invocations? + self.__source_object_id = None # XXX: persist this across invocations? self.connect('key-press-event', self._key_press_cb) + def _key_press_cb(self, widget, event): import gtk if gtk.gdk.keyval_name(event.keyval) == 'XF86Start': self.view_source() return True return False + def view_source(self): """Implement the 'view source' key by saving pippy_app.py to the datastore, and then telling the Journal to view it.""" @@ -29,13 +32,14 @@ class ViewSourceActivity(activity.Activity): 'icon-color': profile.get_color().to_string(), 'mime_type': 'text/x-python', } - for k,v in metadata.items(): + for k, v in metadata.items(): jobject.metadata[k] = v # dict.update method is missing =( jobject.file_path = os.path.join(get_bundle_path(), 'pippy_app.py') datastore.write(jobject) self.__source_object_id = jobject.object_id jobject.destroy() self.journal_show_object(self.__source_object_id) + def journal_show_object(self, object_id): """Invoke journal_show_object from sugar.activity.activity if it exists.""" @@ -43,11 +47,15 @@ class ViewSourceActivity(activity.Activity): from sugar.activity.activity import show_object_in_journal show_object_in_journal(object_id) except ImportError: - pass # no love from sugar. + pass # no love from sugar. + class VteActivity(ViewSourceActivity): def __init__(self, handle): - import gtk, pango, vte + import gtk + import pango + import vte + super(VteActivity, self).__init__(handle) toolbox = activity.ActivityToolbox(self) self.set_toolbox(toolbox) @@ -55,12 +63,12 @@ class VteActivity(ViewSourceActivity): # creates vte widget self._vte = vte.Terminal() - self._vte.set_size(30,5) + self._vte.set_size(30, 5) self._vte.set_size_request(200, 300) font = 'Monospace 10' self._vte.set_font(pango.FontDescription(font)) - self._vte.set_colors(gtk.gdk.color_parse ('#000000'), - gtk.gdk.color_parse ('#E7E7E7'), + self._vte.set_colors(gtk.gdk.color_parse('#000000'), + gtk.gdk.color_parse('#E7E7E7'), []) # ...and its scrollbar vtebox = gtk.HBox() @@ -78,7 +86,7 @@ class VteActivity(ViewSourceActivity): # the vte widget manages to snarf the last bits of its output self._pid = self._vte.fork_command \ (command='/bin/sh', - argv=['/bin/sh','-c', + argv=['/bin/sh', '-c', 'python %s/pippy_app.py; sleep 1' % bundle_path], envv=["PYTHONPATH=%s/library" % bundle_path], directory=bundle_path) -- cgit v0.9.1