Izidor Matušov has proposed merging lp:~izidor/gtg/1287259 into lp:gtg.

Requested reviews:
  Gtg developers (gtg)
Related bugs:
  Bug #1287259 in Getting Things GNOME!: "pep8ify the codebase"
  https://bugs.launchpad.net/gtg/+bug/1287259

For more details, see:
https://code.launchpad.net/~izidor/gtg/1287259/+merge/210084

Ideal task for lazy Sunday afternoon :)
-- 
https://code.launchpad.net/~izidor/gtg/1287259/+merge/210084
Your team Gtg developers is requested to review the proposed merge of 
lp:~izidor/gtg/1287259 into lp:gtg.
=== modified file 'GTG/backends/__init__.py'
--- GTG/backends/__init__.py	2013-11-25 02:37:46 +0000
+++ GTG/backends/__init__.py	2014-03-09 13:02:55 +0000
@@ -55,10 +55,7 @@
             # This object has already been constructed
             return
         self.backend_modules = {}
-        # Look for backends in the GTG/backends dir
-        this_dir = os.path.dirname(__file__)
-        backend_files = [f for f in os.listdir(this_dir) if f.endswith(".py") and
-                               f.startswith(self.BACKEND_PREFIX)]
+        backend_files = self._find_backend_files()
         # Create module names
         module_names = [f.replace(".py", "") for f in backend_files]
         Log.debug("Backends found: " + str(module_names))
@@ -81,6 +78,15 @@
             self.backend_modules[module_name] = \
                 sys.modules[extended_module_name]
 
+    def _find_backend_files(self):
+        # Look for backends in the GTG/backends dir
+        this_dir = os.path.dirname(__file__)
+        for filename in os.listdir(this_dir):
+            is_python = filename.endswith(".py")
+            has_prefix = filename.startswith(self.BACKEND_PREFIX)
+            if is_python and has_prefix:
+                yield filename
+
     def get_backend(self, backend_name):
         '''
         Returns the backend module for the backend matching

=== modified file 'GTG/backends/backend_launchpad.py'
--- GTG/backends/backend_launchpad.py	2013-11-23 14:40:23 +0000
+++ GTG/backends/backend_launchpad.py	2014-03-09 13:02:55 +0000
@@ -211,13 +211,13 @@
                 tid = str(uuid.uuid4())
                 task = self.datastore.task_factory(tid)
                 self._populate_task(task, bug_dic)
-                self.sync_engine.record_relationship(local_id=tid,
-                                                     remote_id=str(
-                                                     bug_dic['self_link']),
-                                                     meme=SyncMeme(
-                                                     task.get_modified(),
-                                                     bug_dic['modified'],
-                                                     self.get_id()))
+                meme = SyncMeme(
+                    task.get_modified(), bug_dic['modified'], self.get_id())
+                self.sync_engine.record_relationship(
+                    local_id=tid,
+                    remote_id=str(bug_dic['self_link']),
+                    meme=meme,
+                )
                 self.datastore.push_task(task)
 
             elif action == SyncEngine.UPDATE:

=== modified file 'GTG/backends/backend_mantis.py'
--- GTG/backends/backend_mantis.py	2013-11-23 14:40:23 +0000
+++ GTG/backends/backend_mantis.py	2014-03-09 13:02:55 +0000
@@ -177,13 +177,13 @@
                 tid = str(uuid.uuid4())
                 task = self.datastore.task_factory(tid)
                 self._populate_task(task, issue_dic)
-                self.sync_engine.record_relationship(local_id=tid,
-                                                     remote_id=str(
-                                                     issue_dic['number']),
-                                                     meme=SyncMeme(
-                                                     task.get_modified(),
-                                                     issue_dic['modified'],
-                                                     self.get_id()))
+                meme = SyncMeme(
+                    task.get_modified(), issue_dic['modified'], self.get_id())
+                self.sync_engine.record_relationship(
+                    local_id=tid,
+                    remote_id=str(issue_dic['number']),
+                    meme=meme
+                )
                 self.datastore.push_task(task)
 
             elif action == SyncEngine.UPDATE:

=== modified file 'GTG/backends/backend_rtm.py'
--- GTG/backends/backend_rtm.py	2014-03-01 09:07:22 +0000
+++ GTG/backends/backend_rtm.py	2014-03-09 13:02:55 +0000
@@ -890,7 +890,7 @@
             return ""
         else:
             note_list = self.__getattr_the_rtm_way(notes, 'note')
-            return "".join(["%s\n" % getattr(note, '$t') for note in note_list])
+            return "".join("%s\n" % getattr(note, '$t') for note in note_list)
 
     def set_text(self, text, transaction_ids=[]):
         '''

