Nothing major, just some things that tripped pylint.

r?

Regards
Morgan
From 29c07d9a113dafb4cba3665250f3cb3341393aa7 Mon Sep 17 00:00:00 2001
From: Morgan Collett <[EMAIL PROTECTED]>
Date: Tue, 4 Nov 2008 16:26:21 +0200
Subject: [PATCH] Pylint fixes

---
 src/buddy.py            |    3 ++-
 src/linklocal_plugin.py |   10 +++-------
 src/presenceservice.py  |   22 +++++++++++-----------
 src/server_plugin.py    |   21 +++++++++------------
 src/telepathy_plugin.py |    9 ++++-----
 5 files changed, 29 insertions(+), 36 deletions(-)

diff --git a/src/buddy.py b/src/buddy.py
index 1b2e4d6..3e8788d 100644
--- a/src/buddy.py
+++ b/src/buddy.py
@@ -974,7 +974,8 @@ class ShellOwner(GenericOwner):
         for (signal, cb) in (('IconChanged', self._icon_changed_cb),
                              ('ColorChanged', self._color_changed_cb),
                              ('NickChanged', self._nick_changed_cb),
-                             ('CurrentActivityChanged', self._cur_activity_changed_cb)):
+                             ('CurrentActivityChanged',
+                              self._cur_activity_changed_cb)):
             self._bus.add_signal_receiver(cb, signal_name=signal,
                 dbus_interface=self._SHELL_OWNER_INTERFACE,
                 bus_name=self._SHELL_SERVICE,
diff --git a/src/linklocal_plugin.py b/src/linklocal_plugin.py
index 250482d..eb44ca5 100644
--- a/src/linklocal_plugin.py
+++ b/src/linklocal_plugin.py
@@ -19,17 +19,13 @@
 # Standard library
 import logging
 from itertools import izip
-from string import hexdigits
 
 # Other libraries
 import gobject
 from dbus import SystemBus
-from telepathy.client import (ConnectionManager, Connection)
-from telepathy.interfaces import (CONN_MGR_INTERFACE, CONN_INTERFACE,
-    CHANNEL_INTERFACE_GROUP)
-from telepathy.constants import (HANDLE_TYPE_CONTACT,
-    CONNECTION_STATUS_CONNECTED, CONNECTION_STATUS_DISCONNECTED,
-    CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES)
+from telepathy.client import Connection
+from telepathy.interfaces import CONN_INTERFACE
+from telepathy.constants import HANDLE_TYPE_CONTACT
 
 # Presence Service local modules
 import psutils
diff --git a/src/presenceservice.py b/src/presenceservice.py
index 88e2904..e68bded 100644
--- a/src/presenceservice.py
+++ b/src/presenceservice.py
@@ -25,12 +25,11 @@ import dbus.service
 import gobject
 from dbus.gobject_service import ExportedGObject
 from dbus.mainloop.glib import DBusGMainLoop
-from telepathy.client import ManagerRegistry, Connection
-from telepathy.interfaces import (CONN_MGR_INTERFACE, CONN_INTERFACE,
-    CONN_INTERFACE_AVATARS, CONN_INTERFACE_ALIASING)
-from telepathy.constants import (CONNECTION_STATUS_CONNECTING,
-    CONNECTION_STATUS_CONNECTED,
-    CONNECTION_STATUS_DISCONNECTED)
+from telepathy.client import ManagerRegistry
+from telepathy.interfaces import (CONN_INTERFACE_AVATARS,
+                                  CONN_INTERFACE_ALIASING)
+from telepathy.constants import (CONNECTION_STATUS_CONNECTED,
+                                 CONNECTION_STATUS_DISCONNECTED)
 
 from sugar import util
 
@@ -142,7 +141,7 @@ class PresenceService(ExportedGObject):
     def owner(self):
         return self._owner
 
-    def _connection_disconnected_cb(self, foo=None):
+    def _connection_disconnected_cb(self, data=None):
         """Log event when D-Bus kicks us off the bus for some reason"""
         _logger.debug("Disconnected from session bus!!!")
 
@@ -158,7 +157,8 @@ class PresenceService(ExportedGObject):
                 self._ll_plugin.cleanup()
         else:
             self._tp_disconnected(plugin)
-            if plugin == self._server_plugin and self._ll_plugin and status == CONNECTION_STATUS_DISCONNECTED:
+            if plugin == self._server_plugin and self._ll_plugin and \
+               status == CONNECTION_STATUS_DISCONNECTED:
                 # For now, Gabble takes precedence over Salut to alleviate
                 # corner cases where laptops on mesh can't talk to ones on APs
                 if self._ll_plugin.status == CONNECTION_STATUS_DISCONNECTED:
@@ -578,8 +578,8 @@ class PresenceService(ExportedGObject):
             # Link-local plugin can connect only if the Server plugin isn't
             # connected
             if not self._server_plugin or \
-                    self._server_plugin.status != CONNECTION_STATUS_CONNECTED:
-                        plugin.start()
+               self._server_plugin.status != CONNECTION_STATUS_CONNECTED:
+                plugin.start()
 
         elif plugin == self._server_plugin:
             # Server plugin can always try to connect
@@ -684,7 +684,7 @@ class PresenceService(ExportedGObject):
                 and conn.object_path == tp_conn_path):
                 buddy = handles.get(handle)
                 if buddy is not None and buddy.props.valid:
