From: Josh Roesslein Date: Thu, 30 Jul 2009 05:17:24 +0000 (-0500) Subject: Fixed status source parsing. Status.source -> source name Status.source_url -> url X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9cdfe04f8b3f0da3dd46ad0610fd7c1f0300fec2;p=tweepy.git Fixed status source parsing. Status.source -> source name Status.source_url -> url --- diff --git a/tweepy/parsers.py b/tweepy/parsers.py index 71ec6df..e54b3c6 100644 --- a/tweepy/parsers.py +++ b/tweepy/parsers.py @@ -21,6 +21,14 @@ def _parse_search_datetime(str): return datetime.strptime(str, '%a, %d %b %Y %H:%M:%S +0000') +def _parse_html_value(html): + + return html[html.find('>')+1:html.rfind('<')] + +def _parse_a_href(atag): + + return atag[atag.find('"')+1:atag.find('>')-1] + def _parse_user(obj, api): user = api.classes['user']() @@ -54,6 +62,9 @@ def _parse_status(obj, api): setattr(status, k, _parse_user(v, api)) elif k == 'created_at': setattr(status, k, _parse_datetime(v)) + elif k == 'source': + setattr(status, k, _parse_html_value(v)) + setattr(status, 'source_url', _parse_a_href(v)) else: setattr(status, k, v) return status