=== modified file 'GTG/backends/rtm/rtm.py'
--- GTG/backends/rtm/rtm.py	2014-03-01 09:47:05 +0000
+++ GTG/backends/rtm/rtm.py	2014-03-09 13:02:55 +0000
@@ -8,7 +8,9 @@
 )
 
 
-import urllib.request, urllib.parse, urllib.error
+import urllib.request
+import urllib.parse
+import urllib.error
 from hashlib import md5
 
 from GTG import _
@@ -242,75 +244,53 @@
         [('frob',), ()]
     },
     'contacts': {
-        'add':
-    [('timeline', 'contact'), ()],
-        'delete':
-    [('timeline', 'contact_id'), ()],
-        'getList':
-    [(), ()]
+        'add': [('timeline', 'contact'), ()],
+        'delete': [('timeline', 'contact_id'), ()],
+        'getList': [(), ()]
     },
     'groups': {
-        'add':
-    [('timeline', 'group'), ()],
-        'addContact':
-    [('timeline', 'group_id', 'contact_id'), ()],
-        'delete':
-    [('timeline', 'group_id'), ()],
-        'getList':
-    [(), ()],
-        'removeContact':
-    [('timeline', 'group_id', 'contact_id'), ()],
+        'add': [('timeline', 'group'), ()],
+        'addContact': [('timeline', 'group_id', 'contact_id'), ()],
+        'delete': [('timeline', 'group_id'), ()],
+        'getList': [(), ()],
+        'removeContact': [('timeline', 'group_id', 'contact_id'), ()],
     },
     'lists': {
-        'add':
-    [('timeline', 'name',), ('filter',)],
-        'archive':
-    [('timeline', 'list_id'), ()],
-        'delete':
-    [('timeline', 'list_id'), ()],
-        'getList':
-    [(), ()],
-        'setDefaultList':
-    [('timeline'), ('list_id')],
-        'setName':
-    [('timeline', 'list_id', 'name'), ()],
-        'unarchive':
-    [('timeline',), ('list_id',)]
+        'add': [('timeline', 'name',), ('filter',)],
+        'archive': [('timeline', 'list_id'), ()],
+        'delete': [('timeline', 'list_id'), ()],
+        'getList': [(), ()],
+        'setDefaultList': [('timeline'), ('list_id')],
+        'setName': [('timeline', 'list_id', 'name'), ()],
+        'unarchive': [('timeline',), ('list_id',)]
     },
     'locations': {
-        'getList':
-    [(), ()]
+        'getList': [(), ()]
     },
     'reflection': {
-        'getMethodInfo':
-    [('methodName',), ()],
-        'getMethods':
-    [(), ()]
+        'getMethodInfo': [('methodName',), ()],
+        'getMethods': [(), ()]
     },
     'settings': {
-        'getList':
-    [(), ()]
+        'getList': [(), ()]
     },
     'tasks': {
-        'add':
-    [('timeline', 'name',), ('list_id', 'parse',)],
-        'addTags':
-    [('timeline', 'list_id', 'taskseries_id', 'task_id', 'tags'),
-     ()],
-        'complete':
-    [('timeline', 'list_id', 'taskseries_id', 'task_id',), ()],
-        'delete':
-    [('timeline', 'list_id', 'taskseries_id', 'task_id'), ()],
-        'getList':
-    [(),
-     ('list_id', 'filter', 'last_sync')],
-        'movePriority':
-    [('timeline', 'list_id', 'taskseries_id', 'task_id', 'direction'),
-     ()],
-        'moveTo':
-    [(
-    'timeline', 'from_list_id', 'to_list_id', 'taskseries_id', 'task_id'),
-        ()],
+        'add': [('timeline', 'name',), ('list_id', 'parse',)],
+        'addTags': [
+            ('timeline', 'list_id', 'taskseries_id', 'task_id', 'tags'), (),
+        ],
+        'complete': [('timeline', 'list_id', 'taskseries_id', 'task_id',), ()],
+        'delete': [('timeline', 'list_id', 'taskseries_id', 'task_id'), ()],
+        'getList': [(), ('list_id', 'filter', 'last_sync')],
+        'movePriority': [
+            ('timeline', 'list_id', 'taskseries_id', 'task_id', 'direction'),
+            (),
+        ],
+        'moveTo': [
+            ('timeline', 'from_list_id', 'to_list_id',
+             'taskseries_id', 'task_id'),
+            (),
+        ],
         'postpone':
         [('timeline', 'list_id', 'taskseries_id', 'task_id'),
          ()],
@@ -346,37 +326,29 @@
          ()],
     },
     'tasksNotes': {
-        'add':
-    [('timeline', 'list_id', 'taskseries_id',
-      'task_id', 'note_title', 'note_text'), ()],
-        'delete':
-    [('timeline', 'note_id'), ()],
-        'edit':
-    [('timeline', 'note_id', 'note_title', 'note_text'), ()]
+        'add': [
+            ('timeline', 'list_id', 'taskseries_id', 'task_id',
+             'note_title', 'note_text'), ()],
+        'delete': [('timeline', 'note_id'), ()],
+        'edit': [('timeline', 'note_id', 'note_title', 'note_text'), ()]
     },
     'test': {
-        'echo':
-    [(), ()],
-        'login':
-    [(), ()]
+        'echo': [(), ()],
+        'login': [(), ()]
     },
     'time': {
-        'convert':
-    [('to_timezone',), ('from_timezone', 'to_timezone', 'time')],
-        'parse':
-    [('text',), ('timezone', 'dateformat')]
+        'convert': [
+            ('to_timezone',), ('from_timezone', 'to_timezone', 'time')],
+        'parse': [('text',), ('timezone', 'dateformat')]
     },
     'timelines': {
-        'create':
-    [(), ()]
+        'create': [(), ()]
     },
     'timezones': {
-        'getList':
-    [(), ()]
+        'getList': [(), ()]
     },
     'transactions': {
-        'undo':
-    [('timeline', 'transaction_id'), ()]
+        'undo': [('timeline', 'transaction_id'), ()]
     },
 }
 

