Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.

Commit 76d224f

Browse files
authored
Merge pull request #394 from bear/feature/changes_to_tweet_counting
Changes to tweet counting
2 parents d3eb170 + 429d3cb commit 76d224f

24 files changed

Lines changed: 591 additions & 558 deletions

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ docs:
3535
$(MAKE) -C doc html
3636

3737
lint:
38-
flake8 twitter > violations.flake8.txt
38+
pycodestyle --config={toxinidir}/setup.cfg twitter tests
3939

4040
test: lint
4141
python setup.py test

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ You can install python-twitter using::
4444

4545
$ pip install python-twitter
4646

47-
47+
4848
If you are using python-twitter on Google App Engine, see `more information <GAE.rst>`_ about including 3rd party vendor library dependencies in your App Engine project.
4949

5050

doc/changes_to_tweet_counting.rst

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
REST API Changes
2+
=================
3+
4+
Information compiled on Sept 14, 2016.
5+
6+
``statuses/update`` Endpoint
7+
----------------------------
8+
9+
``auto_populate_reply_metadata``
10+
+++++++++++++++++++++++++++++++
11+
12+
* Default is ``false``
13+
14+
* Must have ``in_reply_to_status_id`` set.
15+
16+
* Unknown what happens if not set. Probably error (does it get posted?)
17+
18+
* If the status to which you're replying is deleted, tweet will fail to post.
19+
20+
``exclude_reply_user_ids``
21+
++++++++++++++++++++++++++
22+
23+
* List of ``user_ids`` to remove from result of ``auto_populate_reply_metadata``.
24+
25+
* Doesn't apply to the first ``user_id``.
26+
27+
* If you try to remove it, this will be silently ignored by Twitter.
28+
29+
``attachment_url``
30+
++++++++++++++++++
31+
32+
* Must be a status permalnk or a DM deep link.
33+
34+
* If it's anything else and included in this parameter, Twitter will return an error.
35+
36+
37+
Most Other Endpoints
38+
--------------------
39+
40+
``tweet_mode``
41+
++++++++++++++
42+
43+
* Any endpoint that returns a tweet will accept this param.
44+
45+
* Must be in ``['compat', 'extended']``
46+
47+
* If ``tweet_mode == 'compat'``, then no ``extended_tweet`` node in the json returned.
48+
49+
* If ``tweet_mode == 'extended'``, then you'll get the ``extended_tweet`` node.
50+
51+
52+
Errors
53+
------
54+
* 44 -> URL passed to attachment_url is invalid
55+
56+
* 385 -> Replied to deleted tweet or tweet not visible to you
57+
58+
* 386 -> Too many attachments types (ie a GIF + quote tweet)
59+
60+
61+
Streaming API
62+
=============
63+
64+
Everything is going to be compatibility mode for now; however **all** tweets with have an ``extended_tweet`` node, which will contain the new information. According to Twitter's documentation though, there's the possibility that this node may not exist. We should be careful about making assumptions here.
65+
66+
67+
Changes to Models
68+
=================
69+
70+
Classic tweet: tweet with length < 140 char.
71+
Extended tweet: tweet with extended entities and text > 140 chars.
72+
73+
Twitter doesn't say if extended tweet with a total length of < 140 characters will be considered a "Classic tweet". They also state that an extended tweet shall have "text content [that] exceeds 140 characters in length", however this is contradictory to earlier statements about total text length retaining a hard max at 140 characters.
74+
75+
There will be two rendering modes: Compatibility and Extended. If in compatibility mode and tweet is "classic", no changes to tweet JSON. If in Extended mode, the following will change:
76+
77+
* ``text`` -> truncated version of the extended tweet's text + "..." + permalink to tweet. (Twitter is mute on whether an extended tweet's with (text + @mentions + urls) < 140 characters will have the @mentions + urls put back in ``text`` field.)
78+
79+
* ``truncated`` -> gets set to ``True`` if extended tweet is rendered in compat mode.

