From f53cb56a376716e2b2e3a78c91310d3abe3aa7d8 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Sun, 28 Mar 2010 00:52:43 -0300 Subject: [PATCH] Logged user information. --- mitterlib/network/__init__.py | 9 ++++++++- mitterlib/network/twitter.py | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/mitterlib/network/__init__.py b/mitterlib/network/__init__.py index aa55487..73d37ff 100644 --- a/mitterlib/network/__init__.py +++ b/mitterlib/network/__init__.py @@ -100,7 +100,14 @@ class Networks(object): return self._networks - def _targets(self, shortcut): + def user(self, network=None): + """Return a :class:`NetworkUser` representation for the logged user in + the requested network. If no network is selected, will return the + first found.""" + shortcut = self._targets(network).next() # need this due yield + return self.networks[shortcut].user + + def _targets(self, shortcut=None): """Select a network based on the shortcut. If the shortcut is None, returns all available network shortcuts.""" if shortcut: diff --git a/mitterlib/network/twitter.py b/mitterlib/network/twitter.py index 76449dc..6b74b45 100644 --- a/mitterlib/network/twitter.py +++ b/mitterlib/network/twitter.py @@ -192,7 +192,12 @@ class Connection(NetworkBase): return self._user user = self._request('/account/verify_credentials.json') - self._user = TwitterNetworkUser(user) + + self._user = NetworkUser() + self._user.name = user['name'] + self._user.username = user['screen_name'] + self._user.avatar = user['profile_image_url'] + _log.debug("User: %s" % (self._user)) return self._user