=== modified file 'GTG/core/datastore.py'
--- GTG/core/datastore.py	2013-11-25 02:37:46 +0000
+++ GTG/core/datastore.py	2014-03-09 13:02:55 +0000
@@ -137,7 +137,6 @@
                        (query, e.message))
             return None
 
-
         # Create own copy of attributes and add special attributes label, query
         init_attr = dict(attributes)
         init_attr["label"] = name

=== modified file 'GTG/core/plugins/engine.py'
--- GTG/core/plugins/engine.py	2013-11-25 02:37:46 +0000
+++ GTG/core/plugins/engine.py	2014-03-09 13:02:55 +0000
@@ -18,7 +18,6 @@
 # -----------------------------------------------------------------------------
 import imp
 import os
-import types
 import configparser
 
 import dbus

=== modified file 'GTG/gtk/browser/tag_editor.py'
--- GTG/gtk/browser/tag_editor.py	2014-02-26 07:00:43 +0000
+++ GTG/gtk/browser/tag_editor.py	2014-03-09 13:02:55 +0000
@@ -473,7 +473,8 @@
         if self.tag is not None:
             if color is not None:
                 my_color = Gdk.color_parse(color)
-                color = Gdk.Color(my_color.red, my_color.green, my_color.blue).to_string()
+                color = Gdk.Color(
+                    my_color.red, my_color.green, my_color.blue).to_string()
                 color_add(color)
                 self.tag.set_attribute('color', color)
             else:

=== modified file 'GTG/gtk/browser/treeview_factory.py'
--- GTG/gtk/browser/treeview_factory.py	2014-03-01 21:15:24 +0000
+++ GTG/gtk/browser/treeview_factory.py	2014-03-09 13:02:55 +0000
@@ -77,9 +77,10 @@
         search_parent = self.req.get_tag(CoreConfig.SEARCH_TAG)
         for search_tag in search_parent.get_children():
             tag = self.req.get_tag(search_tag)
-            match = search_filter(node,
-                                  parse_search_query(
-                                  tag.get_attribute('query')))
+            match = search_filter(
+                node,
+                parse_search_query(tag.get_attribute('query')),
+            )
             if match and search_tag not in tags:
                 tags.append(tag)
 

=== modified file 'GTG/gtk/colors.py'
--- GTG/gtk/colors.py	2014-02-26 07:00:43 +0000
+++ GTG/gtk/colors.py	2014-03-09 13:02:55 +0000
@@ -26,6 +26,7 @@
 
 used_color = []
 
+
 def background_color(tags, bgcolor=None):
     if not bgcolor:
         bgcolor = Gdk.color_parse("#FFFFFF")

=== modified file 'GTG/gtk/crashhandler.py'
--- GTG/gtk/crashhandler.py	2013-08-28 20:13:59 +0000
+++ GTG/gtk/crashhandler.py	2014-03-09 13:02:55 +0000
@@ -44,7 +44,7 @@
 try:
     from gi.repository import GObject, Gtk, Pango
 except Exception:
-    print("gtkcrashhandler could not load GTK 3.0", file=sys.stderr)
+    sys.stderr.write("gtkcrashhandler could not load GTK 3.0\n")
     _gtk_initialized = False
 else:
     _gtk_initialized = True
@@ -97,7 +97,8 @@
     if thread:
         if not isinstance(thread, threading._MainThread):
             tb = "Exception in thread %s:\n%s" % (thread.getName(), tb)