doc/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@
5757
# built documents.
5858
#
5959
# The short X.Y version.
60-
version = '3.1'
60+
version = '3.2'
6161
# The full version, including alpha/beta/rc tags.
62-
release = '3.1'
62+
release = '3.2dev0'
6363

6464
# The language for content autogenerated by Sphinx. Refer to documentation
6565
# for a list of supported languages.

requirements.testing.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ pytest
77
pytest-cov
88
pytest-runner
99
mccabe
10-
flake8
1110
mock
1211
six
1312
coverage

setup.cfg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ ignore =
88
violations.flake8.txt
99

1010
[flake8]
11-
ignore = E111,E124,E126,E201,E202,E221,E241,E302,E501
11+
ignore = E111,E124,E126,E221,E501
1212

1313
[pep8]
14-
ignore = E111,E124,E126,E128,E201,E202,E221,E226,E241,E301,E302,E303,E402,E501,W291
15-
max-line-length = 160
14+
ignore = E111,E124,E126,E221,E501
15+
max-line-length = 100
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"contributors": null, "in_reply_to_status_id_str": null, "lang": "en", "source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>", "in_reply_to_user_id": null, "possibly_sensitive_appealable": false, "coordinates": null, "truncated": true, "retweet_count": 0, "retweeted": false, "possibly_sensitive": false, "in_reply_to_user_id_str": null, "entities": {"symbols": [], "user_mentions": [], "urls": [{"expanded_url": "https://twitter.com/i/web/status/782737772490600448", "indices": [117, 140], "url": "https://t.co/et3OTOxWSa", "display_url": "twitter.com/i/web/status/7\u2026"}], "hashtags": []}, "geo": null, "is_quote_status": false, "favorite_count": 0, "id_str": "782737772490600448", "id": 782737772490600448, "created_at": "Mon Oct 03 00:23:22 +0000 2016", "text": "has more details about these changes. Thanks for making more expressive!writing requirements to python_twitt pytho\u2026 https://t.co/et3OTOxWSa", "place": null, "in_reply_to_screen_name": null, "in_reply_to_status_id": null, "favorited": false, "user": {"follow_request_sent": false, "protected": true, "default_profile_image": true, "profile_sidebar_fill_color": "000000", "favourites_count": 1, "utc_offset": null, "has_extended_profile": false, "lang": "en", "profile_image_url": "http://abs.twimg.com/sticky/default_profile_images/default_profile_2_normal.png", "friends_count": 2, "profile_text_color": "000000", "geo_enabled": true, "profile_banner_url": "https://pbs.twimg.com/profile_banners/4012966701/1453123196", "verified": false, "listed_count": 1, "is_translator": false, "location": "", "entities": {"description": {"urls": []}}, "name": "notinourselves", "is_translation_enabled": false, "time_zone": null, "id_str": "4012966701", "profile_background_tile": false, "followers_count": 1, "profile_sidebar_border_color": "000000", "contributors_enabled": false, "following": false, "description": "", "url": null, "statuses_count": 84, "default_profile": false, "profile_link_color": "000000", "profile_image_url_https": "https://abs.twimg.com/sticky/default_profile_images/default_profile_2_normal.png", "notifications": false, "profile_background_image_url": "http://pbs.twimg.com/profile_background_images/736320724164448256/LgaAQoav.jpg", "screen_name": "notinourselves", "profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/736320724164448256/LgaAQoav.jpg", "id": 4012966701, "profile_use_background_image": true, "created_at": "Wed Oct 21 23:53:04 +0000 2015", "profile_background_color": "000000"}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"contributors": null, "in_reply_to_status_id_str": null, "lang": "en", "in_reply_to_user_id_str": null, "in_reply_to_user_id": null, "possibly_sensitive_appealable": false, "coordinates": null, "full_text": "has more details about these changes. Thanks for making more expressive!writing requirements to python_twitt python_twitter.egg-info/SOURCE https://t.co/JWSPztfoyt", "truncated": false, "retweet_count": 0, "retweeted": false, "possibly_sensitive": false, "entities": {"symbols": [], "media": [{"id_str": "782737766455119872", "type": "photo", "media_url_https": "https://pbs.twimg.com/media/CtzX2fnXEAAMAjK.jpg", "display_url": "pic.twitter.com/JWSPztfoyt", "sizes": {"large": {"w": 1024, "resize": "fit", "h": 1024}, "thumb": {"w": 150, "resize": "crop", "h": 150}, "small": {"w": 680, "resize": "fit", "h": 680}, "medium": {"w": 1024, "resize": "fit", "h": 1024}}, "expanded_url": "https://twitter.com/notinourselves/status/782737772490600448/photo/1", "indices": [141, 164], "id": 782737766455119872, "url": "https://t.co/JWSPztfoyt", "media_url": "http://pbs.twimg.com/media/CtzX2fnXEAAMAjK.jpg"}], "user_mentions": [], "urls": [], "hashtags": []}, "geo": null, "is_quote_status": false, "favorite_count": 0, "id_str": "782737772490600448", "extended_entities": {"media": [{"id_str": "782737766455119872", "type": "photo", "media_url_https": "https://pbs.twimg.com/media/CtzX2fnXEAAMAjK.jpg", "display_url": "pic.twitter.com/JWSPztfoyt", "sizes": {"large": {"w": 1024, "resize": "fit", "h": 1024}, "thumb": {"w": 150, "resize": "crop", "h": 150}, "small": {"w": 680, "resize": "fit", "h": 680}, "medium": {"w": 1024, "resize": "fit", "h": 1024}}, "expanded_url": "https://twitter.com/notinourselves/status/782737772490600448/photo/1", "indices": [141, 164], "id": 782737766455119872, "url": "https://t.co/JWSPztfoyt", "media_url": "http://pbs.twimg.com/media/CtzX2fnXEAAMAjK.jpg", "ext_alt_text": null}]}, "created_at": "Mon Oct 03 00:23:22 +0000 2016", "source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>", "place": null, "favorited": false, "in_reply_to_screen_name": null, "in_reply_to_status_id": null, "id": 782737772490600448, "display_text_range": [0, 140], "user": {"follow_request_sent": false, "protected": true, "default_profile_image": true, "profile_sidebar_fill_color": "000000", "favourites_count": 1, "utc_offset": null, "has_extended_profile": false, "lang": "en", "profile_image_url": "http://abs.twimg.com/sticky/default_profile_images/default_profile_2_normal.png", "friends_count": 2, "profile_text_color": "000000", "geo_enabled": true, "profile_banner_url": "https://pbs.twimg.com/profile_banners/4012966701/1453123196", "verified": false, "listed_count": 1, "is_translator": false, "location": "", "entities": {"description": {"urls": []}}, "name": "notinourselves", "is_translation_enabled": false, "time_zone": null, "id_str": "4012966701", "profile_background_tile": false, "followers_count": 1, "profile_sidebar_border_color": "000000", "contributors_enabled": false, "following": false, "description": "", "url": null, "statuses_count": 84, "default_profile": false, "profile_link_color": "000000", "profile_image_url_https": "https://abs.twimg.com/sticky/default_profile_images/default_profile_2_normal.png", "notifications": false, "profile_background_image_url": "http://pbs.twimg.com/profile_background_images/736320724164448256/LgaAQoav.jpg", "screen_name": "notinourselves", "profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/736320724164448256/LgaAQoav.jpg", "id": 4012966701, "profile_use_background_image": true, "created_at": "Wed Oct 21 23:53:04 +0000 2015", "profile_background_color": "000000"}}

tests/test_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
ACCESS_TOKEN_KEY = os.getenv('ACCESS_TOKEN_KEY', None)
1313
ACCESS_TOKEN_SECRET = os.getenv('ACCESS_TOKEN_SECRET', None)
1414

15+
1516
@unittest.skipIf(not CONSUMER_KEY and not CONSUMER_SECRET, "No tokens provided")
1617
class ApiTest(unittest.TestCase):
1718
def setUp(self):

0 commit comments

Comments
 (0)