-                        return buddy.object_path()
+                    return buddy.object_path()
                 # either the handle is invalid, or we don't have a Buddy
                 # object for that buddy because we don't have all their
                 # details yet
diff --git a/src/server_plugin.py b/src/server_plugin.py
index e2dcc83..625f608 100644
--- a/src/server_plugin.py
+++ b/src/server_plugin.py
@@ -17,20 +17,16 @@
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 # Standard library
-import base64
 import logging
-import os
 from itertools import izip
-from string import hexdigits
 import re
 import gconf
 
 # Other libraries
 import dbus
-import gobject
-from telepathy.client import (ConnectionManager, Connection, Channel)
-from telepathy.interfaces import (CONN_MGR_INTERFACE, CONN_INTERFACE,
-    CHANNEL_INTERFACE_GROUP, CHANNEL_TYPE_CONTACT_LIST)
+from telepathy.client import (Connection, Channel)
+from telepathy.interfaces import (CONN_INTERFACE, CHANNEL_INTERFACE_GROUP,
+    CHANNEL_TYPE_CONTACT_LIST)
 from telepathy.constants import (HANDLE_TYPE_CONTACT, HANDLE_TYPE_GROUP,
     CONNECTION_STATUS_CONNECTED, CONNECTION_STATUS_DISCONNECTED,
     CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES,
@@ -41,10 +37,10 @@ import psutils
 from telepathy_plugin import TelepathyPlugin
 
 
-
 _logger = logging.getLogger('s-p-s.server_plugin')
 
 _MUC_JID_RE = re.compile('[EMAIL PROTECTED]/.*')
+hexdigits = '0123456789abcdefABCDEF'
 
 class ServerPlugin(TelepathyPlugin):
     """Telepathy-python-based presence server interface
@@ -276,7 +272,7 @@ class ServerPlugin(TelepathyPlugin):
             HANDLE_TYPE_CONTACT, handles)
 
         for handle, jid in izip(handles, identifiers):
-            user, host = jid.split('@', 1)
+            host = jid.split('@', 1)[1]
             if self._server_is_trusted(host):
                 result.append(handle)
 
@@ -319,7 +315,8 @@ class ServerPlugin(TelepathyPlugin):
         if status == CONNECTION_STATUS_DISCONNECTED:
             if reason == CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED and \
                     not self._account['register']:
-                _logger.debug('Authentication failed. Trying to register the account')
+                _logger.debug(
+                    'Authentication failed. Trying to register the account')
                 self._account['register'] = True
                 self._stop()
                 self._init_connection()
@@ -376,9 +373,9 @@ class ServerPlugin(TelepathyPlugin):
         friends_handles = set()
         friends = set()
         for key in keys:
-            id = psutils.pubkey_to_keyid(key)
+            identity = psutils.pubkey_to_keyid(key)
             # this assumes that all our friends are on the same server as us
-            jid = '[EMAIL PROTECTED]' % (id, server)
+            jid = '[EMAIL PROTECTED]' % (identity, server)
             friends.add(jid)
 
         def error_syncing_friends(e):
diff --git a/src/telepathy_plugin.py b/src/telepathy_plugin.py
index 6eee900..982f7cc 100644
--- a/src/telepathy_plugin.py
+++ b/src/telepathy_plugin.py
@@ -32,8 +32,7 @@ from telepathy.constants import (CONNECTION_STATUS_DISCONNECTED,
     HANDLE_TYPE_CONTACT, HANDLE_TYPE_ROOM, HANDLE_TYPE_LIST)
 from telepathy.interfaces import (CONN_INTERFACE, CHANNEL_TYPE_TEXT,
         CHANNEL_TYPE_STREAMED_MEDIA, CHANNEL_INTERFACE_GROUP,
-        CONN_INTERFACE_PRESENCE, CONN_INTERFACE_AVATARS,
-        CONN_INTERFACE_ALIASING, CHANNEL_TYPE_CONTACT_LIST,
+        CONN_INTERFACE_PRESENCE, CHANNEL_TYPE_CONTACT_LIST,
         CONN_MGR_INTERFACE)
 from telepathy.errors import (InvalidArgument, InvalidHandle)
 
@@ -295,7 +294,6 @@ class TelepathyPlugin(gobject.GObject):
             if reason == CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED:
                 # FIXME: handle connection failure; retry later?
                 _logger.debug("%r: authentification failed. Give up ", self)
-                pass
             else:
                 # Try again later. We'll detect whether we have a network
                 # connection after the retry period elapses. The fact that
@@ -400,8 +398,9 @@ class TelepathyPlugin(gobject.GObject):
         except (InvalidArgument, InvalidHandle):
             # InspectHandles failed so discard invalid handles by trying to
             # inspect them one by one.
-            # FIXME: the Contacts interface should offer a proper way to do this.
-            jids = self._inspect_handles_one_by_one(HANDLE_TYPE_CONTACT, relevant)
+            # FIXME: the Contacts interface should offer a proper way to do this
+            jids = self._inspect_handles_one_by_one(HANDLE_TYPE_CONTACT,
+                                                    relevant)
             if not jids:
                 return
 
-- 
1.5.6.3

_______________________________________________
Sugar mailing list
[email protected]
http://lists.laptop.org/listinfo/sugar

Reply via email to