-    print(tb, file=sys.stderr)
+
+    sys.stderr.write(tb + '\n')
 
     # determine whether to add a "Report problem..." button
     add_apport_button = False
@@ -206,7 +207,8 @@
     try:
         textview.override_font(Pango.FontDescription("monospace 8"))
     except Exception:
-        print("gtkcrashhandler: override_font raised an exception", file=sys.stderr)
+        sys.stderr.write(
+            "gtkcrashhandler: override_font raised an exception\n")
 
     # allow scrolling of textview
     scrolled = Gtk.ScrolledWindow()
@@ -329,8 +331,10 @@
     yield
 
 initialize(app_name="Getting Things GNOME!",
-           message="GTG" + info.VERSION +
-           _(" has crashed. Please report the bug on <a href=\""
-           "http://bugs.edge.launchpad.net/gtg\";>our Launchpad page</a>."
-             " If you have Apport installed, it will be started for you."),
+           message=_(
+               'GTG %s has crashed. Please report the bug on '
+               '<a href="http://bugs.edge.launchpad.net/gtg";>'
+               'our Launchpad page</a>. '
+               'If you have Apport installed, it will be started for you.'
+           ) % info.VERSION,
            use_apport=True)

=== modified file 'GTG/gtk/editor/calendar.py'
--- GTG/gtk/editor/calendar.py	2014-02-21 10:03:07 +0000
+++ GTG/gtk/editor/calendar.py	2014-03-09 13:02:55 +0000
@@ -50,23 +50,14 @@
         self.__window = self.__builder.get_object("calendar")
         self.__calendar = self.__builder.get_object("calendar1")
         self.__fuzzydate_btns = self.__builder.get_object("fuzzydate_btns")
-        self.__builder.get_object("button_clear").connect("clicked",
-                                                          lambda w:
-                                                          self.__day_selected(
-                                                          w, ""))
-        self.__builder.get_object("button_now").connect("clicked",
-                                                        lambda w:
-                                                        self.__day_selected(
-                                                        w, "now"))
-        self.__builder.get_object("button_soon").connect("clicked",
-                                                         lambda w:
-                                                         self.__day_selected(
-                                                         w, "soon"))
-        self.__builder.get_object("button_someday").connect("clicked",
-                                                            lambda w:
-                                                            self.
-                                                            __day_selected(w,
-                                                            "someday"))
+        self.__builder.get_object("button_clear").connect(
+            "clicked", lambda w: self.__day_selected(w, ""))
+        self.__builder.get_object("button_now").connect(
+            "clicked", lambda w: self.__day_selected(w, "now"))
+        self.__builder.get_object("button_soon").connect(
+            "clicked", lambda w: self.__day_selected(w, "soon"))
+        self.__builder.get_object("button_someday").connect(
+            "clicked", lambda w: self.  __day_selected(w, "someday"))
 
     def set_date(self, date, date_kind):
         self.__date_kind = date_kind
@@ -137,12 +128,12 @@
             #True,
             #Gdk.ModifierType.BUTTON1_MASK | Gdk.ModifierType.MOD2_MASK
         #)
