From: Bas Westerbaan Date: Thu, 17 Dec 2009 06:17:40 +0000 (-0600) Subject: API methods lists(), lists_memberships(), and lists_subscriptions now accept 'user... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=4278e6abce8a04cfbd56451ddfc95db1522d86cd;p=tweepy.git API methods lists(), lists_memberships(), and lists_subscriptions now accept 'user' parameter. Added helpers to User model for lists. Merged from bwesterb/tweepy @ f26e000ba04b57761578831792d7a7a1adfc8e41 Signed-off-by: Joshua --- diff --git a/CHANGELOG b/CHANGELOG index d2c5ca2..c0dcf8c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,11 @@ during upgrade will be listed here. =========================== + Models - Added some new helper methods to List model + - User model + - Added lists_memberships, lists_subscriptions, and lists helpers ++ API + - lists(), lists_memberships(), and lists_subscriptions() now + take an "user" parameter for specifying which user to query. 1.3 -> 1.4 [current] =========================== diff --git a/tweepy/api.py b/tweepy/api.py index cb2f871..36304e6 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -482,32 +482,26 @@ class API(object): require_auth = True )(self, *args, **kargs) - def lists(self, *args, **kargs): - return bind_api( - path = '/%s/lists.json' % self.auth.get_username(), - parser = parse_lists, - allowed_param = ['cursor'], - require_auth = True - )(self, *args, **kargs) - lists.pagination_mode = 'cursor' + lists = bind_api( + path = '/{user}/lists.json', + parser = parse_lists, + allowed_param = ['user', 'cursor'], + require_auth = True + ) - def lists_memberships(self, *args, **kargs): - return bind_api( - path = '/%s/lists/memberships.json' % self.auth.get_username(), - parser = parse_lists, - allowed_param = ['cursor'], - require_auth = True - )(self, *args, **kargs) - lists_memberships.pagination_mode = 'cursor' + lists_memberships = bind_api( + path = '/{user}/lists/memberships.json', + parser = parse_lists, + allowed_param = ['user', 'cursor'], + require_auth = True + ) - def lists_subscriptions(self, *args, **kargs): - return bind_api( - path = '/%s/lists/subscriptions.json' % self.auth.get_username(), - parser = parse_lists, - allowed_param = ['cursor'], - require_auth = True - )(self, *args, **kargs) - lists_subscriptions.pagination_mode = 'cursor' + lists_subscriptions = bind_api( + path = '/{user}/lists/subscriptions.json', + parser = parse_lists, + allowed_param = ['user', 'cursor'], + require_auth = True + ) list_timeline = bind_api( path = '/{owner}/lists/{slug}/statuses.json', diff --git a/tweepy/models.py b/tweepy/models.py index a8b9e43..259b4af 100644 --- a/tweepy/models.py +++ b/tweepy/models.py @@ -52,6 +52,15 @@ class User(Model): self._api.destroy_friendship(user_id=self.id) self.following = False + def lists_memberships(self): + return self._api.lists_memberships(user=self.screen_name) + + def lists_subscriptions(self): + return self._api.lists_subscriptions(user=self.screen_name) + + def lists(self): + return self._api.lists(user=self.screen_name) + class DirectMessage(Model):