Browse Source

PEP8'd and Pyflake'd

master
Julio Biason 15 years ago
parent
commit
3ed7bd1414
  1. 22
      docs/conf.py
  2. 1
      mitterlib/network/networkbase.py
  3. 3
      mitterlib/network/twitter.py
  4. 1
      mitterlib/ui/helpers/gdk_avatarcache.py
  5. 6
      mitterlib/ui/helpers/gtk_messagegrid.py
  6. 10
      mitterlib/ui/helpers/gtk_threading.py
  7. 5
      mitterlib/ui/helpers/gtk_updatebox.py
  8. 5
      mitterlib/ui/helpers/timesince.py
  9. 12
      mitterlib/ui/ui_pygtk.py
  10. 4
      utils/pep8.py

22
docs/conf.py

@ -3,10 +3,12 @@
# Mitter documentation build configuration file, created by # Mitter documentation build configuration file, created by
# sphinx-quickstart on Sun Apr 5 18:19:25 2009. # 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 # 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 # Note that not all possible configuration values are present in this
# autogenerated file. # autogenerated file.
@ -14,7 +16,8 @@
# All configuration values have a default; values that are commented out # All configuration values have a default; values that are commented out
# serve to show the default. # 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 # 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 # is relative to the documentation root, use os.path.abspath to make it
@ -32,9 +35,10 @@ sys.path.append(mitterlib_network)
# General configuration # General configuration
# --------------------- # ---------------------
# Add any Sphinx extension module names here, as strings. They can be extensions # Add any Sphinx extension module names here, as strings. They can be
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx'] extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest',
'sphinx.ext.intersphinx']
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
templates_path = ['.templates'] templates_path = ['.templates']
@ -78,7 +82,8 @@ release = '1.0'
# for source files. # for source files.
exclude_trees = ['.build'] 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 #default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text. # If true, '()' will be appended to :func: etc. cross-reference text.
@ -174,7 +179,8 @@ htmlhelp_basename = 'Mitterdoc'
#latex_font_size = '10pt' #latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples # 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 = [ latex_documents = [
('index', 'Mitter.tex', ur'Mitter Documentation', ('index', 'Mitter.tex', ur'Mitter Documentation',
ur'Julio Biason', 'manual'), ur'Julio Biason', 'manual'),

1
mitterlib/network/networkbase.py

@ -107,6 +107,7 @@ class MessageTooLongWarning(NetworkWarning):
class NetworkUser(object): class NetworkUser(object):
"""Provides an uniform way to access information about users.""" """Provides an uniform way to access information about users."""
def __init__(self): def __init__(self):
self.name = '' self.name = ''
"""The name to be displayed as author of the message. *Required*""" """The name to be displayed as author of the message. *Required*"""

3
mitterlib/network/twitter.py

@ -187,7 +187,6 @@ class Connection(NetworkBase):
#------------------------------------------------------------ #------------------------------------------------------------
# Properties # Properties
#------------------------------------------------------------ #------------------------------------------------------------
@property @property
def is_setup(self): def is_setup(self):
"""Return True or False if the network is setup/enabled.""" """Return True or False if the network is setup/enabled."""
@ -226,7 +225,6 @@ class Connection(NetworkBase):
#------------------------------------------------------------ #------------------------------------------------------------
# Private functions # Private functions
#------------------------------------------------------------ #------------------------------------------------------------
def _common_headers(self): def _common_headers(self):
"""Returns a string with the normal headers we should add on every """Returns a string with the normal headers we should add on every
request""" request"""
@ -429,7 +427,6 @@ class Connection(NetworkBase):
#------------------------------------------------------------ #------------------------------------------------------------
# NetworkBase required functions # NetworkBase required functions
#------------------------------------------------------------ #------------------------------------------------------------
def messages(self): def messages(self):
"""Return a list of NetworkData objects for the main "timeline".""" """Return a list of NetworkData objects for the main "timeline"."""
return self._timeline('last_tweet', '/statuses/home_timeline.json') return self._timeline('last_tweet', '/statuses/home_timeline.json')

1
mitterlib/ui/helpers/gdk_avatarcache.py

@ -122,4 +122,3 @@ class AvatarCache(object):
_log.debug('Exception trying to get an avatar.') _log.debug('Exception trying to get an avatar.')
_log.debug(str(exception)) _log.debug(str(exception))
return return

