From: Josh Roesslein Date: Mon, 6 Jul 2009 00:57:53 +0000 (-0500) Subject: Added show status endpoint. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=543ac3b6eb2407e92fc227bc565f973832476d2d;p=tweepy.git Added show status endpoint. --- diff --git a/api.py b/api.py index 9c48d0a..55280e3 100644 --- a/api.py +++ b/api.py @@ -48,4 +48,11 @@ class API(object): require_auth = True ) + """Show status""" + get_status = bind_api( + path = '/statuses/show.json', + parser = parse_status, + allowed_param = ['id'] + ) + api = API('jitterapp', 'josh1987') diff --git a/binder.py b/binder.py index 5c70488..8cd6380 100644 --- a/binder.py +++ b/binder.py @@ -6,18 +6,14 @@ from error import TweepError def bind_api(path, parser, allowed_param=None, method='GET', require_auth=False): - def _call(api, **kargs): + def _call(api, *args, **kargs): # If require auth, throw exception if credentials not provided if require_auth and not api._b64up: raise TweepError('Authentication required!') # Filter out unallowed parameters - if len(kargs) == 0: - parameters = None - elif allowed_param: + if allowed_param: parameters = dict((k,v) for k,v in kargs.items() if k in allowed_param) - else: - parameters = kargs # Open connection if api.secure: diff --git a/parsers.py b/parsers.py index b8866fc..a412d26 100644 --- a/parsers.py +++ b/parsers.py @@ -39,6 +39,10 @@ def _parse_status(obj, classes): setattr(status, k, v) return status +def parse_status(data, classes): + + return _parse_status(json.loads(data), classes) + def parse_statuses(data, classes): statuses = []