Skip to content

Commit

Permalink
more auto formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
barrust committed Jan 18, 2019
1 parent 8ee9766 commit 44a1c16
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 111 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## Version 0.2.1
* Correct exception properties
* [black](https://github.com/ambv/black) formatting

## Version 0.2.0
* Change to using named parameters in most cases
* Ensure all keys are handled correctly in response
Expand Down
31 changes: 21 additions & 10 deletions omdb/__init__.py
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",
]
60 changes: 34 additions & 26 deletions omdb/exceptions.py
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
Loading

0 comments on commit 44a1c16

Please sign in to comment.