From fdfacaf26f6259afd305afba1b7de221d60bcfd8 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Thu, 12 Aug 2010 14:20:14 +0000 Subject: Misc. pylint fixes --- (limited to 'src') diff --git a/src/sugar/activity/activity.py b/src/sugar/activity/activity.py index cb9805b..649d3ef 100644 --- a/src/sugar/activity/activity.py +++ b/src/sugar/activity/activity.py @@ -31,6 +31,7 @@ STABLE. """ # Copyright (C) 2006-2007 Red Hat, Inc. # Copyright (C) 2007-2009 One Laptop Per Child +# Copyright (C) 2010 Collabora Ltd. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -78,7 +79,6 @@ from sugar.graphics.alert import Alert from sugar.graphics.icon import Icon from sugar.datastore import datastore from sugar.session import XSMPClient -from sugar.presence import presenceservice from sugar import wm # support deprecated imports @@ -741,7 +741,8 @@ class Activity(Window, gtk.Container): self.shared_activity.invite( buddy, '', self._invite_response_cb) else: - logging.error('Cannot invite %s, no such buddy.', buddy_key) + logging.error('Cannot invite %s %s, no such buddy', + account_path, contact_id) def invite(self, account_path, contact_id): """Invite a buddy to join this Activity. @@ -923,7 +924,8 @@ class _ClientHandler(dbus.service.Object, DBusProperties): CHANNEL + '.TargetHandleType': CONNECTION_HANDLE_TYPE_CONTACT, } filter_dict = dbus.Dictionary(filters, signature='sv') - logging.debug('__get_filters_cb %r', dbus.Array([filter_dict], signature='a{sv}')) + logging.debug('__get_filters_cb %r', dbus.Array([filter_dict], + signature='a{sv}')) return dbus.Array([filter_dict], signature='a{sv}') @dbus.service.method(dbus_interface=CLIENT_HANDLER, diff --git a/src/sugar/bundle/activitybundle.py b/src/sugar/bundle/activitybundle.py index 673db67..aeec8be 100644 --- a/src/sugar/bundle/activitybundle.py +++ b/src/sugar/bundle/activitybundle.py @@ -72,7 +72,7 @@ class ActivityBundle(Bundle): self._parse_linfo(linfo_file) if self._local_name == None: - self._local_name = self._name + self._local_name = self._name def _get_manifest(self): if self._manifest is None: diff --git a/src/sugar/datastore/datastore.py b/src/sugar/datastore/datastore.py index 656afcc..3f5188e 100644 --- a/src/sugar/datastore/datastore.py +++ b/src/sugar/datastore/datastore.py @@ -140,7 +140,10 @@ class DSObject(object): def __init__(self, object_id, metadata=None, file_path=None): self._update_signal_match = None + self._object_id = None + self.set_object_id(object_id) + self._metadata = metadata self._file_path = file_path self._destroyed = False diff --git a/src/sugar/presence/activity.py b/src/sugar/presence/activity.py index 6d94089..0def0c8 100644 --- a/src/sugar/presence/activity.py +++ b/src/sugar/presence/activity.py @@ -1,4 +1,5 @@ # Copyright (C) 2007, Red Hat, Inc. +# Copyright (C) 2010 Collabora Ltd. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -97,6 +98,7 @@ class Activity(gobject.GObject): self.room_handle = room_handle self._join_command = None + self._share_command = None self._id = properties.get('id', None) self._color = properties.get('color', None) self._name = properties.get('name', None) @@ -692,7 +694,7 @@ class _JoinCommand(_BaseCommand): 'private': True, # don't appear in server room lists } props_to_set = [] - for ident, name, sig, flags in prop_specs: + for ident, name, sig_, flags in prop_specs: value = props.pop(name, None) if value is not None: if flags & PROPERTY_FLAG_WRITE: diff --git a/src/sugar/presence/buddy.py b/src/sugar/presence/buddy.py index 5ce8962..48b08f4 100644 --- a/src/sugar/presence/buddy.py +++ b/src/sugar/presence/buddy.py @@ -23,7 +23,6 @@ STABLE. import logging import gobject -import gtk import dbus import gconf from telepathy.interfaces import CONNECTION, \ @@ -52,14 +51,11 @@ class BaseBuddy(gobject.GObject): 'color': color (XXX what format), 'current-activity': (XXX dbus path?), 'owner': (XXX dbus path?), - 'icon': (XXX pixel data for an icon?) - See __gproperties__ """ __gtype_name__ = 'PresenceBaseBuddy' __gsignals__ = { - 'icon-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])), 'joined-activity': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([gobject.TYPE_PYOBJECT])), 'left-activity': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, @@ -72,7 +68,6 @@ class BaseBuddy(gobject.GObject): gobject.GObject.__init__(self) self._key = None - self._icon = None self._nick = None self._color = None self._current_activity = None @@ -80,20 +75,6 @@ class BaseBuddy(gobject.GObject): self._ip4_address = None self._tags = None - def destroy(self): - self._icon_changed_signal.remove() - self._joined_activity_signal.remove() - self._left_activity_signal.remove() - self._property_changed_signal.remove() - - def _get_properties_helper(self): - """Retrieve the Buddy's property dictionary from the service object - """ - props = self._buddy.GetProperties(byte_arrays=True) - if not props: - return {} - return props - def get_key(self): return self._key @@ -102,11 +83,6 @@ class BaseBuddy(gobject.GObject): key = gobject.property(type=str, getter=get_key, setter=set_key) - def get_icon(self): - raise NotImplementedError() - - icon = gobject.property(type=str, getter=get_icon) - def get_nick(self): return self._nick @@ -164,94 +140,6 @@ class BaseBuddy(gobject.GObject): """Retrieve our dbus object path""" return None - def _emit_icon_changed_signal(self, icon_data): - """Emit GObject signal when icon has changed""" - self._icon = str(icon_data) - self.emit('icon-changed') - return False - - def __icon_changed_cb(self, icon_data): - """Handle dbus signal by emitting a GObject signal""" - gobject.idle_add(self._emit_icon_changed_signal, icon_data) - - def __emit_joined_activity_signal(self, object_path): - """Emit activity joined signal with Activity object""" - self.emit('joined-activity', self._ps_new_object(object_path)) - return False - - def __joined_activity_cb(self, object_path): - """Handle dbus signal by emitting a GObject signal - - Stores the activity in activities dictionary as well - """ - if not self._activities.has_key(object_path): - self._activities[object_path] = self._ps_new_object(object_path) - gobject.idle_add(self._emit_joined_activity_signal, object_path) - - def _emit_left_activity_signal(self, object_path): - """Emit activity left signal with Activity object - - XXX this calls self._ps_new_object instead of self._ps_del_object, - which would seem to be the incorrect callback? - """ - self.emit('left-activity', self._ps_new_object(object_path)) - return False - - def __left_activity_cb(self, object_path): - """Handle dbus signal by emitting a GObject signal - - Also removes from the activities dictionary - """ - if self._activities.has_key(object_path): - del self._activities[object_path] - gobject.idle_add(self._emit_left_activity_signal, object_path) - - def _handle_property_changed_signal(self, prop_list): - """Emit property-changed signal with property dictionary - - Generates a property-changed signal with the results of - _get_properties_helper() - """ - self._properties = self._get_properties_helper() - # FIXME: don't leak unexposed property names - self.emit('property-changed', prop_list) - return False - - def __property_changed_cb(self, prop_list): - """Handle dbus signal by emitting a GObject signal""" - gobject.idle_add(self._handle_property_changed_signal, prop_list) - - def get_icon_pixbuf(self): - """Retrieve Buddy's icon as a GTK pixel buffer - - XXX Why aren't the icons coming in as SVG? - """ - if self.props.icon and len(self.props.icon): - pbl = gtk.gdk.PixbufLoader() - pbl.write(self.props.icon) - pbl.close() - return pbl.get_pixbuf() - else: - return None - - def get_joined_activities(self): - """Retrieve the set of all activities which this buddy has joined - - Uses the GetJoinedActivities method on the service - object to produce object paths, wraps each in an - Activity object. - - returns list of presence Activity objects - """ - try: - resp = self._buddy.GetJoinedActivities() - except dbus.exceptions.DBusException: - return [] - acts = [] - for item in resp: - acts.append(self._ps_new_object(item)) - return acts - class Buddy(BaseBuddy): __gtype_name__ = 'PresenceBuddy' @@ -316,8 +204,6 @@ class Buddy(BaseBuddy): def _update_properties(self, properties): if 'key' in properties: self.props.key = properties['key'] - if 'icon' in properties: - self.props.icon = properties['icon'] if 'color' in properties: self.props.color = properties['color'] if 'current-activity' in properties: -- cgit v0.9.1