-#FIXME THIS DOES NOT WORK!!!!!!!
+        #FIXME THIS DOES NOT WORK!!!!!!!
         Gdk.pointer_grab(
             self.get_window(),
             True,
             #Gdk.ModifierType.BUTTON1_MASK | Gdk.ModifierType.MOD2_MASK,
-#FIXME!!!! JUST GUESSING THE TYPE
+            #FIXME!!!! JUST GUESSING THE TYPE
             Gdk.EventMask.ALL_EVENTS_MASK,
             None,
             None,

=== modified file 'GTG/gtk/editor/editor.py'
--- GTG/gtk/editor/editor.py	2014-03-05 19:25:18 +0000
+++ GTG/gtk/editor/editor.py	2014-03-09 13:02:55 +0000
@@ -361,14 +361,14 @@
                 menu.append(mi)
         if tag_count > 0:
             self.inserttag_button.set_menu(menu)
-            
+
         # Refreshing the parent list in open_parent_button
         menu = Gtk.Menu()
         parents = self.task.get_parents()
         if len(parents) > 0:
             for parent in self.task.get_parents():
                 task = self.req.get_task(parent)
-                mi = Gtk.MenuItem(label = task.get_title(), use_underline=False)
+                mi = Gtk.MenuItem(label=task.get_title(), use_underline=False)
                 mi.connect("activate", self.open_parent, parent)
                 mi.show()
                 menu.append(mi)
@@ -519,10 +519,10 @@
     def inserttag(self, widget, tag):
         self.textview.insert_tags([tag])
         self.textview.grab_focus()
-        
+
     def open_parent_clicked(self, widget):
         self.vmanager.open_task(self.task.get_parents()[0])
-    
+
     # On click handler for open_parent_button's menu items
     def open_parent(self, widget, tid):
         self.vmanager.open_task(tid)

=== modified file 'GTG/gtk/manager.py'
--- GTG/gtk/manager.py	2013-11-25 02:37:46 +0000
+++ GTG/gtk/manager.py	2014-03-09 13:02:55 +0000
@@ -309,9 +309,13 @@
         # FIXME: this code is replicated in the preference window.
         if len(self.pengine.plugins) > 0:
             self.plugins_config.clear()
-            self.plugins_config.set("disabled",
-                [p.module_name for p in self.pengine.get_plugins("disabled")])
-            self.plugins_config.set("enabled",
-                [p.module_name for p in self.pengine.get_plugins("enabled")])
+            self.plugins_config.set(
+                "disabled",
+                [p.module_name for p in self.pengine.get_plugins("disabled")],
+            )
+            self.plugins_config.set(
+                "enabled",
+                [p.module_name for p in self.pengine.get_plugins("enabled")],
+            )
         # plugins are deactivated
         self.pengine.deactivate_plugins()

=== modified file 'GTG/gtk/plugins.py'
--- GTG/gtk/plugins.py	2013-11-25 02:37:46 +0000
+++ GTG/gtk/plugins.py	2014-03-09 13:02:55 +0000
@@ -147,10 +147,14 @@
         self.pengine = PluginEngine()
         # plugin config initiation
         if self.pengine.get_plugins():
-            self.config.set("disabled",
-                [p.module_name for p in self.pengine.get_plugins("disabled")])
-            self.config.set("enabled",
-                [p.module_name for p in self.pengine.get_plugins("enabled")])
+            self.config.set(
+                "disabled",
+                [p.module_name for p in self.pengine.get_plugins("disabled")],
+            )
+            self.config.set(
+                "enabled",
+                [p.module_name for p in self.pengine.get_plugins("enabled")],
+            )
 
         # see constants PLUGINS_COL_* for column meanings
         self.plugin_store = Gtk.ListStore(str, bool, str, str, bool)

=== modified file 'GTG/plugins/hamster/hamster.py'
--- GTG/plugins/hamster/hamster.py	2014-01-12 07:15:09 +0000
+++ GTG/plugins/hamster/hamster.py	2014-03-09 13:02:55 +0000
@@ -19,7 +19,7 @@
 
 from calendar import timegm
 import dbus
-from gi.repository import Gtk, Gdk, GdkPixbuf
+from gi.repository import Gtk, GdkPixbuf
 import os
 import re
 import time
@@ -317,7 +317,7 @@
             for offset, i in enumerate(records):
                 t = calc_duration(i)
                 total += t
-                add(inner_table, format_date(i), format_duration(t),
+                add(inner_grid, format_date(i), format_duration(t),
                     offset, i[0] == active_id)
 
             add(outer_grid, "<big><b>Total</b></big>",

=== modified file 'GTG/plugins/send_email/sendEmail.py'
--- GTG/plugins/send_email/sendEmail.py	2013-11-08 20:42:51 +0000
+++ GTG/plugins/send_email/sendEmail.py	2014-03-09 13:02:55 +0000
@@ -21,7 +21,9 @@
 
 from gi.repository import Gio
 from gi.repository import Gtk
-import urllib.request, urllib.parse, urllib.error
+import urllib.request
+import urllib.parse
+import urllib.error
 
 from GTG import _
 

=== modified file 'GTG/plugins/tomboy/tomboy.py'
--- GTG/plugins/tomboy/tomboy.py	2013-08-28 20:11:53 +0000
+++ GTG/plugins/tomboy/tomboy.py	2014-03-09 13:02:55 +0000
@@ -62,15 +62,15 @@
             # showed only once
             DIALOG_DESTROY_WITH_PARENT = Gtk.DialogFlags.DESTROY_WITH_PARENT
             if not self.activated:
-                dialog = Gtk.MessageDialog(parent=self.plugin_api.get_ui().
-                                           get_window(),
-                                           flags=DIALOG_DESTROY_WITH_PARENT,
-                                           type=Gtk.MessageType.ERROR,
-                                           buttons=Gtk.ButtonsType.OK,
-                                           message_format=_("Tomboy/Gnote "
-                                           "not found. Please install it or "
-                                           "disable the Tomboy/Gnote plugin"
-                                           " in GTG"))
+                message = _("Tomboy/Gnote not found. Please install it or "
+                            "disable the Tomboy/Gnote plugin in GTG")
+                dialog = Gtk.MessageDialog(
+                    parent=self.plugin_api.get_ui().get_window(),
+                    flags=DIALOG_DESTROY_WITH_PARENT,
+                    type=Gtk.MessageType.ERROR,
+                    buttons=Gtk.ButtonsType.OK,
+                    message_format=message,
+                )
                 dialog.run()
                 dialog.destroy()
         return self.activated
@@ -179,17 +179,17 @@
         except dbus.DBusException:
             DIALOG_DESTROY_WITH_PARENT = Gtk.DialogFlags.DESTROY_WITH_PARENT
             if not hasattr(self, "disable_flag"):
-                dialog = Gtk.MessageDialog(parent=self.plugin_api.get_ui().
-                                           get_window(),
-                                           flags=DIALOG_DESTROY_WITH_PARENT,
-                                           type=Gtk.MessageType.ERROR,
-                                           buttons=Gtk.ButtonsType.OK,
-                                           message_format=_("%s seems to be "
-                                           "installed on your system, but it "
-                                           "does not provide a DBus interface"
-                                           " which is required by the "
-                                           "Tomboy/Gnote plugin in GTG.") %
-                                           self.software.title())
+                message = _(
+                    "%s seems to be installed on your system, but it does "
+                    "not provide a DBus interface which is required by the "
+                    "Tomboy/Gnote plugin in GTG.") % self.software.title()
+                dialog = Gtk.MessageDialog(
+                    parent=self.plugin_api.get_ui().get_window(),
+                    flags=DIALOG_DESTROY_WITH_PARENT,
+                    type=Gtk.MessageType.ERROR,
+                    buttons=Gtk.ButtonsType.OK,
+                    message_format=message,
+                )
                 dialog.run()
                 dialog.destroy()
                 self.disable_flag = True
@@ -201,7 +201,8 @@
         tomboy = self.getTomboyObject()
         if tomboy is None:
             return None
-        return [str(tomboy.GetNoteTitle(note)) for note in tomboy.ListAllNotes()]
+        return [
+            str(tomboy.GetNoteTitle(note)) for note in tomboy.ListAllNotes()]
 
     def onTbTaskButton(self, widget, plugin_api):
         title_list = self.getTomboyNoteTitleList()
@@ -223,6 +224,12 @@
                                                     self.noteChosen)
         self.dialog.show_all()
 
+    def _node_exist(self, tomboy, title):
+        for note in tomboy.ListAllNotes():
+            if tomboy.GetNoteTitle(note) == title:
+                return True
+        return False
+
     # A title has been chosen by the user. If the note exists, it will be
     # linked, otherwise the user will have the option to create the note.
     def noteChosen(self, widget=None, data=None):
@@ -230,15 +237,18 @@
         if tomboy is None:
             return
         supposed_title = self.combobox_entry.get_text()
-        if [x for x in tomboy.ListAllNotes() if tomboy.GetNoteTitle(x) == supposed_title] == []:
+        if not self._node_exist(tomboy, supposed_title):
             self.label_caption.set_text(_("That note does not exist!"))
             DIALOG_DESTROY_WITH_PARENT = Gtk.DialogFlags.DESTROY_WITH_PARENT
-            dialog = Gtk.MessageDialog(parent=self.dialog,
-                                       flags=DIALOG_DESTROY_WITH_PARENT,
-                                       type=Gtk.MessageType.QUESTION,
-                                       buttons=Gtk.ButtonsType.YES_NO,
-                                       message_format=_("That note does not \
-exist. Do you want to create a new one?"))
+            message = _(
+                "That note does not exist. Do you want to create a new one?")
+            dialog = Gtk.MessageDialog(
+                parent=self.dialog,
+                flags=DIALOG_DESTROY_WITH_PARENT,
+                type=Gtk.MessageType.QUESTION,
+                buttons=Gtk.ButtonsType.YES_NO,
+                message_format=message,
+            )
             response = dialog.run()
             dialog.destroy()
             if response == Gtk.ResponseType.YES:

=== modified file 'GTG/tests/__init__.py'
--- GTG/tests/__init__.py	2013-11-25 02:37:46 +0000
+++ GTG/tests/__init__.py	2014-03-09 13:02:55 +0000
@@ -33,7 +33,9 @@
     '''
     # find all the test files
     test_dir = os.path.dirname(__file__)
-    test_files = [f for f in os.listdir(test_dir) if f.endswith(".py") and f.startswith("test_")]
+    test_files = [
+        f for f in os.listdir(test_dir)
+        if f.endswith(".py") and f.startswith("test_")]
 
     # Loading of the test files and adding to the TestSuite
     test_suite = unittest.TestSuite()

=== modified file 'GTG/tests/signals_testing.py'
--- GTG/tests/signals_testing.py	2013-11-25 02:37:46 +0000
+++ GTG/tests/signals_testing.py	2014-03-09 13:02:55 +0000
@@ -46,7 +46,8 @@
             # then we notify the error
             # if the error_code is set to None, we're expecting it to fail.
             if error_code is not None:
-                print("An expected signal wasn't received %s" % str(error_code))
+                print("An expected signal wasn't received %s" %
+                      str(error_code))
             self.unittest.assertFalse(should_be_caught)
 
         self.watchdog = Watchdog(3, _on_failure)
@@ -93,7 +94,8 @@
             # then we notify the error
             # if the error_code is set to None, we're expecting it to fail.
             if error_code is not None:
-                print("An expected signal wasn't received %s" % str(error_code))
+                print("An expected signal wasn't received %s" %
+                      str(error_code))
             self.unittest.assertFalse(should_be_caught)
 
         self.watchdog = Watchdog(3, _on_failure)

=== modified file 'GTG/tests/test_backend_tomboy.py'
--- GTG/tests/test_backend_tomboy.py	2013-11-25 02:37:46 +0000
+++ GTG/tests/test_backend_tomboy.py	2014-03-09 13:02:55 +0000
@@ -174,17 +174,17 @@
         # no-one updated, nothing should happen
         self.backend.set_task(task)
         self.assertEqual(gtg_modified, task.get_modified())
-        self.assertEqual(tomboy_modified,
-                         self._modified_string_to_datetime(
-                         self.tomboy.GetNoteChangeDate(note)))
+        actual_modified = self._modified_string_to_datetime(
+            self.tomboy.GetNoteChangeDate(note))
+        self.assertEqual(tomboy_modified, actual_modified)
         # we update the GTG task
         UPDATED_GTG_TITLE = "UPDATED_GTG_TITLE"
         task.set_title(UPDATED_GTG_TITLE)
         self.backend.set_task(task)
         self.assertTrue(gtg_modified < task.get_modified())
-        self.assertTrue(tomboy_modified <=
-                        self._modified_string_to_datetime(
-                        self.tomboy.GetNoteChangeDate(note)))
+        actual_modified = self._modified_string_to_datetime(
+            self.tomboy.GetNoteChangeDate(note))
+        self.assertTrue(tomboy_modified <= actual_modified)
         self.assertEqual(task.get_title(), UPDATED_GTG_TITLE)
         self.assertEqual(self.tomboy.GetNoteTitle(note), UPDATED_GTG_TITLE)
         gtg_modified = task.get_modified()
@@ -199,9 +199,9 @@
         self.tomboy.SetNoteContents(note, UPDATED_TOMBOY_TITLE)
         self.backend._process_tomboy_note(note)
         self.assertTrue(gtg_modified <= task.get_modified())
-        self.assertTrue(tomboy_modified <=
-                        self._modified_string_to_datetime(
-                        self.tomboy.GetNoteChangeDate(note)))
+        actual_modified = self._modified_string_to_datetime(
+            self.tomboy.GetNoteChangeDate(note))
+        self.assertTrue(tomboy_modified <= actual_modified)
         self.assertEqual(task.get_title(), UPDATED_TOMBOY_TITLE)
         self.assertEqual(self.tomboy.GetNoteTitle(note), UPDATED_TOMBOY_TITLE)
 

=== modified file 'GTG/tests/test_search_query.py'
--- GTG/tests/test_search_query.py	2013-11-23 14:40:23 +0000
+++ GTG/tests/test_search_query.py	2014-03-09 13:02:55 +0000
@@ -80,22 +80,32 @@
                          {'q': [("word", False, '@gtg')]})
 
     def test_or(self):
-        self.assertEqual(parse("@gtg !or @gtd"),
-                         {'q': [("or", True, [("tag", True, "@gtg"),
-                        ("tag", True, "@gtd")])]})
+        parsed = {'q': [
+            ("or", True, [("tag", True, "@gtg"), ("tag", True, "@gtd")]),
+        ]}
+        self.assertEqual(parse("@gtg !or @gtd"), parsed)
 
     def test_or_or(self):
-        self.assertEqual(parse("@gtg !or @gtd !or @a"),
-                         {'q': [("or", True, [("tag", True, "@gtg"),
-                        ("tag", True, "@gtd"), ("tag", True, "@a")])]})
+        parsed = {'q': [
+            ("or", True, [
+                ("tag", True, "@gtg"),
+                ("tag", True, "@gtd"),
+                ("tag", True, "@a"),
+            ]),
+        ]}
+        self.assertEqual(parse("@gtg !or @gtd !or @a"), parsed)
 
     def test_or_or_or_or_or(self):
-        self.assertEqual(parse("@gtg !or @gtd !or @a !or @b !or @c"),
-                         {'q': [("or", True, [
-                                 ("tag", True, "@gtg"), ("tag", True, "@gtd"),
-                        ("tag", True, "@a"), ("tag", True, "@b"),
-                             ("tag", True, "@c"),
-                         ])]})
+        parsed = {'q': [
+            ("or", True, [
+                ("tag", True, "@gtg"),
+                ("tag", True, "@gtd"),
+                ("tag", True, "@a"),
+                ("tag", True, "@b"),
+                ("tag", True, "@c"),
+            ])
+        ]}
+        self.assertEqual(parse("@gtg !or @gtd !or @a !or @b !or @c"), parsed)
 
     def test_not_or(self):
         self.assertRaises(InvalidQuery, parse, '!not !or')
@@ -162,19 +172,30 @@
                          {'q': [('before', True, d('next month'))]})
 
         # Test other things as well
-        self.assertEqual(parse("@gtg !before tomorrow @gtg"),
-                         {'q': [('tag', True, '@gtg'),
-                                ('before', True, d('tomorrow')),
-                        ('tag', True, '@gtg')]})
-        self.assertEqual(parse("!before tomorrow !not @gtg"),
-                         {'q': [('before', True, d('tomorrow')),
-                                ('tag', False, '@gtg')]})
-        self.assertEqual(parse("!before tomorrow mytask"),
-                         {'q': [('before', True, d('tomorrow')),
-                                ('word', True, 'mytask')]})
-        self.assertEqual(parse("!before tomorrow !not mytask"),
-                         {'q': [('before', True, d('tomorrow')),
-                        ('word', False, 'mytask')]})
+        parsed = {'q': [
+            ('tag', True, '@gtg'),
+            ('before', True, d('tomorrow')),
+            ('tag', True, '@gtg'),
+        ]}
+        self.assertEqual(parse("@gtg !before tomorrow @gtg"), parsed)
+
+        parsed = {'q': [
+            ('before', True, d('tomorrow')),
+            ('tag', False, '@gtg'),
+        ]}
+        self.assertEqual(parse("!before tomorrow !not @gtg"), parsed)
+
+        parsed = {'q': [
+            ('before', True, d('tomorrow')),
+            ('word', True, 'mytask'),
+        ]}
+        self.assertEqual(parse("!before tomorrow mytask"), parsed)
+
+        parsed = {'q': [
+            ('before', True, d('tomorrow')),
+            ('word', False, 'mytask'),
+        ]}
+        self.assertEqual(parse("!before tomorrow !not mytask"), parsed)
 
         # Test whitespace
         self.assertEqual(parse("!before                        today       "),

=== modified file 'GTG/tools/cleanxml.py'
--- GTG/tools/cleanxml.py	2013-11-25 02:37:46 +0000
+++ GTG/tools/cleanxml.py	2014-03-09 13:02:55 +0000
@@ -224,9 +224,8 @@
                 current = "%s.bak.0" % backup_name
                 shutil.copy(zefile, current)
 
-                daily_backup = "%s.%s.bak" % (backup_name,
-                                              datetime.date.today().strftime(
-                                              "%Y-%m-%d"))
+                daily_backup = "%s.%s.bak" % (
+                    backup_name, datetime.date.today().strftime("%Y-%m-%d"))
                 if not os.path.exists(daily_backup):
                     shutil.copy(zefile, daily_backup)
             return True

=== modified file 'GTG/tools/shortcut.py'
--- GTG/tools/shortcut.py	2014-01-12 07:15:09 +0000
+++ GTG/tools/shortcut.py	2014-03-09 13:02:55 +0000
@@ -50,6 +50,7 @@
 def is_gsettings_present():
     return bool(call_subprocess(CHECK_GSETTINGS_PRESENCE))
 
+
 def get_saved_binding():
     """ Get the current shortcut if the task exists """
     list_keys = call_subprocess(CHECK_VERSION).splitlines()

=== modified file 'GTG/tools/urlregex.py'
--- GTG/tools/urlregex.py	2013-11-25 02:37:46 +0000
+++ GTG/tools/urlregex.py	2014-03-09 13:02:55 +0000
@@ -32,7 +32,7 @@
     "pre": r'(?:[^/"\':!=]|^|\:)',
     "domain": r'([\.-]|[^\s_\!\.\/])+\.[a-z]{2,}(?::[0-9]+)?',
     "path": r'(?:[\.,]?[%s!\*\'\(\);:&=\+\$/%s#\[\]\-_,~@])' % (
-    UTF_CHARS, '%'),
+        UTF_CHARS, '%'),
     "query": r'[a-z0-9!\*\'\(\);:&=\+\$/%#\[\]\-_\.,~]',
     # Valid end-of-path characters (so /foo. does not gobble the period).
     "path_end": r'[%s\)=#/]' % UTF_CHARS,

_______________________________________________
Mailing list: https://launchpad.net/~gtg
Post to     : gtg@lists.launchpad.net
Unsubscribe : https://launchpad.net/~gtg
More help   : https://help.launchpad.net/ListHelp

Reply via email to