diff --git a/scrython/cards/search.py b/scrython/cards/search.py index 0faf90b..29ac880 100644 --- a/scrython/cards/search.py +++ b/scrython/cards/search.py @@ -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