Browse Source

American spelling from now on (don't ask me why)

master
Julio Biason 15 years ago
parent
commit
76c22f851d
  1. 8
      mitterlib/network/__init__.py
  2. 10
      mitterlib/network/networkbase.py
  3. 8
      mitterlib/network/twitter.py

8
mitterlib/network/__init__.py

@ -263,11 +263,11 @@ class Networks(object):
self._save() self._save()
return return
def favourite(self, message): def favouite(self, message):
"""Change the favourite status of the message.""" """Change the favorite status of the message."""
assert(isinstance(message, NetworkData)) assert(isinstance(message, NetworkData))
self._proxy() self._proxy()
self.networks[message.network].favourite(message) self.networks[message.network].favorite(message)
self._operations += 1 self._operations += 1
self._save() self._save()
return return
@ -319,4 +319,4 @@ class Networks(object):
for shortcut in self._targets(network): for shortcut in self._targets(network):
requests = self.networks[shortcut].available_requests() requests = self.networks[shortcut].available_requests()
result[shortcut] = requests result[shortcut] = requests
return result return result

10
mitterlib/network/networkbase.py

@ -139,8 +139,8 @@ class NetworkData(object):
"""Message timestamp (as a datetime object). Defaults to None. """Message timestamp (as a datetime object). Defaults to None.
*Optional*""" *Optional*"""
self.favourite = False self.favorite = False
"""Boolean indicating if the message was marked as "favourite" or not. """Boolean indicating if the message was marked as "favorite" or not.
*Optional*""" *Optional*"""
self.parent = None self.parent = None
@ -268,8 +268,8 @@ class NetworkBase(object):
# anyway? # anyway?
return None return None
def favourite(self, message): def favorite(self, message):
"""Toggle the favourite status of a message. *message* must be a valid """Toggle the favorite status of a message. *message* must be a valid
:class:`NetworkData` object. Returns True if the request was :class:`NetworkData` object. Returns True if the request was
successful or False otherwise.""" successful or False otherwise."""
# TODO: Again, if errors appear as exceptions, why return something? # TODO: Again, if errors appear as exceptions, why return something?
@ -301,4 +301,4 @@ class NetworkBase(object):
"""Return the number of requests the user can request before being """Return the number of requests the user can request before being
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

8
mitterlib/network/twitter.py

@ -144,7 +144,7 @@ class TwitterNetworkData(NetworkData):
self.protected = data['user']['protected'] self.protected = data['user']['protected']
if 'favorited' in data: if 'favorited' in data:
self.favourited = data['favorited'] self.favorited = data['favorited']
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']:
owner = NetworkUser() owner = NetworkUser()
@ -495,11 +495,11 @@ class Connection(NetworkBase):
data = self._request(resource, body=body) data = self._request(resource, body=body)
return TwitterNetworkData(data, self.user.username) return TwitterNetworkData(data, self.user.username)
def favourite(self, message): def favorite(self, message):
"""Mark a message as favourite.""" """Mark a message as favorite."""
assert(isinstance(message, NetworkData)) assert(isinstance(message, NetworkData))
body = urllib.urlencode({'id': message.id}) body = urllib.urlencode({'id': message.id})
if not message.favourite: if not message.favorite:
resource = '/favorites/create/%d.json' % (message.id) resource = '/favorites/create/%d.json' % (message.id)
else: else:
resource = '/favorites/destroy/%d.json' % (message.id) resource = '/favorites/destroy/%d.json' % (message.id)

Loading…
Cancel
Save