-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
153 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,24 @@ | ||
''' the omdb module ''' | ||
""" the omdb module """ | ||
|
||
from .omdb import OMDB | ||
from .exceptions import OMDBException, OMDBNoResults, OMDBLimitReached, OMDBTooManyResults | ||
from .exceptions import ( | ||
OMDBException, | ||
OMDBNoResults, | ||
OMDBLimitReached, | ||
OMDBTooManyResults, | ||
) | ||
|
||
__author__ = 'Tyler Barrus' | ||
__maintainer__ = 'Tyler Barrus' | ||
__email__ = '[email protected]' | ||
__license__ = 'MIT' | ||
__version__ = '0.2.0' | ||
__url__ = 'https://github.com/barrust/pyomdbapi' | ||
__bugtrack_url__ = '{0}/issues'.format(__url__) | ||
__all__ = ['OMDB', 'OMDBException', 'OMDBNoResults', 'OMDBLimitReached', 'OMDBTooManyResults'] | ||
__author__ = "Tyler Barrus" | ||
__maintainer__ = "Tyler Barrus" | ||
__email__ = "[email protected]" | ||
__license__ = "MIT" | ||
__version__ = "0.2.0" | ||
__url__ = "https://github.com/barrust/pyomdbapi" | ||
__bugtrack_url__ = "{0}/issues".format(__url__) | ||
__all__ = [ | ||
"OMDB", | ||
"OMDBException", | ||
"OMDBNoResults", | ||
"OMDBLimitReached", | ||
"OMDBTooManyResults", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,112 @@ | ||
''' Exceptions for the pyomdbapi project ''' | ||
""" Exceptions for the pyomdbapi project """ | ||
|
||
|
||
class OMDBException(Exception): | ||
''' Base OMDB Exception | ||
""" Base OMDB Exception | ||
Args: | ||
message (str): The exception message | ||
''' | ||
""" | ||
|
||
def __init__(self, message): | ||
''' init ''' | ||
""" init """ | ||
self._message = message | ||
super(OMDBException, self).__init__(self.message) | ||
|
||
@property | ||
def message(self): | ||
''' str: The exception message ''' | ||
""" str: The exception message """ | ||
return self._message | ||
|
||
|
||
class OMDBInvalidAPIKey(OMDBException): | ||
''' Invalide API Key provided | ||
""" Invalide API Key provided | ||
Args: | ||
api_key (str): The API Key used that generated the exception | ||
''' | ||
""" | ||
|
||
def __init__(self, api_key): | ||
self._api_key = api_key | ||
super(OMDBInvalidAPIKey, self).__init__('Invalid API Key ({}) provided'.format(self.api_key)) | ||
super(OMDBInvalidAPIKey, self).__init__( | ||
"Invalid API Key ({}) provided".format(self.api_key) | ||
) | ||
|
||
@property | ||
def api_key(self): | ||
''' str: The exception message ''' | ||
""" str: The exception message """ | ||
return self._api_key | ||
|
||
|
||
class OMDBNoResults(OMDBException): | ||
''' A No results returned exception | ||
""" A No results returned exception | ||
Args: | ||
error (str): The error message returned by the OMDB API service | ||
params (dict): The parameters used when the exception was raised | ||
''' | ||
""" | ||
|
||
def __init__(self, error, params): | ||
''' init ''' | ||
""" init """ | ||
self._params = params | ||
self._error = error | ||
super(OMDBNoResults, self).__init__('\n\tmessage:\t{}\n\tparams: \t{}'.format(self.error, self.params)) | ||
super(OMDBNoResults, self).__init__( | ||
"\n\tmessage:\t{}\n\tparams: \t{}".format(self.error, self.params) | ||
) | ||
|
||
@property | ||
def error(self): | ||
''' str: The OMDB API exception message ''' | ||
""" str: The OMDB API exception message """ | ||
return self._error | ||
|
||
@property | ||
def params(self): | ||
''' dict: The parameters used when the exception was raised ''' | ||
""" dict: The parameters used when the exception was raised """ | ||
return self._params | ||
|
||
|
||
class OMDBTooManyResults(OMDBException): | ||
''' Too many results would be returned (per the OMDB API) | ||
""" Too many results would be returned (per the OMDB API) | ||
Args: | ||
error (str): The error message returned by the OMDB API service | ||
params (dict): The parameters used when the exception was raised | ||
''' | ||
""" | ||
|
||
def __init__(self, error, params): | ||
''' init ''' | ||
""" init """ | ||
self._params = params | ||
self._error = error | ||
super(OMDBTooManyResults, self).__init__('\n\tmessage:\t{}\n\tparams: \t{}'.format(self.error, self.params)) | ||
super(OMDBTooManyResults, self).__init__( | ||
"\n\tmessage:\t{}\n\tparams: \t{}".format(self.error, self.params) | ||
) | ||
|
||
@property | ||
def error(self): | ||
''' str: The OMDB API exception message ''' | ||
""" str: The OMDB API exception message """ | ||
return self._error | ||
|
||
@property | ||
def params(self): | ||
''' dict: The parameters used when the exception was raised ''' | ||
""" dict: The parameters used when the exception was raised """ | ||
return self._params | ||
|
||
|
||
class OMDBLimitReached(OMDBException): | ||
''' Reached the limit of requests for the user - API Key combination | ||
""" Reached the limit of requests for the user - API Key combination | ||
Args: | ||
api_key (str): The API Key used when connecting to the OMDB API service | ||
''' | ||
""" | ||
|
||
def __init__(self, api_key): | ||
''' init ''' | ||
""" init """ | ||
self._api_key = api_key | ||
super(OMDBLimitReached, self).__init__('Limit reached for API Key: {}'.format(self.api_key)) | ||
super(OMDBLimitReached, self).__init__( | ||
"Limit reached for API Key: {}".format(self.api_key) | ||
) | ||
|
||
@property | ||
def api_key(self): | ||
''' str: The OMDB API API key used ''' | ||
""" str: The OMDB API API key used """ | ||
return self._api_key |
Oops, something went wrong.