Updating a lot of docstrings, EndpointMixin replaces api_table dict

[ci skip]
This commit is contained in:
Mike Helmick 2013-06-06 13:40:39 -04:00
parent 9c6fe0d6b8
commit ff7e3fab94
5 changed files with 858 additions and 450 deletions

View file

@ -1,23 +1,20 @@
from .endpoints import twitter_http_status_codes
from .endpoints import TWITTER_HTTP_STATUS_CODE
class TwythonError(Exception):
"""Generic error class, catch-all for most Twython issues.
Special cases are handled by TwythonAuthError & TwythonRateLimitError.
Note: Syntax has changed as of Twython 1.3. To catch these,
you need to explicitly import them into your code, e.g:
from twython import TwythonError, TwythonRateLimitError, TwythonAuthError
from twython import (
TwythonError, TwythonRateLimitError, TwythonAuthError
)"""
"""
def __init__(self, msg, error_code=None, retry_after=None):
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_CODE:
msg = 'Twitter API returned a %s (%s), %s' % \
(error_code,
twitter_http_status_codes[error_code][0],
TWITTER_HTTP_STATUS_CODE[error_code][0],
msg)
super(TwythonError, self).__init__(msg)
@ -29,7 +26,9 @@ class TwythonError(Exception):
class TwythonAuthError(TwythonError):
"""Raised when you try to access a protected resource and it fails due to
some issue with your authentication."""
some issue with your authentication.
"""
pass
@ -37,7 +36,9 @@ class TwythonRateLimitError(TwythonError):
"""Raised when you've hit a rate limit.
The amount of seconds to retry your request in will be appended
to the message."""
to the message.
"""
def __init__(self, msg, error_code, retry_after=None):
if isinstance(retry_after, int):
msg = '%s (Retry after %d seconds)' % (msg, retry_after)