From: Josh Roesslein Date: Sun, 13 Sep 2009 19:36:22 +0000 (-0500) Subject: Added rest of search API trending methods. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=40e82fdbcfbce2d140829d467b19685840c79b21;p=tweepy.git Added rest of search API trending methods. --- diff --git a/CHANGES b/CHANGES index af32436..8fca1c0 100644 --- a/CHANGES +++ b/CHANGES @@ -13,6 +13,8 @@ during upgrade will be listed here. + added new() method. shortcut for setting up new API instances example: API.new(auth='basic', username='testuser', password='testpass') + update_profile_image() and update_profile_background_image() method added. + + Added search API methods: + trends, trends_current, trends_daily, and trends_weekly + Streaming: + Update to new streaming API methods + New StreamListener class replacing callback function @@ -21,3 +23,5 @@ during upgrade will be listed here. when user is not followed. + python 2.5 import syntax error fixed + python 2.5 timeout support for streaming API ++ Changed indents from 2 to 4 spaces + diff --git a/README b/README index b419b07..9dd3cb0 100644 --- a/README +++ b/README @@ -30,7 +30,8 @@ Souce code: Gitorious: Github: -Mailinglist: tweepy@googlegroups.com (questions/feature request/bug reports/anything else) +Bug tracker: http://github.com/joshthecoder/tweepy/issues +Mailing list: tweepy@googlegroups.com Author: Joshua Roesslein License: MIT diff --git a/ROADMAP b/ROADMAP index 626fc6e..eccf70c 100644 --- a/ROADMAP +++ b/ROADMAP @@ -3,7 +3,7 @@ The plan of attack for the next version of Tweepy. 1.0 -> 1.0.1 ============ + changing profile and background images [DONE] -+ finish search api ++ finish search api [DONE] + autodetect authenticated user's ID [DONE] + make oauth handler more web app friendly + address file locking portability issues in file cache diff --git a/tweepy/api.py b/tweepy/api.py index cf22fb7..434645f 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -425,9 +425,33 @@ class API(object): return bind_api( host = 'search.' + self.host, path = '/trends.json', - parser = parse_trend_results + parser = parse_json )(self) + def trends_current(self, *args, **kargs): + return bind_api( + host = 'search.' + self.host, + path = '/trends/current.json', + parser = parse_json, + allowed_param = ['exclude'] + )(self, *args, **kargs) + + def trends_daily(self, *args, **kargs): + return bind_api( + host = "search." + self.host, + path = '/trends/daily.json', + parser = parse_json, + allowed_param = ['date', 'exclude'] + )(self, *args, **kargs) + + def trends_weekly(self, *args, **kargs): + return bind_api( + host = "search." + self.host, + path = '/trends/weekly.json', + parser = parse_json, + allowed_param = ['date', 'exclude'] + )(self, *args, **kargs) + def _pack_image(filename, max_size): """Pack image from file into multipart-formdata post body""" # image must be less than 700kb in size diff --git a/tweepy/parsers.py b/tweepy/parsers.py index e1dce1e..2731e9e 100644 --- a/tweepy/parsers.py +++ b/tweepy/parsers.py @@ -91,7 +91,9 @@ def _parse_status(obj, api): status._api = api for k, v in obj.items(): if k == 'user': - setattr(status, 'author', _parse_user(v, api)) + user = _parse_user(v, api) + setattr(status, 'author', user) + setattr(status, 'user', user) # DEPRECIATED elif k == 'created_at': setattr(status, k, _parse_datetime(v)) elif k == 'source': @@ -204,8 +206,3 @@ def parse_search_results(data, api): result_objects.append(_parse_search_result(obj, api)) return result_objects - -def parse_trend_results(data, api): - - return json.loads(data)['trends'] -