Revert removing unicode2utf8 and encode staticmethods
[ci skip]
This commit is contained in:
parent
c7bce9189f
commit
126305d93d
3 changed files with 19 additions and 11 deletions
|
|
@ -10,7 +10,6 @@ History
|
||||||
- Callback URL is optional in ``get_authentication_tokens`` to accomedate those using OOB authorization (non web clients)
|
- Callback URL is optional in ``get_authentication_tokens`` to accomedate those using OOB authorization (non web clients)
|
||||||
- Not part of the python package, but tests are now available along with Travis CI hooks
|
- Not part of the python package, but tests are now available along with Travis CI hooks
|
||||||
- Added ``__repr__`` definition for Twython, when calling only returning <Twython: APP_KEY>
|
- Added ``__repr__`` definition for Twython, when calling only returning <Twython: APP_KEY>
|
||||||
- Removed ``Twython.unicode2utf8`` and ``Twython.encode`` methods
|
|
||||||
- Cleaned up ``Twython.construct_api_url``, uses "transparent" parameters (see 4th bullet in this version for explaination)
|
- Cleaned up ``Twython.construct_api_url``, uses "transparent" parameters (see 4th bullet in this version for explaination)
|
||||||
|
|
||||||
2.9.1 (2013-05-04)
|
2.9.1 (2013-05-04)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
from .compat import basestring, is_py2, str
|
from .compat import basestring
|
||||||
|
|
||||||
|
|
||||||
def _transparent_params(_params):
|
def _transparent_params(_params):
|
||||||
|
|
@ -17,9 +17,3 @@ def _transparent_params(_params):
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
return params, files
|
return params, files
|
||||||
|
|
||||||
|
|
||||||
def _encode(value):
|
|
||||||
if is_py2 and isinstance(value, str):
|
|
||||||
value.encode('utf-8')
|
|
||||||
return value
|
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,10 @@ from requests_oauthlib import OAuth1
|
||||||
|
|
||||||
from . import __version__
|
from . import __version__
|
||||||
from .advisory import TwythonDeprecationWarning
|
from .advisory import TwythonDeprecationWarning
|
||||||
from .compat import json, urlencode, parse_qsl, quote_plus, str
|
from .compat import json, urlencode, parse_qsl, quote_plus, str, is_py2
|
||||||
from .endpoints import api_table
|
from .endpoints import api_table
|
||||||
from .exceptions import TwythonError, TwythonAuthError, TwythonRateLimitError
|
from .exceptions import TwythonError, TwythonAuthError, TwythonRateLimitError
|
||||||
from .helpers import _encode, _transparent_params
|
from .helpers import _transparent_params
|
||||||
|
|
||||||
warnings.simplefilter('always', TwythonDeprecationWarning) # For Python 2.7 >
|
warnings.simplefilter('always', TwythonDeprecationWarning) # For Python 2.7 >
|
||||||
|
|
||||||
|
|
@ -354,7 +354,7 @@ class Twython(object):
|
||||||
params = requests.utils.to_key_val_list(params)
|
params = requests.utils.to_key_val_list(params)
|
||||||
for (k, v) in params:
|
for (k, v) in params:
|
||||||
querystring.append(
|
querystring.append(
|
||||||
'%s=%s' % (_encode(k), quote_plus(_encode(v)))
|
'%s=%s' % (Twython.encode(k), quote_plus(Twython.encode(v)))
|
||||||
)
|
)
|
||||||
return '%s?%s' % (base_url, '&'.join(querystring))
|
return '%s?%s' % (base_url, '&'.join(querystring))
|
||||||
|
|
||||||
|
|
@ -393,3 +393,18 @@ class Twython(object):
|
||||||
|
|
||||||
for tweet in self.searchGen(search_query, **kwargs):
|
for tweet in self.searchGen(search_query, **kwargs):
|
||||||
yield tweet
|
yield tweet
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def unicode2utf8(text):
|
||||||
|
try:
|
||||||
|
if is_py2 and isinstance(text, str):
|
||||||
|
text = text.encode('utf-8')
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return text
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def encode(text):
|
||||||
|
if is_py2 and isinstance(text, (str)):
|
||||||
|
return Twython.unicode2utf8(text)
|
||||||
|
return str(text)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue