Browse Source

PEP8 fixed

master
Julio Biason 15 years ago
parent
commit
32f26f20d0
  1. 4
      mitterlib/__init__.py
  2. 3
      mitterlib/network/__init__.py
  3. 12
      mitterlib/network/networkbase.py
  4. 4
      mitterlib/network/twitter.py
  5. 1
      mitterlib/ui/__init__.py
  6. 1
      mitterlib/ui/helpers/console_utils.py
  7. 3
      mitterlib/ui/helpers/image_helpers.py
  8. 1
      mitterlib/ui/helpers/timesince.py
  9. 4
      mitterlib/ui/ui_cmd.py
  10. 7
      mitterlib/ui/ui_pygtk.py
  11. 3
      mitterlib/ui/ui_tty.py
  12. 7
      mitterlib/ui/ui_zork.py
  13. 6
      tests.py

4
mitterlib/__init__.py

@ -21,6 +21,7 @@ import os.path
import glob
import htmlentitydefs
def module_search(source, ignore):
"""Search for modules in the source directory. Ignore any modules
indicated."""
@ -39,6 +40,7 @@ def module_search(source, ignore):
# "importable"
yield module_name
def htmlize(text):
"""Convert accented characters to their HTML entities."""
new = []
@ -50,5 +52,3 @@ def htmlize(text):
else:
new.append(char)
return ''.join(new)

3
mitterlib/network/__init__.py

@ -32,7 +32,6 @@ SKIPPABLES = ('__init__.py', 'networkbase.py')
# Helper functions
#--------------------------------------------------------------------
def _import_name(module):
"""Based on the name of the module, return the proper "import"
statement."""
@ -44,7 +43,6 @@ def _import_name(module):
# Exceptions
#--------------------------------------------------------------------
class NetworksError(Exception):
"""Basic Networks exception."""
pass
@ -151,7 +149,6 @@ class Networks(object):
# This is basically a copy of all methods available in NetworkBase, with
# the additional parameter "network" (to request data from just one
# source)
def messages(self, network=None):
"""Return a list of NetworkData objects for the main "timeline" (the
default list presented to the user.)"""

12
mitterlib/network/networkbase.py

@ -44,7 +44,6 @@ def auth_options(namespace, options, auths):
# Exceptions
#--------------------------------------------------------------------
class NetworkError(Exception):
"""Base class for all network related exceptions."""
pass
@ -92,10 +91,12 @@ class NetworkPermissionDeniedError(NetworkError):
#--------------------------------------------------------------------
# Warnings
#--------------------------------------------------------------------
class NetworkWarning(Warning):
"""Base warning for networks."""
pass
class MessageTooLongWarning(NetworkWarning):
"""The message is too long for the network."""
pass
@ -104,7 +105,6 @@ class MessageTooLongWarning(NetworkWarning):
# The classes
#--------------------------------------------------------------------
class NetworkData(object):
"""Provides an uniform way to access information about posts. The
following fields should appear:
@ -143,6 +143,7 @@ class NetworkData(object):
worry about this field themselves; :class:`Networks` will set it when
merging information from all networks.
"""
def __init__(self):
self.id = ''
self.name = ''
@ -189,7 +190,6 @@ class NetworkBase(object):
if possible.
"""
def is_setup(self):
"""Should return a boolean indicating if the network have all
necessary options set up so it can retrieve information.
@ -244,12 +244,12 @@ class NetworkBase(object):
def can_delete(self, message):
"""Return True if the message can be deleted; False otherwise."""
return False;
return False
def can_reply(self, message):
"""Return True if the message can be replied; False otherwise."""
return False;
return False
def can_repost(self, message):
"""Return True if the message can be resposted; False otherwise."""
return False;
return False

4
mitterlib/network/twitter.py

@ -365,7 +365,6 @@ class Connection(NetworkBase):
_log.debug('Requests: %s', data)
return int(data['remaining_hits'])
def update(self, status, reply_to=None):
"""Update the user status."""
if len(status) > 140:
@ -423,7 +422,6 @@ class Connection(NetworkBase):
_log.debug('Delete response: %s', response)
return True # Either we get a response or an exception before we reach
# this.
def can_delete(self, message):
"""Check if the message belongs to the user. If so, returns True;
False otherwise."""
@ -432,7 +430,7 @@ class Connection(NetworkBase):
def can_reply(self, message):
"""Always return True; Twitter allows replying to any messages,
including the ones from the user."""
return True;
return True
def can_repost(self, message):
"""Twitter ignores retweets from the user."""

1
mitterlib/ui/__init__.py

@ -31,7 +31,6 @@ SKIPPABLES = ('__init__.py')
# Helper functions
#--------------------------------------------------------------------
def _import_name(module):
"""Based on the name of the module, return the proper "import"
statement."""

1
mitterlib/ui/helpers/console_utils.py