6
mitterlib/ui/helpers/gtk_messagegrid.py

@ -60,6 +60,7 @@ N_ = t.ngettext
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# MessageGrid class # MessageGrid class
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
class MessageGrid(gtk.ScrolledWindow, gobject.GObject): class MessageGrid(gtk.ScrolledWindow, gobject.GObject):
"""Custom message grid.""" """Custom message grid."""
@ -71,8 +72,7 @@ class MessageGrid(gtk.ScrolledWindow, gobject.GObject):
'message-changed': ( # the selected message changed 'message-changed': ( # the selected message changed
gobject.SIGNAL_RUN_LAST, gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE, gobject.TYPE_NONE,
(gobject.TYPE_PYOBJECT, )) (gobject.TYPE_PYOBJECT, ))}
}
@property @property
def count(self): def count(self):
@ -379,7 +379,7 @@ class MessageGrid(gtk.ScrolledWindow, gobject.GObject):
def clear_posts(self): def clear_posts(self):
"""Clear the list of posts from the grid.""" """Clear the list of posts from the grid."""
self._grid.get_model().clear() self._grid.get_model().clear()
self.count = 0; self.count = 0
return return
def mark_all_read(self): def mark_all_read(self):

10
mitterlib/ui/helpers/gtk_threading.py

@ -14,6 +14,9 @@ import logging
_log = logging.getLogger('helper.gtk_threads') _log = logging.getLogger('helper.gtk_threads')
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Helper class for GObject
# ----------------------------------------------------------------------
class _IdleObject(gobject.GObject): class _IdleObject(gobject.GObject):
""" """
Override gobject.GObject to always emit signals in the main thread 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) gobject.idle_add(gobject.GObject.emit, self, *args)
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# A (worker) thread; does all the hard work.
# ----------------------------------------------------------------------
class _WorkerThread(threading.Thread, _IdleObject): class _WorkerThread(threading.Thread, _IdleObject):
""" """
A single working thread. A single working thread.
@ -71,6 +77,9 @@ class _WorkerThread(threading.Thread, _IdleObject):
return return
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# The Thread manager class
# ----------------------------------------------------------------------
class ThreadManager(object): class ThreadManager(object):
"""Manages the threads.""" """Manages the threads."""
@ -143,4 +152,3 @@ class ThreadManager(object):
self._thread_pool = [] self._thread_pool = []
self._running = [] self._running = []
return return

5
mitterlib/ui/helpers/gtk_updatebox.py

@ -38,6 +38,7 @@ N_ = t.ngettext
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# UpdateBox class # UpdateBox class
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
class UpdateBox(gtk.VBox): class UpdateBox(gtk.VBox):
"""Custom update box widget.""" """Custom update box widget."""
@ -45,9 +46,7 @@ class UpdateBox(gtk.VBox):
'text-focus': ( 'text-focus': (
gobject.SIGNAL_RUN_LAST, gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE, gobject.TYPE_NONE,
() ())}
)
}
def __init__(self, avatar, spell_check=True): def __init__(self, avatar, spell_check=True):
super(UpdateBox, self).__init__(False, 0) super(UpdateBox, self).__init__(False, 0)

5
mitterlib/ui/helpers/timesince.py

