Browse Source

Removed tailing spaces

master
Julio Biason 15 years ago
parent
commit
5d4f84d5bc
  1. 6
      mitterlib/network/__init__.py
  2. 14
      mitterlib/network/networkbase.py
  3. 18
      mitterlib/network/twitter.py
  4. 92
      mitterlib/ui/ui_pygtk.py

6
mitterlib/network/__init__.py

@ -196,7 +196,7 @@ class Networks(object):
data = self.networks[network].message(message_id) data = self.networks[network].message(message_id)
data.network = network data.network = network
return data return data
def replies(self, network=None): def replies(self, network=None):
"""Return a list of NetworkData objects for the replies for the user """Return a list of NetworkData objects for the replies for the user
@ -225,11 +225,11 @@ class Networks(object):
def can_delete(self, message): def can_delete(self, message):
"""Return True if the message can be deleted; False otherwise.""" """Return True if the message can be deleted; False otherwise."""
return self.networks[message.network].can_delete(message) return self.networks[message.network].can_delete(message)
def can_reply(self, message): def can_reply(self, message):
"""Return True if the message can be replied; False otherwise.""" """Return True if the message can be replied; False otherwise."""
return self.networks[message.network].can_reply(message) return self.networks[message.network].can_reply(message)
def can_repost(self, message): def can_repost(self, message):
"""Return True if the message can be resposted; False otherwise.""" """Return True if the message can be resposted; False otherwise."""
return self.networks[message.network].can_repost(message) return self.networks[message.network].can_repost(message)

14
mitterlib/network/networkbase.py

