diff --git a/AUTHORS.rst b/AUTHORS.rst index 6cddac6..24bd911 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -27,7 +27,7 @@ Patches and Suggestions - `Jonathan Elsas `_, Fix for original Streaming API stub causing import errors. - `LuqueDaniel `_, Extended example code where necessary. - `Mesar Hameed `_, Commit to swap ``__getattr__`` trick for a more debuggable solution. -- `Remy DeCausemaker `_, PEP-8 contributions. +- `Remy DeCausemaker `_, PEP 8 contributions. - `mckellister `_ Twitter Spring 2012 Clean Up fixes to ``Exception`` raised by Twython (Rate Limits, etc). - `Tatz Tsuchiya `_, Fix for ``lambda`` scoping in key injection phase. - `Mohammed ALDOUB `_, Fixes for ``http/https`` access endpoints. @@ -35,7 +35,7 @@ Patches and Suggestions - `Terry Jones `_, Error cleanup and Exception processing in 2.3.0. - `Leandro Ferreira `_, Fix for double-encoding of search queries in 2.3.0. - `Chris Brown `_, Updated to use v1.1 endpoints over v1 -- `Virendra Rajput `_, Fixed unicode (json) encoding in twython.py 2.7.2. +- `Virendra Rajput `_, Fixed unicode (json) encoding in twython.py 2.7.2. - `Paul Solbach `_, fixed requirement for oauth_verifier - `Greg Nofi `_, fixed using built-in Exception attributes for storing & retrieving error message - `Jonathan Vanasco `_, Debugging support, error_code tracking, Twitter error API tracking, other fixes @@ -43,3 +43,14 @@ Patches and Suggestions - `Ruben Varela Rosa `_, Fixed search example - `Oleg Anashkin `_, streaming ``handlers`` functionality - `Luis Alberto Santana `_, Fixed issue where Twython was unnecessarily disabling compression +- `Cory Dolphin `_, Added retry_after attribute to TwythonRateLimitError +- `Natan L `_, Fixed typo in documentation +- `Cash Costello `_, Moved tests to use `responsoes`, fixed typos in documentation +- `Joe Cabrera `_, PEP 8 contributions +- `bsbkeven `_, Added `lookup_status` function to `endpoints.py` +- `drevicko `_, Added option to yield full page vs individual results in `cursor` +- `Filipe A Ximenes `_, Added `upload_media` function to `endpoints.py` +- `Mertcan Mermerkaya `_, Fixed code example in documentation +- `Donne Martin `_, Fixed typos in `README.rst` +- `Diego Allen `_, Add missing comma in documentation code snippet diff --git a/HISTORY.rst b/HISTORY.rst index 1259227..4454d4c 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,21 @@ History ------- +3.2.0 (2014-08-xx) +++++++++++++++++++ +- PEP8'd some code +- Added `lookup_status` function to `endpoints.py` +- Added keyword argument to `cursor` to return full pages rather than individual results +- `cursor` now uses while loop rather than recursion +- Fixed issue where Twython was unnecessarily disabling compression +- Using `responses` to mock API calls in tests +- Fixed some typos in documentation +- Added `retry_after` attribute to `TwythonRateLimitError` +- Added `upload_media` method to `Twython` in favor of `update_with_media` +- Deprecating `update_with_media` per Twitter API 1.1 (https://dev.twitter.com/rest/reference/post/statuses/update_with_media) +- Unpin `requests` and `requests-oauthlib` in `requirements.txt` + + 3.1.2 (2013-12-05) ++++++++++++++++++ diff --git a/docs/conf.py b/docs/conf.py index b0b98eb..a0f9ef4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -50,9 +50,9 @@ copyright = u'2013, Ryan McGrath' # built documents. # # The short X.Y version. -version = '3.1.2' +version = '3.2.0' # The full version, including alpha/beta/rc tags. -release = '3.1.2' +release = '3.2.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/requirements.txt b/requirements.txt index 917c31a..126cbe4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ coverage==3.6.0 -requests==2.1.0 -requests_oauthlib==0.4.0 +requests>=2.1.0 +requests_oauthlib>=0.4.0 python-coveralls==2.1.0 nose-cov==1.6 -responses==0.2.0 +responses==0.3.0 diff --git a/setup.py b/setup.py index e6c8e94..e203cc9 100755 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ except ImportError: from distutils.core import setup __author__ = 'Ryan McGrath ' -__version__ = '3.1.2' +__version__ = '3.2.0' packages = [ 'twython', @@ -23,7 +23,7 @@ if sys.argv[-1] == 'publish': setup( name='twython', version=__version__, - install_requires=['requests==2.1.0', 'requests_oauthlib==0.4.0'], + install_requires=['requests>=2.1.0', 'requests_oauthlib>=0.4.0'], author='Ryan McGrath', author_email='ryan@venodesigns.net', license=open('LICENSE').read(), diff --git a/tests/test_core.py b/tests/test_core.py index 98d3a47..1aa0eea 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -262,16 +262,16 @@ class TwythonAPITestCase(unittest.TestCase): """Test getting last specific header of the last API call works""" endpoint = 'statuses/home_timeline' url = self.get_url(endpoint) - self.register_response(responses.GET, url, adding_headers={'x-rate-limit-remaining': 37}) + self.register_response(responses.GET, url, adding_headers={'x-rate-limit-remaining': '37'}) self.api.get(endpoint) value = self.api.get_lastfunction_header('x-rate-limit-remaining') - self.assertEqual(37, value) + self.assertEqual('37', value) value2 = self.api.get_lastfunction_header('does-not-exist') self.assertIsNone(value2) - value3 = self.api.get_lastfunction_header('not-there-either', 96) - self.assertEqual(96, value3) + value3 = self.api.get_lastfunction_header('not-there-either', '96') + self.assertEqual('96', value3) def test_get_lastfunction_header_should_raise_error_when_no_previous_call(self): """Test attempting to get a header when no API call was made raises a TwythonError""" @@ -286,7 +286,7 @@ class TwythonAPITestCase(unittest.TestCase): self.api.get(endpoint) - self.assertEqual(b'gzip, deflate, compress', responses.calls[0].request.headers['Accept-Encoding']) + self.assertEqual(b'gzip, deflate', responses.calls[0].request.headers['Accept-Encoding']) # Static methods def test_construct_api_url(self): diff --git a/twython/__init__.py b/twython/__init__.py index e0920a6..a79667d 100644 --- a/twython/__init__.py +++ b/twython/__init__.py @@ -19,7 +19,7 @@ Questions, comments? ryan@venodesigns.net """ __author__ = 'Ryan McGrath ' -__version__ = '3.1.2' +__version__ = '3.2.0' from .api import Twython from .streaming import TwythonStreamer diff --git a/twython/api.py b/twython/api.py index 6e33904..0b421c3 100644 --- a/twython/api.py +++ b/twython/api.py @@ -9,6 +9,8 @@ Twitter Authentication, and miscellaneous methods that are useful when dealing with the Twitter API """ +import warnings + import requests from requests.auth import HTTPBasicAuth from requests_oauthlib import OAuth1, OAuth2 @@ -20,8 +22,6 @@ from .endpoints import EndpointsMixin from .exceptions import TwythonError, TwythonAuthError, TwythonRateLimitError from .helpers import _transparent_params -import warnings - warnings.simplefilter('always', TwythonDeprecationWarning) # For Python 2.7 > @@ -243,9 +243,12 @@ class Twython(EndpointsMixin, object): :rtype: dict """ + if endpoint.startswith('http://'): + raise TwythonError('api.twitter.com is restricted to SSL/TLS traffic.') + # In case they want to pass a full Twitter URL # i.e. https://api.twitter.com/1.1/search/tweets.json - if endpoint.startswith('http://') or endpoint.startswith('https://'): + if endpoint.startswith('https://'): url = endpoint else: url = '%s/%s.json' % (self.api_url % version, endpoint) diff --git a/twython/endpoints.py b/twython/endpoints.py index 9b6fca1..444a920 100644 --- a/twython/endpoints.py +++ b/twython/endpoints.py @@ -14,6 +14,10 @@ This map is organized the order functions are documented at: https://dev.twitter.com/docs/api/1.1 """ +import warnings + +from .advisory import TwythonDeprecationWarning + class EndpointsMixin(object): # Timelines @@ -118,6 +122,11 @@ class EndpointsMixin(object): https://dev.twitter.com/docs/api/1.1/post/statuses/update_with_media """ + warnings.warn( + 'This method is deprecated. You should use Twython.upload_media instead.', + TwythonDeprecationWarning, + stacklevel=2 + ) return self.post('statuses/update_with_media', params=params) def upload_media(self, **params):