Resolving merge conflicts, because Ryan is an idiot
This commit is contained in:
commit
c16ec65915
1 changed files with 10 additions and 6 deletions
|
|
@ -63,6 +63,7 @@ class TwythonError(AttributeError):
|
||||||
"""
|
"""
|
||||||
def __init__(self, msg, error_code=None):
|
def __init__(self, msg, error_code=None):
|
||||||
self.msg = msg
|
self.msg = msg
|
||||||
|
self.error_code = error_code
|
||||||
|
|
||||||
if error_code is not None and error_code in twitter_http_status_codes:
|
if error_code is not None and error_code in twitter_http_status_codes:
|
||||||
self.msg = '%s: %s -- %s' % \
|
self.msg = '%s: %s -- %s' % \
|
||||||
|
|
@ -71,7 +72,7 @@ class TwythonError(AttributeError):
|
||||||
self.msg)
|
self.msg)
|
||||||
|
|
||||||
if error_code == 400 or error_code == 420:
|
if error_code == 400 or error_code == 420:
|
||||||
raise TwythonAPILimit(self.msg)
|
raise TwythonAPILimit( self.msg , error_code)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return repr(self.msg)
|
return repr(self.msg)
|
||||||
|
|
@ -83,8 +84,9 @@ class TwythonAPILimit(TwythonError):
|
||||||
docs if you're running into issues here, Twython does not concern itself with
|
docs if you're running into issues here, Twython does not concern itself with
|
||||||
this matter beyond telling you that you've done goofed.
|
this matter beyond telling you that you've done goofed.
|
||||||
"""
|
"""
|
||||||
def __init__(self, msg):
|
def __init__(self, msg, error_code=None):
|
||||||
self.msg = msg
|
self.msg = msg
|
||||||
|
self.error_code = error_code
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return repr(self.msg)
|
return repr(self.msg)
|
||||||
|
|
@ -123,8 +125,9 @@ class TwythonAuthError(TwythonError):
|
||||||
Raised when you try to access a protected resource and it fails due to some issue with
|
Raised when you try to access a protected resource and it fails due to some issue with
|
||||||
your authentication.
|
your authentication.
|
||||||
"""
|
"""
|
||||||
def __init__(self, msg):
|
def __init__(self, msg, error_code=None ):
|
||||||
self.msg = msg
|
self.msg = msg
|
||||||
|
self.error_code = error_code
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return repr(self.msg)
|
return repr(self.msg)
|
||||||
|
|
@ -135,8 +138,9 @@ class AuthError(TwythonError):
|
||||||
Raised when you try to access a protected resource and it fails due to some issue with
|
Raised when you try to access a protected resource and it fails due to some issue with
|
||||||
your authentication.
|
your authentication.
|
||||||
"""
|
"""
|
||||||
def __init__(self, msg):
|
def __init__(self, msg , error_code=None ):
|
||||||
self.msg = '%s\n Notice: AuthError is deprecated and soon to be removed, catch on TwythonAuthError instead!' % msg
|
self.msg = '%s\n Notice: AuthError is deprecated and soon to be removed, catch on TwythonAuthError instead!' % msg
|
||||||
|
self.error_code = error_code
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return repr(self.msg)
|
return repr(self.msg)
|
||||||
|
|
@ -405,7 +409,7 @@ class Twython(object):
|
||||||
if request.status_code in [301, 201, 200]:
|
if request.status_code in [301, 201, 200]:
|
||||||
return request.text
|
return request.text
|
||||||
else:
|
else:
|
||||||
raise TwythonError('shortenURL() failed with a %s error code.' % request.status_code)
|
raise TwythonError('shortenURL() failed with a %s error code.' % request.status_code , request.status_code )
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def constructApiURL(base_url, params):
|
def constructApiURL(base_url, params):
|
||||||
|
|
@ -472,7 +476,7 @@ class Twython(object):
|
||||||
e.g x.searchGen("python", page="2") or
|
e.g x.searchGen("python", page="2") or
|
||||||
x.searchGen(search_query = "python", page = "2")
|
x.searchGen(search_query = "python", page = "2")
|
||||||
"""
|
"""
|
||||||
searchURL = Twython.constructApiURL("https://search.twitter.com/search.json?q=%s" % Twython.unicode2utf8(search_query), kwargs)
|
searchURL = Twython.constructApiURL("http://search.twitter.com/search.json?q=%s" % urllib.quote_plus(Twython.unicode2utf8(search_query)), kwargs)
|
||||||
try:
|
try:
|
||||||
response = self.client.get(searchURL, headers=self.headers)
|
response = self.client.get(searchURL, headers=self.headers)
|
||||||
data = simplejson.loads(response.content.decode('utf-8'))
|
data = simplejson.loads(response.content.decode('utf-8'))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue