Created data_length and data_tuple attributes for Search
This commit is contained in:
parent
4817763f27
commit
50e9d35064
|
@ -53,6 +53,12 @@ class Search(CardsObject):
|
|||
except KeyError:
|
||||
return None
|
||||
|
||||
def __checkForTupleKey(self, parent, num, key):
|
||||
try:
|
||||
return self.scryfallJson[parent][num][key]
|
||||
except KeyError:
|
||||
return None
|
||||
|
||||
def object(self):
|
||||
if self.__checkForKey('object') is None:
|
||||
raise KeyError('This object has no key \'object\'')
|
||||
|
@ -83,6 +89,18 @@ class Search(CardsObject):
|
|||
|
||||
return self.scryfallJson['warnings']
|
||||
|
||||
def data_length(self):
|
||||
if self.__checkForKey('data') is None:
|
||||
raise KeyError('This object has no key \'data\'')
|
||||
|
||||
return len(self.scryfallJson['data'])
|
||||
|
||||
def data_tuple(self, num):
|
||||
if self.__checkForKey('data') is None:
|
||||
raise KeyError('This object has no key \'data\'')
|
||||
|
||||
return self.scryfallJson['data'][num]
|
||||
|
||||
#The following attributes are only to override the inherited class attributes.
|
||||
#This class has no matching attributes but we still need the getRequest function from CardsObject
|
||||
|
||||
|
|
Loading…
Reference in New Issue