From: Josh Roesslein Date: Thu, 30 Jul 2009 03:11:04 +0000 (-0500) Subject: Implemented help/test endpoint. Condensed parsers that had duplicate code. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=4bcf872037a61e4d9d0235e557d0a377c0b89c15;p=tweepy.git Implemented help/test endpoint. Condensed parsers that had duplicate code. --- diff --git a/api.py b/api.py index b08cfbe..1a4c16a 100644 --- a/api.py +++ b/api.py @@ -165,7 +165,7 @@ class API(object): """Check if friendship exists""" exists_friendship = bind_api( path = '/friendships/exists.json', - parser = parse_bool, + parser = parse_json, allowed_param = ['user_a', 'user_b'] ) @@ -180,14 +180,14 @@ class API(object): """Get list of IDs of users the specified user is following""" friends_ids = bind_api( path = '/friends/ids.json', - parser = parse_ids, + parser = parse_json, allowed_param = ['id', 'user_id', 'screen_name', 'page'] ) """Get list of IDs of users following the specified user""" followers_ids = bind_api( path = '/followers/ids.json', - parser = parse_ids, + parser = parse_json, allowed_param = ['id', 'user_id', 'screen_name', 'page'] ) @@ -196,7 +196,7 @@ class API(object): try: return bind_api( path = '/account/verify_credentials.json', - parser = parse_verify_credentials, + parser = parse_return_true, require_auth = True)(self) except TweepError: return False @@ -204,7 +204,7 @@ class API(object): """Rate limit status""" rate_limit_status = bind_api( path = '/account/rate_limit_status.json', - parser = parse_rate_limit + parser = parse_json ) """Update delivery device""" @@ -323,7 +323,7 @@ class API(object): """Get list of ids of users that are blocked""" blocks_ids = bind_api( path = '/blocks/blocking/ids.json', - parser = parse_ids, + parser = parse_json, require_auth = True ) @@ -361,3 +361,9 @@ class API(object): require_auth = True )(self) + def test(self): + return bind_api( + path = '/help/test.json', + parser = parse_return_true + )(self) + diff --git a/parsers.py b/parsers.py index 825d208..6f9ed1f 100644 --- a/parsers.py +++ b/parsers.py @@ -124,22 +124,14 @@ def parse_saved_searches(data, api): saved_searches.append(_parse_saved_search(obj, api)) return saved_searches -def parse_bool(data, api): +def parse_json(data, api): return json.loads(data) -def parse_ids(data, api): - - return json.loads(data) - -def parse_verify_credentials(data, api): +def parse_return_true(data, api): return True -def parse_rate_limit(data, api): - - return json.loads(data) - def parse_none(data, api): return None