@ -189,6 +189,7 @@ def print_thread(thread_list, connection):
pos += 1
return
def make_retweet(message):
"""Creates the text for a reweet."""
if not message.message.lower().startswith('rt @'):

3
mitterlib/ui/helpers/image_helpers.py

@ -21,8 +21,9 @@ import os.path
import sys
import logging
def find_image(image_name):
"""Using the iamge_name, search in the common places. Return the path for
"""Using the image_name, search in the common places. Return the path for
the image or None if the image couldn't be found."""
# just because I'm a logging nut

1
mitterlib/ui/helpers/timesince.py

@ -26,7 +26,6 @@ import time
# http://code.djangoproject.com/browser/django/trunk/django/utils/timesince.py
# My version expects time to be given in UTC & returns timedelta from UTC.
def pluralize(singular, plural, count):
if count == 1:
return singular

4
mitterlib/ui/ui_cmd.py

@ -40,7 +40,6 @@ class Interface(cmd.Cmd):
# -----------------------------------------------------------------------
# Methods required by cmd.Cmd (our commands)
# -----------------------------------------------------------------------
def do_config(self, line=None):
"""Setup the networks."""
options = self._connection.settings()
@ -157,7 +156,6 @@ class Interface(cmd.Cmd):
# -----------------------------------------------------------------------
# Helper functions
# -----------------------------------------------------------------------
def _check_message(self, message_id):
"""Check if a message is valid in the current list."""
if message_id < 1 or message_id > len(self._messages):
@ -234,11 +232,9 @@ class Interface(cmd.Cmd):
(update_text, ', '.join(available)))
return
# -----------------------------------------------------------------------
# Methods required by the main Mitter code
# -----------------------------------------------------------------------
def __init__(self, connection, options):
"""Class initialization."""

7
mitterlib/ui/ui_pygtk.py

@ -67,6 +67,7 @@ class _IdleObject(gobject.GObject):
Override gobject.GObject to always emit signals in the main thread
by emmitting on an idle handler
"""
def __init__(self):
gobject.GObject.__init__(self)
@ -82,12 +83,11 @@ class _WorkerThread(threading.Thread, _IdleObject):
"completed": (
gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE,
(gobject.TYPE_PYOBJECT,)), # list/networkdata
(gobject.TYPE_PYOBJECT, )), # list/networkdata
"exception": (
gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE,
(gobject.TYPE_PYOBJECT,)) # The exception
}
(gobject.TYPE_PYOBJECT, ))} # The exception
def __init__(self, function, *args, **kwargs):
threading.Thread.__init__(self)
@ -669,7 +669,6 @@ class Interface(object):
return True
# ------------------------------------------------------------
# Widget callback functions
# ------------------------------------------------------------

3
mitterlib/ui/ui_tty.py

@ -35,7 +35,6 @@ class Interface(object):
# -----------------------------------------------------------------------
# Private functions
# -----------------------------------------------------------------------
def _config(self):
"""Set up the networks."""
options = self._connection.settings()
@ -75,11 +74,9 @@ class Interface(object):
return
# -----------------------------------------------------------------------
# Methods required by the main Mitter code
# -----------------------------------------------------------------------
def __init__(self, connection, options):
"""Class initialization."""
self._connection = connection

7
mitterlib/ui/ui_zork.py

@ -37,7 +37,6 @@ class Interface(cmd.Cmd):
# -----------------------------------------------------------------------
# Commands
# -----------------------------------------------------------------------
def do_config(self, line=None):
"""Setup the networks."""
options = self._connection.settings()
@ -127,9 +126,9 @@ class Interface(cmd.Cmd):
"""Update your status."""
if self._update(line):
print 'Status updated'
# clear the message so it's not send if the user press enter
# twice.
self.lastcmd = None
# So we don't send the same message if the user pressed enter
# again
def do_thread(self, line):
"""Display the conversation thread with the message pointed by the
@ -153,7 +152,6 @@ class Interface(cmd.Cmd):
# -----------------------------------------------------------------------
# Helper functions
# -----------------------------------------------------------------------
def _update(self, status, reply_to=None):
"""Send the update to the server."""
try:
@ -185,7 +183,6 @@ class Interface(cmd.Cmd):
# -----------------------------------------------------------------------
# Methods required by the main Mitter code
# -----------------------------------------------------------------------
def __init__(self, connection, options):
"""Class initialization."""

6
tests.py

@ -38,12 +38,12 @@ class TwitterEncodingTests(unittest.TestCase):
def setUp(self):
# Generate a set of options required for starting the Twitter
# connection.
options = ConfigOpt()
twitter.Connection.options(options)
self.connection = twitter.Connection(options)
# we don't call options(), so it won't load the options in the config
# file. If tests need to test specific options, they can change
# options directly.
options = ConfigOpt()
twitter.Connection.options(options)
self.connection = twitter.Connection(options)
def test_twitter_unhtml(self):
"""Test the _unhtml() function inside the Twitter."""

Loading…
Cancel
Save