Remove parse_a_href and parse_html_value functions
authorHarmon <Harmon758@gmail.com>
Sun, 3 Jan 2021 03:27:58 +0000 (21:27 -0600)
committerHarmon <Harmon758@gmail.com>
Sun, 3 Jan 2021 03:27:58 +0000 (21:27 -0600)
tweepy/models.py
tweepy/utils.py

index 4e88f34dc8702681bea8a8daeae724a7bba186de..bafd910ecca4a3c457c66a6fab17695e5e6550a1 100644 (file)
@@ -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:
+                    # <a href="{source_url}" rel="nofollow">{source}</a>
+                    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)
index 793cf982e7fd2ef533e29cd276cda7e5d6455fe2..f93d14ec9cf2f97f49b08c5f140aba20b2914eb2 100644 (file)
@@ -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))