@ -18,7 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import datetime import datetime
import time
import gettext import gettext
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
@ -38,6 +37,7 @@ def timesince(timestamp):
as a nicely formatted string, e.g "10 minutes" as a nicely formatted string, e.g "10 minutes"
Adapted from http://blog.natbat.co.uk/archive/2003/Jun/14/time_since Adapted from http://blog.natbat.co.uk/archive/2003/Jun/14/time_since
""" """
assert(isinstance(timestamp, datetime.datetime))
chunks = ( chunks = (
(60 * 60 * 24 * 365, lambda n: N_('year', 'years', n)), (60 * 60 * 24 * 365, lambda n: N_('year', 'years', n)),
(60 * 60 * 24 * 30, lambda n: N_('month', 'months', 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 * 24, lambda n: N_('day', 'days', n)),
(60 * 60, lambda n: N_('hour', 'hours', n)), (60 * 60, lambda n: N_('hour', 'hours', n)),
(60, lambda n: N_('minute', 'minutes', 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() now = datetime.datetime.utcnow()

12
mitterlib/ui/ui_pygtk.py

@ -24,7 +24,6 @@ gobject.threads_init()
import logging import logging
import urllib2 import urllib2
import webbrowser
import gettext import gettext
from mitterlib.ui.helpers.image_helpers import find_image from mitterlib.ui.helpers.image_helpers import find_image
@ -84,8 +83,7 @@ class Interface(object):
(menu, toolbar, accelerators) = self._create_menu_and_toolbar() (menu, toolbar, accelerators) = self._create_menu_and_toolbar()
self._update_field = UpdateBox( self._update_field = UpdateBox(
self._images['avatar'], self._images['avatar'],
self._options[self.NAMESPACE]['spell_check'] self._options[self.NAMESPACE]['spell_check'])
)
self._statusbar = self._create_statusbar() self._statusbar = self._create_statusbar()
# the messages grid # the messages grid
@ -299,7 +297,8 @@ class Interface(object):
view_messages_action = gtk.Action('Messages', _('_Messages'), view_messages_action = gtk.Action('Messages', _('_Messages'),
_('Display messages'), None) _('Display messages'), None)
view_messages_action.connect('activate', self._change_tab, 0) view_messages_action.connect('activate', self._change_tab, 0)
self._action_group.add_action_with_accel(view_messages_action, '<Alt>1') self._action_group.add_action_with_accel(view_messages_action,
'<Alt>1')
view_replies_action = gtk.Action('Replies', _('_Replies'), view_replies_action = gtk.Action('Replies', _('_Replies'),
_('Display replies'), None) _('Display replies'), None)
@ -322,7 +321,6 @@ class Interface(object):
return (main_menu, main_toolbar, uimanager.get_accel_group()) return (main_menu, main_toolbar, uimanager.get_accel_group())
def _create_statusbar(self): def _create_statusbar(self):
"""Create the statusbar.""" """Create the statusbar."""
statusbar = gtk.Statusbar() statusbar = gtk.Statusbar()
@ -361,7 +359,6 @@ class Interface(object):
# ------------------------------------------------------------ # ------------------------------------------------------------
# Helper functions # Helper functions
# ------------------------------------------------------------ # ------------------------------------------------------------
def _update_statusbar(self, message): def _update_statusbar(self, message):
"""Update the statusbar with the message.""" """Update the statusbar with the message."""
self._statusbar.pop(self._statusbar_context) self._statusbar.pop(self._statusbar_context)
@ -397,8 +394,7 @@ class Interface(object):
'message_count': str(messages), 'message_count': str(messages),
'message': N_('message', 'messages', messages), 'message': N_('message', 'messages', messages),
'replies_count': str(replies), 'replies_count': str(replies),
'replies': N_('reply', 'replies', replies) 'replies': N_('reply', 'replies', replies)}
}
mask = self._options[self.NAMESPACE]['window_title'] mask = self._options[self.NAMESPACE]['window_title']
for variable in title_info: for variable in title_info:
mask = mask.replace('{' + variable + '}', title_info[variable]) mask = mask.replace('{' + variable + '}', title_info[variable])

4
utils/pep8.py

@ -115,7 +115,6 @@ args = None
# Plugins (check functions) for physical lines # Plugins (check functions) for physical lines
############################################################################## ##############################################################################
def tabs_or_spaces(physical_line, indent_char): def tabs_or_spaces(physical_line, indent_char):
""" """
Never mix tabs and spaces. Never mix tabs and spaces.
@ -191,7 +190,6 @@ def maximum_line_length(physical_line):
# Plugins (check functions) for logical lines # Plugins (check functions) for logical lines
############################################################################## ##############################################################################
def blank_lines(logical_line, blank_lines, indent_level, line_number, def blank_lines(logical_line, blank_lines, indent_level, line_number,
previous_logical): previous_logical):
""" """
@ -404,7 +402,6 @@ def python_3000_raise_comma(logical_line):
# Helper functions # Helper functions
############################################################################## ##############################################################################
def expand_indent(line): def expand_indent(line):
""" """
Return the amount of indentation. Return the amount of indentation.
@ -436,7 +433,6 @@ def expand_indent(line):
# Framework to run all checks # Framework to run all checks
############################################################################## ##############################################################################
def message(text): def message(text):
"""Print a message.""" """Print a message."""
# print >> sys.stderr, options.prog + ': ' + text # print >> sys.stderr, options.prog + ': ' + text

Loading…
Cancel
Save