From 43bc5d4726ae0c78eebc278e200192fdc3eb5b0d Mon Sep 17 00:00:00 2001 From: Harmon Date: Sat, 2 Jan 2021 21:27:58 -0600 Subject: [PATCH] Remove parse_a_href and parse_html_value functions --- tweepy/models.py | 9 ++++++--- tweepy/utils.py | 10 ---------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/tweepy/models.py b/tweepy/models.py index 4e88f34..bafd910 100644 --- a/tweepy/models.py +++ b/tweepy/models.py @@ -5,7 +5,6 @@ from email.utils import parsedate_to_datetime from tweepy.mixins import Hashable -from tweepy.utils import parse_a_href, parse_html_value class ResultSet(list): @@ -101,8 +100,12 @@ class Status(Model, Hashable): setattr(status, k, parsedate_to_datetime(v)) elif k == 'source': if '<' in v: - setattr(status, k, parse_html_value(v)) - setattr(status, 'source_url', parse_a_href(v)) + # At this point, v should be of the format: + # {source} + setattr(status, k, v[v.find('>') + 1:v.rfind('<')]) + start = v.find('"') + 1 + end = v.find('"', start) + setattr(status, 'source_url', v[start:end]) else: setattr(status, k, v) setattr(status, 'source_url', None) diff --git a/tweepy/utils.py b/tweepy/utils.py index 793cf98..f93d14e 100644 --- a/tweepy/utils.py +++ b/tweepy/utils.py @@ -3,16 +3,6 @@ # See LICENSE for details. -def parse_html_value(html): - return html[html.find('>')+1:html.rfind('<')] - - -def parse_a_href(atag): - start = atag.find('"') + 1 - end = atag.find('"', start) - return atag[start:end] - - def list_to_csv(item_list): if item_list: return ','.join(map(str, item_list)) -- 2.25.1