@ -129,7 +129,7 @@ class NetworkData(object):
**parent** **parent**
The parent of this message, in case of a reply. The parent of this message, in case of a reply.
**reposted_by** **reposted_by**
Username friend of the current user that reposted that message. Some Username friend of the current user that reposted that message. Some
networks will return the original user in a separate table (Twitter, networks will return the original user in a separate table (Twitter,
@ -196,7 +196,7 @@ class NetworkBase(object):
:class:`Networks` won't send requests to networks that return False to :class:`Networks` won't send requests to networks that return False to
this function.""" this function."""
return False return False
def messages(self): def messages(self):
"""Return a list of :class:`NetworkData` objects for the main """Return a list of :class:`NetworkData` objects for the main
"timeline" (the default list presented to the user.)""" "timeline" (the default list presented to the user.)"""
@ -211,9 +211,9 @@ class NetworkBase(object):
# TODO: All networks will return an id? If so, what we do with it # TODO: All networks will return an id? If so, what we do with it
# anyway? # anyway?
return None return None
def repost(self, message): def repost(self, message):
"""Repost a message in your current timeline. *message* must be a """Repost a message in your current timeline. *message* must be a
valid :class:`NetworkData` object. Must return the id of the new valid :class:`NetworkData` object. Must return the id of the new
message.""" message."""
# TODO: All networks will return an id? If so, what we do with it # TODO: All networks will return an id? If so, what we do with it
@ -241,15 +241,15 @@ class NetworkBase(object):
capped. If such limitation doesn't exist for the network, a negative capped. If such limitation doesn't exist for the network, a negative
number should be returned.""" number should be returned."""
return -1 return -1
def can_delete(self, message): def can_delete(self, message):
"""Return True if the message can be deleted; False otherwise.""" """Return True if the message can be deleted; False otherwise."""
return False; return False;
def can_reply(self, message): def can_reply(self, message):
"""Return True if the message can be replied; False otherwise.""" """Return True if the message can be replied; False otherwise."""
return False; return False;
def can_repost(self, message): def can_repost(self, message):
"""Return True if the message can be resposted; False otherwise.""" """Return True if the message can be resposted; False otherwise."""
return False; return False;

18
mitterlib/network/twitter.py

@ -119,15 +119,15 @@ class TwitterNetworkData(NetworkData):
if 'in_reply_to_status_id' in data and data['in_reply_to_status_id']: if 'in_reply_to_status_id' in data and data['in_reply_to_status_id']:
self.parent = int(data['in_reply_to_status_id']) self.parent = int(data['in_reply_to_status_id'])
if 'retweeted_status' in data: if 'retweeted_status' in data:
self.reposted_by = self.username self.reposted_by = self.username
retweet_user = data['retweeted_status']['user'] retweet_user = data['retweeted_status']['user']
self.name = retweet_user['name'] self.name = retweet_user['name']
self.username = retweet_user['screen_name'] self.username = retweet_user['screen_name']
self.avatar = retweet_user['profile_image_url'] self.avatar = retweet_user['profile_image_url']
# also switch the text for the original text. # also switch the text for the original text.
data['text'] = data['retweeted_status']['text'] data['text'] = data['retweeted_status']['text']
@ -154,7 +154,7 @@ class Connection(NetworkBase):
return True return True
else: else:
return False return False
def __init__(self, options): def __init__(self, options):
self._options = options self._options = options
@ -242,7 +242,7 @@ class Connection(NetworkBase):
# #
# New network style methods # New network style methods
# #
AUTH = [ AUTH = [
{'name': 'username', {'name': 'username',
'flags': ['-u', '--username'], 'flags': ['-u', '--username'],
@ -415,17 +415,17 @@ class Connection(NetworkBase):
_log.debug('Delete response: %s', response) _log.debug('Delete response: %s', response)
return True # Either we get a response or an exception before we reach return True # Either we get a response or an exception before we reach
# this. # this.
def can_delete(self, message): def can_delete(self, message):
"""Check if the message belongs to the user. If so, returns True; """Check if the message belongs to the user. If so, returns True;
False otherwise.""" False otherwise."""
return (message.username == self._options[self.NAMESPACE]['username']) return (message.username == self._options[self.NAMESPACE]['username'])
def can_reply(self, message): def can_reply(self, message):
"""Always return True; Twitter allows replying to any messages, """Always return True; Twitter allows replying to any messages,
including the ones from the user.""" including the ones from the user."""
return True; return True;
def can_repost(self, message): def can_repost(self, message):
"""Always return True; Twitter allows reposting (retweeting) to """Always return True; Twitter allows reposting (retweeting) to
any messages, including the ones from the user.""" any messages, including the ones from the user."""

92
mitterlib/ui/ui_pygtk.py

@ -283,7 +283,7 @@ class Interface(object):
def _create_menu_and_toolbar(self): def _create_menu_and_toolbar(self):
"""Create the main menu and the toolbar.""" """Create the main menu and the toolbar."""
# UI elements # UI elements
ui_elements = ''' ui_elements = '''
<ui> <ui>
@ -336,20 +336,20 @@ class Interface(object):
edit_action = gtk.Action('Edit', '_Edit', 'Edit', None) edit_action = gtk.Action('Edit', '_Edit', 'Edit', None)
action_group.add_action(edit_action) action_group.add_action(edit_action)
message_action = gtk.Action('Message', '_Message', message_action = gtk.Action('Message', '_Message',
'Message related options', None) 'Message related options', None)
action_group.add_action(message_action) action_group.add_action(message_action)
help_action = gtk.Action('Help', '_Help', 'Help', None) help_action = gtk.Action('Help', '_Help', 'Help', None)
action_group.add_action(help_action) action_group.add_action(help_action)
# File actions # File actions
quit_action = gtk.Action('Quit', '_Quit', quit_action = gtk.Action('Quit', '_Quit',
'Exit Mitter', gtk.STOCK_QUIT) 'Exit Mitter', gtk.STOCK_QUIT)
quit_action.connect('activate', self._quit_app) quit_action.connect('activate', self._quit_app)
action_group.add_action_with_accel(quit_action, None) action_group.add_action_with_accel(quit_action, None)
# Edit actions # Edit actions
refresh_action = gtk.Action('Refresh', '_Refresh', refresh_action = gtk.Action('Refresh', '_Refresh',
'Update the listing', gtk.STOCK_REFRESH) 'Update the listing', gtk.STOCK_REFRESH)
@ -362,15 +362,15 @@ class Interface(object):
self._update_action.connect('activate', self._update_status) self._update_action.connect('activate', self._update_status)
action_group.add_action_with_accel(self._update_action, action_group.add_action_with_accel(self._update_action,
'<Ctrl>Return') '<Ctrl>Return')
self._cancel_action = gtk.Action('Cancel', '_Cancel', self._cancel_action = gtk.Action('Cancel', '_Cancel',
'Cancel the update', gtk.STOCK_CANCEL) 'Cancel the update', gtk.STOCK_CANCEL)
self._cancel_action.set_property('sensitive', False) self._cancel_action.set_property('sensitive', False)
self._cancel_action.connect('activate', self._clear_text) self._cancel_action.connect('activate', self._clear_text)
action_group.add_action_with_accel(self._cancel_action, action_group.add_action_with_accel(self._cancel_action,
'<Ctrl>Escape') '<Ctrl>Escape')
clear_action = gtk.Action('Clear', '_Clear', clear_action = gtk.Action('Clear', '_Clear',
'Clear the message list', gtk.STOCK_CLEAR) 'Clear the message list', gtk.STOCK_CLEAR)
clear_action.connect('activate', self._clear_posts) clear_action.connect('activate', self._clear_posts)
action_group.add_action_with_accel(clear_action, None) action_group.add_action_with_accel(clear_action, None)
@ -389,22 +389,22 @@ class Interface(object):
'Settings', gtk.STOCK_PREFERENCES) 'Settings', gtk.STOCK_PREFERENCES)
#settings_action.connect('activate', self.show_settings) #settings_action.connect('activate', self.show_settings)
action_group.add_action(settings_action) action_group.add_action(settings_action)
# Message actions # Message actions
self._delete_action = gtk.Action('Delete', '_Delete', self._delete_action = gtk.Action('Delete', '_Delete',
'Delete a post', gtk.STOCK_DELETE) 'Delete a post', gtk.STOCK_DELETE)
self._delete_action.set_property('sensitive', False) self._delete_action.set_property('sensitive', False)
self._delete_action.connect('activate', self._delete_message) self._delete_action.connect('activate', self._delete_message)
action_group.add_action_with_accel(self._delete_action, 'Delete') action_group.add_action_with_accel(self._delete_action, 'Delete')
self._reply_action = gtk.Action('Reply', '_Reply', self._reply_action = gtk.Action('Reply', '_Reply',
"Send a response to someone's else message", gtk.STOCK_REDO) "Send a response to someone's else message", gtk.STOCK_REDO)
self._reply_action.set_property('sensitive', False) self._reply_action.set_property('sensitive', False)
self._reply_action.connect('activate', self._reply_message) self._reply_action.connect('activate', self._reply_message)
action_group.add_action_with_accel(self._reply_action, '<Ctrl>r') action_group.add_action_with_accel(self._reply_action, '<Ctrl>r')
self._repost_action = gtk.Action('Repost', 'Re_post', self._repost_action = gtk.Action('Repost', 'Re_post',
"Put someone's else message on your timeline", "Put someone's else message on your timeline",
gtk.STOCK_CONVERT) gtk.STOCK_CONVERT)
self._repost_action.set_property('sensitive', False) self._repost_action.set_property('sensitive', False)
# TODO: Connect # TODO: Connect
@ -438,27 +438,27 @@ class Interface(object):
self._update_button = gtk.Button(label='Send') self._update_button = gtk.Button(label='Send')
self._update_button.connect('clicked', self._update_status) self._update_button.connect('clicked', self._update_status)
self._update_button.set_property('sensitive', False) self._update_button.set_property('sensitive', False)
self._cancel_button = gtk.Button(label='Cancel') self._cancel_button = gtk.Button(label='Cancel')
self._cancel_button.connect('clicked', self._clear_text) self._cancel_button.connect('clicked', self._clear_text)
self._cancel_button.set_property('sensitive', False) self._cancel_button.set_property('sensitive', False)
info_box = gtk.HBox(True, 0) info_box = gtk.HBox(True, 0)
self._count_label = gtk.Label() self._count_label = gtk.Label()
self._count_label.set_justify(gtk.JUSTIFY_LEFT) self._count_label.set_justify(gtk.JUSTIFY_LEFT)
self._reply_label = gtk.Label() self._reply_label = gtk.Label()
info_box.pack_start(self._count_label, expand=True, fill=True) info_box.pack_start(self._count_label, expand=True, fill=True)
info_box.pack_start(self._reply_label, expand=True, fill=True) info_box.pack_start(self._reply_label, expand=True, fill=True)
self._count_chars(text_buffer) self._count_chars(text_buffer)
update_box = gtk.HBox(False, 0) update_box = gtk.HBox(False, 0)
update_box.pack_start(self._update_text, expand=True, fill=True, update_box.pack_start(self._update_text, expand=True, fill=True,
padding=0) padding=0)
update_box.pack_start(self._update_button, expand=False, fill=False, update_box.pack_start(self._update_button, expand=False, fill=False,
padding=0) padding=0)
update_box.pack_start(self._cancel_button, expand=False, fill=False, update_box.pack_start(self._cancel_button, expand=False, fill=False,
padding=0) padding=0)
update_area = gtk.VBox(True, 0) update_area = gtk.VBox(True, 0)
@ -579,7 +579,7 @@ class Interface(object):
markup = '<b>%s</b> <small>(%s)</small>:\n%s\n' \ markup = '<b>%s</b> <small>(%s)</small>:\n%s\n' \
'<small>%s</small>' % \ '<small>%s</small>' % \
(data.name, username, message, time) (data.name, username, message, time)
cell.set_property('markup', markup) cell.set_property('markup', markup)
return return
@ -604,7 +604,7 @@ class Interface(object):
self._cancel_button.set_property('sensitive', enabled) self._cancel_button.set_property('sensitive', enabled)
self._cancel_action.set_property('sensitive', enabled) self._cancel_action.set_property('sensitive', enabled)
return return
def _update_statusbar(self, message): def _update_statusbar(self, message):
"""Update the statusbar with the message.""" """Update the statusbar with the message."""
self._statusbar.push(self._statusbar_context, message) self._statusbar.push(self._statusbar_context, message)
@ -618,13 +618,13 @@ class Interface(object):
_log.debug('Dequeuing next refresh') _log.debug('Dequeuing next refresh')
gobject.source_remove(self._refresh_id) gobject.source_remove(self._refresh_id)
self._refresh_id = None self._refresh_id = None
# do the refresh # do the refresh
self._update_statusbar('Retrieving messages...') self._update_statusbar('Retrieving messages...')
self._threads.add_work(self._post_get_messages, self._threads.add_work(self._post_get_messages,
self._exception_get_messages, self._exception_get_messages,
self._connection.messages) self._connection.messages)
# queue the next auto-refresh # queue the next auto-refresh
interval = self._options[self.NAMESPACE]['refresh_interval'] interval = self._options[self.NAMESPACE]['refresh_interval']
_log.debug('Queueing next refresh in %d minutes', interval) _log.debug('Queueing next refresh in %d minutes', interval)
@ -632,13 +632,13 @@ class Interface(object):
interval * 60 * 1000, interval * 60 * 1000,
self._refresh, None) self._refresh, None)
return return
def _clear_reply(self): def _clear_reply(self):
"""Clear the info about a reply.""" """Clear the info about a reply."""
self._reply_message_id = None self._reply_message_id = None
self._reply_label.set_text('') self._reply_label.set_text('')
return return
def _clear_repost(self): def _clear_repost(self):
"""Clear the info about a repost.""" """Clear the info about a repost."""
self._repost_message_id = None self._repost_message_id = None
@ -677,11 +677,11 @@ class Interface(object):
status=status, status=status,
reply_to=self._reply_message_id) reply_to=self._reply_message_id)
return return
def _clear_text(self, widget): def _clear_text(self, widget):
"""Clear the text field.""" """Clear the text field."""
self._update_text.get_buffer().set_text('') self._update_text.get_buffer().set_text('')
self._delete_iter = None self._delete_iter = None
self._clear_reply() self._clear_reply()
self._clear_repost() self._clear_repost()
@ -753,35 +753,35 @@ class Interface(object):
(message2.message_time > message1.message_time): (message2.message_time > message1.message_time):
return 1 return 1
return 0 return 0
def _message_selected(self, view, user_data=None): def _message_selected(self, view, user_data=None):
"""Callback when a row in the list is selected. Mostly, we'll check """Callback when a row in the list is selected. Mostly, we'll check
if the message is from the logged user and we change de "sensitive" if the message is from the logged user and we change de "sensitive"
property of the message actions to reflect what the user can and property of the message actions to reflect what the user can and
cannot do.""" cannot do."""
(model, iter) = view.get_selection().get_selected() (model, iter) = view.get_selection().get_selected()
data = model.get_value(iter, 0) data = model.get_value(iter, 0)
self._delete_action.set_property('sensitive', self._delete_action.set_property('sensitive',
self._connection.can_delete(data)) self._connection.can_delete(data))
self._reply_action.set_property('sensitive', self._reply_action.set_property('sensitive',
self._connection.can_reply(data)) self._connection.can_reply(data))
self._repost_action.set_property('sensitive', self._repost_action.set_property('sensitive',
self._connection.can_repost(data)) self._connection.can_repost(data))
return 0 return 0
def _clear_posts(self, widget, user_data=None): def _clear_posts(self, widget, user_data=None):
"""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()
return return
def _delete_message(self, widget, user_data=None): def _delete_message(self, widget, user_data=None):
"""Delete a message.""" """Delete a message."""
(model, iter) = self._grid.get_selection().get_selected() (model, iter) = self._grid.get_selection().get_selected()
message = model.get_value(iter, 0) message = model.get_value(iter, 0)
self._update_statusbar('Deleting message...') self._update_statusbar('Deleting message...')
self._delete_iter = iter self._delete_iter = iter
_log.debug('Deleting messing %d', message.id) _log.debug('Deleting messing %d', message.id)
@ -799,13 +799,13 @@ class Interface(object):
self._reply_label.set_text('Replying to %s' % (message.username)) self._reply_label.set_text('Replying to %s' % (message.username))
self._reply_message_id = message self._reply_message_id = message
self._update_text.grab_focus() self._update_text.grab_focus()
return return
# ------------------------------------------------------------ # ------------------------------------------------------------
# Network related functions # Network related functions
# ------------------------------------------------------------ # ------------------------------------------------------------
### Results from the "messages" request ### Results from the "messages" request
def _post_get_messages(self, widget, results): def _post_get_messages(self, widget, results):
"""Function called after the data from the messages list is """Function called after the data from the messages list is
@ -879,7 +879,7 @@ class Interface(object):
_log.debug('Update error') _log.debug('Update error')
_log.debug(str(exception)) _log.debug(str(exception))
return return
### Results for the delete message call ### Results for the delete message call
def _post_delete_message(self, widget, data): def _post_delete_message(self, widget, data):
"""Called when the message is deleted successfully.""" """Called when the message is deleted successfully."""
@ -889,7 +889,7 @@ class Interface(object):
self._delete_iter = None self._delete_iter = None
self._update_statusbar('Message deleted.') self._update_statusbar('Message deleted.')
return return
def _exception_delete_message(self, widget, exception): def _exception_delete_message(self, widget, exception):
"""Called when the message cannot be deleted.""" """Called when the message cannot be deleted."""
_log.debug('Delete error') _log.debug('Delete error')
@ -930,9 +930,9 @@ class Interface(object):
self._delete_iter = None self._delete_iter = None
self._reply_message_id = None self._reply_message_id = None
self._repost_message_id = None self._repost_message_id = None
return return
def __call__(self): def __call__(self):
"""Call function; displays the interface. This method should appear on """Call function; displays the interface. This method should appear on
every interface.""" every interface."""

Loading…
Cancel
Save