Updated catalogs_object to the new refactor scheme.
This commit is contained in:
parent
2fd9477620
commit
f0cda14141
|
@ -45,32 +45,28 @@ class CatalogsObject(object):
|
||||||
if self.scryfallJson['object'] == 'error':
|
if self.scryfallJson['object'] == 'error':
|
||||||
raise Exception(self.scryfallJson['details'])
|
raise Exception(self.scryfallJson['details'])
|
||||||
|
|
||||||
def __checkForKey(self, key):
|
def _checkForKey(self, key):
|
||||||
try:
|
try:
|
||||||
return self.scryfallJson[key]
|
return self.scryfallJson[key]
|
||||||
except KeyError:
|
except Exception:
|
||||||
return None
|
raise KeyError('This card has no key \'{}\''.format(key))
|
||||||
|
|
||||||
def object(self):
|
def object(self):
|
||||||
if self.__checkForKey('object') is None:
|
self._checkForKey('object')
|
||||||
raise KeyError('This object has no key \'object\'')
|
|
||||||
|
|
||||||
return self.scryfallJson['object']
|
return self.scryfallJson['object']
|
||||||
|
|
||||||
def uri(self):
|
def uri(self):
|
||||||
if self.__checkForKey('uri') is None:
|
self._checkForKey('uri')
|
||||||
raise KeyError('This object has no key \'uri\'')
|
|
||||||
|
|
||||||
return self.scryfallJson['uri']
|
return self.scryfallJson['uri']
|
||||||
|
|
||||||
def total_values(self):
|
def total_values(self):
|
||||||
if self.__checkForKey('total_values') is None:
|
self._checkForKey('total_values')
|
||||||
raise KeyError('This object has no key \'total_values\'')
|
|
||||||
|
|
||||||
return self.scryfallJson['total_values']
|
return self.scryfallJson['total_values']
|
||||||
|
|
||||||
def data(self):
|
def data(self):
|
||||||
if self.__checkForKey('data') is None:
|
self._checkForKey('data')
|
||||||
raise KeyError('This object has no key \'data\'')
|
|
||||||
|
|
||||||
return self.scryfallJson['data']
|
return self.scryfallJson['data']
|
||||||
|
|
Loading…
Reference in New Issue