Updated catalogs_object to the new refactor scheme.

This commit is contained in:
2018-03-03 18:09:56 -05:00
parent 2fd9477620
commit f0cda14141
1 changed files with 7 additions and 11 deletions

View File

@ -45,32 +45,28 @@ class CatalogsObject(object):
if self.scryfallJson['object'] == 'error':
raise Exception(self.scryfallJson['details'])
def __checkForKey(self, key):
def _checkForKey(self, key):
try:
return self.scryfallJson[key]
except KeyError:
return None
except Exception:
raise KeyError('This card has no key \'{}\''.format(key))
def object(self):
if self.__checkForKey('object') is None:
raise KeyError('This object has no key \'object\'')
self._checkForKey('object')
return self.scryfallJson['object']
def uri(self):
if self.__checkForKey('uri') is None:
raise KeyError('This object has no key \'uri\'')
self._checkForKey('uri')
return self.scryfallJson['uri']
def total_values(self):
if self.__checkForKey('total_values') is None:
raise KeyError('This object has no key \'total_values\'')
self._checkForKey('total_values')
return self.scryfallJson['total_values']
def data(self):
if self.__checkForKey('data') is None:
raise KeyError('This object has no key \'data\'')
self._checkForKey('data')
return self.scryfallJson['data']