Updated parse_mana and symbology to the new refactor scheme.
This commit is contained in:
parent
240dcd7436
commit
5460d2b676
|
@ -28,50 +28,43 @@ class ParseMana(SymbologyObject):
|
|||
self.url = 'symbology/parse-mana?cost=' + self.cost
|
||||
super(ParseMana, self).__init__(self.url)
|
||||
|
||||
def __checkForKey(self, key):
|
||||
def _checkForKey(self, key):
|
||||
try:
|
||||
return self.scryfallJson[key]
|
||||
except KeyError:
|
||||
return None
|
||||
except Exception:
|
||||
raise KeyError('This object 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 mana_cost(self):
|
||||
if self.__checkForKey('cost') is None:
|
||||
raise KeyError('This object has no key \'cost\'')
|
||||
self._checkForKey('cost')
|
||||
|
||||
return self.scryfallJson['cost']
|
||||
|
||||
def cmc(self):
|
||||
if self.__checkForKey('cmc') is None:
|
||||
raise KeyError('This object has no key \'cmc\'')
|
||||
self._checkForKey('cmc')
|
||||
|
||||
return self.scryfallJson['cmc']
|
||||
|
||||
def colors(self):
|
||||
if self.__checkForKey('colors') is None:
|
||||
raise KeyError('This object has no key \'colors\'')
|
||||
self._checkForKey('colors')
|
||||
|
||||
return self.scryfallJson['colors']
|
||||
|
||||
def colorless(self):
|
||||
if self.__checkForKey('colorless') is None:
|
||||
raise KeyError('This object has no key \'colorless\'')
|
||||
self._checkForKey('colorless')
|
||||
|
||||
return self.scryfallJson['colorless']
|
||||
|
||||
def monocolored(self):
|
||||
if self.__checkForKey('monocolored') is None:
|
||||
raise KeyError('This object has no key \'monocolored\'')
|
||||
self._checkForKey('monocolored')
|
||||
|
||||
return self.scryfallJson['monocolored']
|
||||
|
||||
def multicolored(self):
|
||||
if self.__checkForKey('multicolored') is None:
|
||||
raise KeyError('This object has no key \'multicolored\'')
|
||||
self._checkForKey('multicolored')
|
||||
|
||||
return self.scryfallJson['multicolored']
|
||||
|
|
|
@ -33,86 +33,74 @@ class Symbology(SymbologyObject):
|
|||
self.url = 'symbology?'
|
||||
super(Symbology, self).__init__(self.url)
|
||||
|
||||
def __checkForKey(self, key):
|
||||
def _checkForKey(self, key):
|
||||
try:
|
||||
return self.scryfallJson[key]
|
||||
except KeyError:
|
||||
return None
|
||||
except Exception:
|
||||
raise KeyError('This object ahs no key \'{}\''.format(key))
|
||||
|
||||
def __checkForTupleKey(self, parent, num, key):
|
||||
def _checkForTupleKey(self, parent, num, key):
|
||||
try:
|
||||
return self.scryfallJson[parent][num][key]
|
||||
except KeyError:
|
||||
return None
|
||||
except Exception:
|
||||
raise KeyError('This object 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 has_more(self):
|
||||
if self.__checkForKey('has_more') is None:
|
||||
raise KeyError('This object has no key \'has_more\'')
|
||||
self._checkForKey('has_more')
|
||||
|
||||
return self.scryfallJson['has_more']
|
||||
|
||||
def data(self):
|
||||
if self.__checkForKey('has_more') is None:
|
||||
raise KeyError('This object has no key \'data\'')
|
||||
self._checkForKey('has_more')
|
||||
|
||||
return self.scryfallJson['data']
|
||||
|
||||
def data_length(self):
|
||||
if self.__checkForKey('data') is None:
|
||||
return KeyError('This object has no key \'data\'')
|
||||
self._checkForKey('data')
|
||||
|
||||
return len(self.scryfallJson['data'])
|
||||
|
||||
def symbol_symbol(self, num):
|
||||
if self.__checkForTupleKey('data', num, 'symbol') is None:
|
||||
raise KeyError('This object has no key \'symbol\'')
|
||||
self._checkForTupleKey('data', num, 'symbol')
|
||||
|
||||
return self.scryfallJson['data'][num]['symbol']
|
||||
|
||||
def symbol_loose_variant(self, num):
|
||||
if self.__checkForTupleKey('data', num, 'loose_variant') is None:
|
||||
raise KeyError('This object has no key \'loose_variant\'')
|
||||
self._checkForTupleKey('data', num, 'loose_variant')
|
||||
|
||||
return self.scryfallJson['data'][num]['loose_variant']
|
||||
|
||||
def symbol_transposable(self, num):
|
||||
if self.__checkForTupleKey('data', num, 'transposable') is None:
|
||||
raise KeyError('This object has no key \'transposable\'')
|
||||
self._checkForTupleKey('data', num, 'transposable')
|
||||
|
||||
return self.scryfallJson['data'][num]['transposable']
|
||||
|
||||
def symbol_represents_mana(self, num):
|
||||
if self.__checkForTupleKey('data', num, 'represents_mana') is None:
|
||||
raise KeyError('This object has no key \'represents_mana\'')
|
||||
self._checkForTupleKey('data', num, 'represents_mana')
|
||||
|
||||
return self.scryfallJson['data'][num]['represents_mana']
|
||||
|
||||
def symbol_cmc(self, num):
|
||||
if self.__checkForTupleKey('data', num, 'cmc') is None:
|
||||
raise KeyError('This object has no key \'cmc\'')
|
||||
self._checkForTupleKey('data', num, 'cmc')
|
||||
|
||||
return self.scryfallJson['data'][num]['cmc']
|
||||
|
||||
def symbol_appears_in_mana_costs(self, num):
|
||||
if self.__checkForTupleKey('data', num, 'appears_in_mana_costs') is None:
|
||||
raise KeyError('This object has no key \'appears_in_mana_costs\'')
|
||||
self._checkForTupleKey('data', num, 'appears_in_mana_costs')
|
||||
|
||||
return self.scryfallJson['data'][num]['appears_in_mana_costs']
|
||||
|
||||
def symbol_funny(self, num):
|
||||
if self.__checkForTupleKey('data', num, 'funny') is None:
|
||||
raise KeyError('This object has no key \'funny\'')
|
||||
self._checkForTupleKey('data', num, 'funny')
|
||||
|
||||
return self.scryfallJson['data'][num]['funny']
|
||||
|
||||
def symbol_colors(self, num):
|
||||
if self.__checkForTupleKey('data', num, 'colors') is None:
|
||||
raise KeyError('This object has no key \'colors\'')
|
||||
self._checkForTupleKey('data', num, 'colors')
|
||||
|
||||
return self.scryfallJson['data'][num]['colors']
|
||||
|
|
Loading…
Reference in New Issue