diff --git a/docs/conf.py b/docs/conf.py
index fb0ad26..85c70b2 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -3,10 +3,12 @@
# Mitter documentation build configuration file, created by
# sphinx-quickstart on Sun Apr 5 18:19:25 2009.
#
-# This file is execfile()d with the current directory set to its containing dir.
+# This file is execfile()d with the current directory set to its containing
+# dir.
#
# The contents of this file are pickled, so don't put values in the namespace
-# that aren't pickleable (module imports are okay, they're removed automatically).
+# that aren't pickleable (module imports are okay, they're removed
+# automatically).
#
# Note that not all possible configuration values are present in this
# autogenerated file.
@@ -14,7 +16,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
-import sys, os
+import sys
+import os
# If your extensions are in another directory, add it here. If the directory
# is relative to the documentation root, use os.path.abspath to make it
@@ -32,9 +35,10 @@ sys.path.append(mitterlib_network)
# General configuration
# ---------------------
-# Add any Sphinx extension module names here, as strings. They can be extensions
-# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx']
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest',
+ 'sphinx.ext.intersphinx']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['.templates']
@@ -78,7 +82,8 @@ release = '1.0'
# for source files.
exclude_trees = ['.build']
-# The reST default role (used for this markup: `text`) to use for all documents.
+# The reST default role (used for this markup: `text`) to use for all
+# documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
@@ -174,7 +179,8 @@ htmlhelp_basename = 'Mitterdoc'
#latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
-# (source start file, target name, title, author, document class [howto/manual]).
+# (source start file, target name, title, author, document class
+# [howto/manual]).
latex_documents = [
('index', 'Mitter.tex', ur'Mitter Documentation',
ur'Julio Biason', 'manual'),
diff --git a/mitterlib/network/networkbase.py b/mitterlib/network/networkbase.py
index e314303..a8d6a2f 100644
--- a/mitterlib/network/networkbase.py
+++ b/mitterlib/network/networkbase.py
@@ -107,6 +107,7 @@ class MessageTooLongWarning(NetworkWarning):
class NetworkUser(object):
"""Provides an uniform way to access information about users."""
+
def __init__(self):
self.name = ''
"""The name to be displayed as author of the message. *Required*"""
diff --git a/mitterlib/network/twitter.py b/mitterlib/network/twitter.py
index 3e6a87b..7b87131 100644
--- a/mitterlib/network/twitter.py
+++ b/mitterlib/network/twitter.py
@@ -187,7 +187,6 @@ class Connection(NetworkBase):
#------------------------------------------------------------
# Properties
#------------------------------------------------------------
-
@property
def is_setup(self):
"""Return True or False if the network is setup/enabled."""
@@ -226,7 +225,6 @@ class Connection(NetworkBase):
#------------------------------------------------------------
# Private functions
#------------------------------------------------------------
-
def _common_headers(self):
"""Returns a string with the normal headers we should add on every
request"""
@@ -429,7 +427,6 @@ class Connection(NetworkBase):
#------------------------------------------------------------
# NetworkBase required functions
#------------------------------------------------------------
-
def messages(self):
"""Return a list of NetworkData objects for the main "timeline"."""
return self._timeline('last_tweet', '/statuses/home_timeline.json')
diff --git a/mitterlib/ui/helpers/gdk_avatarcache.py b/mitterlib/ui/helpers/gdk_avatarcache.py
index d0ac7b8..1c4656e 100644
--- a/mitterlib/ui/helpers/gdk_avatarcache.py
+++ b/mitterlib/ui/helpers/gdk_avatarcache.py
@@ -122,4 +122,3 @@ class AvatarCache(object):
_log.debug('Exception trying to get an avatar.')
_log.debug(str(exception))
return
-
diff --git a/mitterlib/ui/helpers/gtk_messagegrid.py b/mitterlib/ui/helpers/gtk_messagegrid.py
index 61c4ddc..148fdc8 100644
--- a/mitterlib/ui/helpers/gtk_messagegrid.py
+++ b/mitterlib/ui/helpers/gtk_messagegrid.py
@@ -60,6 +60,7 @@ N_ = t.ngettext
# ----------------------------------------------------------------------
# MessageGrid class
# ----------------------------------------------------------------------
+
class MessageGrid(gtk.ScrolledWindow, gobject.GObject):
"""Custom message grid."""
@@ -71,8 +72,7 @@ class MessageGrid(gtk.ScrolledWindow, gobject.GObject):
'message-changed': ( # the selected message changed
gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE,
- (gobject.TYPE_PYOBJECT, ))
- }
+ (gobject.TYPE_PYOBJECT, ))}
@property
def count(self):
@@ -379,7 +379,7 @@ class MessageGrid(gtk.ScrolledWindow, gobject.GObject):
def clear_posts(self):
"""Clear the list of posts from the grid."""
self._grid.get_model().clear()
- self.count = 0;
+ self.count = 0
return
def mark_all_read(self):
@@ -413,4 +413,4 @@ class MessageGrid(gtk.ScrolledWindow, gobject.GObject):
iter = message.iter
self._grid.get_model().remove(iter)
- return
\ No newline at end of file
+ return
diff --git a/mitterlib/ui/helpers/gtk_threading.py b/mitterlib/ui/helpers/gtk_threading.py
index d304315..f4cefd2 100644
--- a/mitterlib/ui/helpers/gtk_threading.py
+++ b/mitterlib/ui/helpers/gtk_threading.py
@@ -14,6 +14,9 @@ import logging
_log = logging.getLogger('helper.gtk_threads')
# ----------------------------------------------------------------------
+# Helper class for GObject
+# ----------------------------------------------------------------------
+
class _IdleObject(gobject.GObject):
"""
Override gobject.GObject to always emit signals in the main thread
@@ -27,6 +30,9 @@ class _IdleObject(gobject.GObject):
gobject.idle_add(gobject.GObject.emit, self, *args)
# ----------------------------------------------------------------------
+# A (worker) thread; does all the hard work.
+# ----------------------------------------------------------------------
+
class _WorkerThread(threading.Thread, _IdleObject):
"""
A single working thread.
@@ -60,7 +66,7 @@ class _WorkerThread(threading.Thread, _IdleObject):
result = self._function(*args, **kwargs)
except Exception, exc: # Catch ALL exceptions
# TODO: Check if this catch all warnins too!
- _log.debug('Exception inside thread %s:\n%s',
+ _log.debug('Exception inside thread %s:\n%s',
self.getName(), str(exc))
self.emit("exception", exc)
return
@@ -71,6 +77,9 @@ class _WorkerThread(threading.Thread, _IdleObject):
return
# ----------------------------------------------------------------------
+# The Thread manager class
+# ----------------------------------------------------------------------
+
class ThreadManager(object):
"""Manages the threads."""
@@ -143,4 +152,3 @@ class ThreadManager(object):
self._thread_pool = []
self._running = []
return
-
diff --git a/mitterlib/ui/helpers/gtk_updatebox.py b/mitterlib/ui/helpers/gtk_updatebox.py
index 09be63a..cc40b41 100644
--- a/mitterlib/ui/helpers/gtk_updatebox.py
+++ b/mitterlib/ui/helpers/gtk_updatebox.py
@@ -38,6 +38,7 @@ N_ = t.ngettext
# ----------------------------------------------------------------------
# UpdateBox class
# ----------------------------------------------------------------------
+
class UpdateBox(gtk.VBox):
"""Custom update box widget."""
@@ -45,9 +46,7 @@ class UpdateBox(gtk.VBox):
'text-focus': (
gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE,
- ()
- )
- }
+ ())}
def __init__(self, avatar, spell_check=True):
super(UpdateBox, self).__init__(False, 0)
diff --git a/mitterlib/ui/helpers/timesince.py b/mitterlib/ui/helpers/timesince.py
index 829e017..8e368e4 100644
--- a/mitterlib/ui/helpers/timesince.py
+++ b/mitterlib/ui/helpers/timesince.py
@@ -18,7 +18,6 @@
# along with this program. If not, see .
import datetime
-import time
import gettext
# ----------------------------------------------------------------------
@@ -38,6 +37,7 @@ def timesince(timestamp):
as a nicely formatted string, e.g "10 minutes"
Adapted from http://blog.natbat.co.uk/archive/2003/Jun/14/time_since
"""
+ assert(isinstance(timestamp, datetime.datetime))
chunks = (
(60 * 60 * 24 * 365, lambda n: N_('year', 'years', n)),
(60 * 60 * 24 * 30, lambda n: N_('month', 'months', n)),
@@ -45,9 +45,6 @@ def timesince(timestamp):
(60 * 60 * 24, lambda n: N_('day', 'days', n)),
(60 * 60, lambda n: N_('hour', 'hours', n)),
(60, lambda n: N_('minute', 'minutes', n)))
- # Convert datetime.date to datetime.datetime for comparison
- if not isinstance(timestamp, datetime.datetime):
- d = datetime.datetime(d.year, d.month, d.day)
now = datetime.datetime.utcnow()
diff --git a/mitterlib/ui/ui_pygtk.py b/mitterlib/ui/ui_pygtk.py
index b5ab99a..fd7dbd9 100644
--- a/mitterlib/ui/ui_pygtk.py
+++ b/mitterlib/ui/ui_pygtk.py
@@ -24,7 +24,6 @@ gobject.threads_init()
import logging
import urllib2
-import webbrowser
import gettext
from mitterlib.ui.helpers.image_helpers import find_image
@@ -84,8 +83,7 @@ class Interface(object):
(menu, toolbar, accelerators) = self._create_menu_and_toolbar()
self._update_field = UpdateBox(
self._images['avatar'],
- self._options[self.NAMESPACE]['spell_check']
- )
+ self._options[self.NAMESPACE]['spell_check'])
self._statusbar = self._create_statusbar()
# the messages grid
@@ -299,7 +297,8 @@ class Interface(object):
view_messages_action = gtk.Action('Messages', _('_Messages'),
_('Display messages'), None)
view_messages_action.connect('activate', self._change_tab, 0)
- self._action_group.add_action_with_accel(view_messages_action, '1')
+ self._action_group.add_action_with_accel(view_messages_action,
+ '1')
view_replies_action = gtk.Action('Replies', _('_Replies'),
_('Display replies'), None)
@@ -322,7 +321,6 @@ class Interface(object):
return (main_menu, main_toolbar, uimanager.get_accel_group())
-
def _create_statusbar(self):
"""Create the statusbar."""
statusbar = gtk.Statusbar()
@@ -361,7 +359,6 @@ class Interface(object):
# ------------------------------------------------------------
# Helper functions
# ------------------------------------------------------------
-
def _update_statusbar(self, message):
"""Update the statusbar with the message."""
self._statusbar.pop(self._statusbar_context)
@@ -397,8 +394,7 @@ class Interface(object):
'message_count': str(messages),
'message': N_('message', 'messages', messages),
'replies_count': str(replies),
- 'replies': N_('reply', 'replies', replies)
- }
+ 'replies': N_('reply', 'replies', replies)}
mask = self._options[self.NAMESPACE]['window_title']
for variable in title_info:
mask = mask.replace('{' + variable + '}', title_info[variable])
diff --git a/utils/pep8.py b/utils/pep8.py
index ac3a39b..6ac6d30 100644
--- a/utils/pep8.py
+++ b/utils/pep8.py
@@ -115,7 +115,6 @@ args = None
# Plugins (check functions) for physical lines
##############################################################################
-
def tabs_or_spaces(physical_line, indent_char):
"""
Never mix tabs and spaces.
@@ -191,7 +190,6 @@ def maximum_line_length(physical_line):
# Plugins (check functions) for logical lines
##############################################################################
-
def blank_lines(logical_line, blank_lines, indent_level, line_number,
previous_logical):
"""
@@ -404,7 +402,6 @@ def python_3000_raise_comma(logical_line):
# Helper functions
##############################################################################
-
def expand_indent(line):
"""
Return the amount of indentation.
@@ -436,7 +433,6 @@ def expand_indent(line):
# Framework to run all checks
##############################################################################
-
def message(text):
"""Print a message."""
# print >> sys.stderr, options.prog + ': ' + text