Added more concise error codes.
This commit is contained in:
parent
baa3db3b55
commit
4e18a7e499
|
@ -39,7 +39,7 @@ class ScryfallObject(object):
|
||||||
set_search_uri: str Same output as set_uri.
|
set_search_uri: str Same output as set_uri.
|
||||||
scryfall_set_uri: str The full link to the set on Scryfall.
|
scryfall_set_uri: str The full link to the set on Scryfall.
|
||||||
rulings_uri: str The API uri for the rulings of the card.
|
rulings_uri: str The API uri for the rulings of the card.
|
||||||
prints_search_uri: str TODO: Figure out what this does.
|
prints_search_uri: str A link to where you can begin paginating all re/prints for this card on Scryfall’s API.
|
||||||
collector_number: str The collector number of the card.
|
collector_number: str The collector number of the card.
|
||||||
digital: bool Returns True if the card is the digital version.
|
digital: bool Returns True if the card is the digital version.
|
||||||
rarity: str The rarity of the card.
|
rarity: str The rarity of the card.
|
||||||
|
@ -88,262 +88,256 @@ class ScryfallObject(object):
|
||||||
|
|
||||||
def object(self):
|
def object(self):
|
||||||
if self.__checkForKey('object') is None:
|
if self.__checkForKey('object') is None:
|
||||||
return KeyError("This card has no associated object.")
|
return KeyError("This card has no associated object key.")
|
||||||
|
|
||||||
return self.scryfallJson['object']
|
return self.scryfallJson['object']
|
||||||
|
|
||||||
def id(self):
|
def id(self):
|
||||||
if self.__checkForKey('id') is None:
|
if self.__checkForKey('id') is None:
|
||||||
return KeyError("This card has no associated id.")
|
return KeyError("This card has no associated id key.")
|
||||||
|
|
||||||
return self.scryfallJson['id']
|
return self.scryfallJson['id']
|
||||||
|
|
||||||
def multiverse_ids(self):
|
def multiverse_ids(self):
|
||||||
if self.__checkForKey('multiverse_ids') is None:
|
if self.__checkForKey('multiverse_ids') is None:
|
||||||
return KeyError("This card has no associated multiverse id.")
|
return KeyError("This card has no associated multiverse id key.")
|
||||||
|
|
||||||
return self.scryfallJson['multiverse_ids']
|
return self.scryfallJson['multiverse_ids']
|
||||||
|
|
||||||
def mtgo_id(self):
|
def mtgo_id(self):
|
||||||
if self.__checkForKey('mtgo_id') is None:
|
if self.__checkForKey('mtgo_id') is None:
|
||||||
return KeyError("This card has no associated mtgo id.")
|
return KeyError("This card has no associated mtgo id key.")
|
||||||
|
|
||||||
return self.scryfallJson['mtgo_id']
|
return self.scryfallJson['mtgo_id']
|
||||||
|
|
||||||
def mtgo_foil_id(self):
|
def mtgo_foil_id(self):
|
||||||
if self.__checkForKey('mtgo_foil_id') is None:
|
if self.__checkForKey('mtgo_foil_id') is None:
|
||||||
return KeyError("This card has no associate mtgo foil id.")
|
return KeyError("This card has no associate mtgo foil id key.")
|
||||||
|
|
||||||
return self.scryfallJson['mtgo_foil_id']
|
return self.scryfallJson['mtgo_foil_id']
|
||||||
|
|
||||||
def name(self):
|
def name(self):
|
||||||
if self.__checkForKey('name') is None:
|
if self.__checkForKey('name') is None:
|
||||||
return KeyError("This card has no associated name.")
|
return KeyError("This card has no associated name key.")
|
||||||
|
|
||||||
return self.scryfallJson['name']
|
return self.scryfallJson['name']
|
||||||
|
|
||||||
def uri(self):
|
def uri(self):
|
||||||
if self.__checkForKey('uri') is None:
|
if self.__checkForKey('uri') is None:
|
||||||
return KeyError("This card has no associated uri.")
|
return KeyError("This card has no associated uri key.")
|
||||||
|
|
||||||
return self.scryfallJson['uri']
|
return self.scryfallJson['uri']
|
||||||
|
|
||||||
def scryfall_uri(self):
|
def scryfall_uri(self):
|
||||||
if self.__checkForKey('scryfall_uri') is None:
|
if self.__checkForKey('scryfall_uri') is None:
|
||||||
return KeyError("This card has no associated scryfall uri.")
|
return KeyError("This card has no associated scryfall uri key.")
|
||||||
|
|
||||||
return self.scryfallJson['scryfall_uri']
|
return self.scryfallJson['scryfall_uri']
|
||||||
|
|
||||||
def layout(self):
|
def layout(self):
|
||||||
if self.__checkForKey('layout') is None:
|
if self.__checkForKey('layout') is None:
|
||||||
return KeyError("This card has no associated layout.")
|
return KeyError("This card has no associated layout key.")
|
||||||
|
|
||||||
return self.scryfallJson['layout']
|
return self.scryfallJson['layout']
|
||||||
|
|
||||||
def highres_image(self):
|
def highres_image(self):
|
||||||
if self.__checkForKey('highres_image') is None:
|
if self.__checkForKey('highres_image') is None:
|
||||||
return KeyError("This card has no associated highres image.")
|
return KeyError("This card has no associated highres image key.")
|
||||||
|
|
||||||
return self.scryfallJson['highres_image']
|
return self.scryfallJson['highres_image']
|
||||||
|
|
||||||
def image_uris(self):
|
def image_uris(self):
|
||||||
if self.__checkForKey('image_uris') is None:
|
if self.__checkForKey('image_uris') is None:
|
||||||
return KeyError("This card has no associated image uris.")
|
return KeyError("This card has no associated image uris key.")
|
||||||
|
|
||||||
return self.scryfallJson['image_uris']
|
return self.scryfallJson['image_uris']
|
||||||
|
|
||||||
def cmc(self):
|
def cmc(self):
|
||||||
if self.__checkForKey('cmc') is None:
|
if self.__checkForKey('cmc') is None:
|
||||||
return KeyError("This card has no associated cmc.")
|
return KeyError("This card has no associated cmc key.")
|
||||||
|
|
||||||
return self.scryfallJson['cmc']
|
return self.scryfallJson['cmc']
|
||||||
|
|
||||||
def type_line(self):
|
def type_line(self):
|
||||||
if self.__checkForKey('type_line') is None:
|
if self.__checkForKey('type_line') is None:
|
||||||
return KeyError("This card has no associated type line.")
|
return KeyError("This card has no associated type line key.")
|
||||||
|
|
||||||
return self.scryfallJson['type_line']
|
return self.scryfallJson['type_line']
|
||||||
|
|
||||||
def oracle_text(self):
|
def oracle_text(self):
|
||||||
if self.__checkForKey('oracle_text') is None:
|
if self.__checkForKey('oracle_text') is None:
|
||||||
return KeyError("This card has no associated oracle text.")
|
return KeyError("This card has no associated oracle text key.")
|
||||||
|
|
||||||
return self.scryfallJson['oracle_text']
|
return self.scryfallJson['oracle_text']
|
||||||
|
|
||||||
def mana_cost(self):
|
def mana_cost(self):
|
||||||
if self.__checkForKey('mana_cost') is None:
|
if self.__checkForKey('mana_cost') is None:
|
||||||
return KeyError("This card has no associated mana cost.")
|
return KeyError("This card has no associated mana cost key.")
|
||||||
|
|
||||||
return self.scryfallJson['mana_cost']
|
return self.scryfallJson['mana_cost']
|
||||||
|
|
||||||
def colors(self):
|
def colors(self):
|
||||||
if self.__checkForKey('colors') is None:
|
if self.__checkForKey('colors') is None:
|
||||||
return KeyError("This card has no associated colors.")
|
return KeyError("This card has no associated colors key.")
|
||||||
|
|
||||||
return self.scryfallJson['colors']
|
return self.scryfallJson['colors']
|
||||||
|
|
||||||
def color_identity(self):
|
def color_identity(self):
|
||||||
if self.__checkForKey('color_identity') is None:
|
if self.__checkForKey('color_identity') is None:
|
||||||
return KeyError("This card has no associated color identity.")
|
return KeyError("This card has no associated color identity key.")
|
||||||
|
|
||||||
return self.scryfallJson['color_identity']
|
return self.scryfallJson['color_identity']
|
||||||
|
|
||||||
def legalities(self):
|
def legalities(self):
|
||||||
if self.__checkForKey('legalities') is None:
|
if self.__checkForKey('legalities') is None:
|
||||||
return KeyError("This card has no associated legalities.")
|
return KeyError("This card has no associated legalities key.")
|
||||||
|
|
||||||
return self.scryfallJson['legalities']
|
return self.scryfallJson['legalities']
|
||||||
|
|
||||||
#TODO: Format error
|
|
||||||
def reserved(self):
|
def reserved(self):
|
||||||
if self.__checkForKey('reserved') is None:
|
if self.__checkForKey('reserved') is None:
|
||||||
return KeyError("This card has no associated .")
|
return KeyError("This card has no associated reserved key key.")
|
||||||
|
|
||||||
return self.scryfallJson['reserved']
|
return self.scryfallJson['reserved']
|
||||||
|
|
||||||
def reprint(self):
|
def reprint(self):
|
||||||
if self.__checkForKey('reprint') is None:
|
if self.__checkForKey('reprint') is None:
|
||||||
return KeyError("This card has no associated reprint.")
|
return KeyError("This card has no associated reprint key.")
|
||||||
|
|
||||||
return self.scryfallJson['reprint']
|
return self.scryfallJson['reprint']
|
||||||
|
|
||||||
def set(self):
|
def set(self):
|
||||||
if self.__checkForKey('set') is None:
|
if self.__checkForKey('set') is None:
|
||||||
return KeyError("This card has no associated set.")
|
return KeyError("This card has no associated set key.")
|
||||||
|
|
||||||
return self.scryfallJson['set']
|
return self.scryfallJson['set']
|
||||||
|
|
||||||
def set_name(self):
|
def set_name(self):
|
||||||
if self.__checkForKey('set_name') is None:
|
if self.__checkForKey('set_name') is None:
|
||||||
return KeyError("This card has no associated set name.")
|
return KeyError("This card has no associated set name key.")
|
||||||
|
|
||||||
return self.scryfallJson['set_name']
|
return self.scryfallJson['set_name']
|
||||||
|
|
||||||
def set_uri(self):
|
def set_uri(self):
|
||||||
if self.__checkForKey('set_uri') is None:
|
if self.__checkForKey('set_uri') is None:
|
||||||
return KeyError("This card has no associated set uri.")
|
return KeyError("This card has no associated set uri key.")
|
||||||
|
|
||||||
return self.scryfallJson['set_uri']
|
return self.scryfallJson['set_uri']
|
||||||
|
|
||||||
def set_search_uri(self):
|
def set_search_uri(self):
|
||||||
if self.__checkForKey('set_search_uri') is None:
|
if self.__checkForKey('set_search_uri') is None:
|
||||||
return KeyError("This card has no associated set search uri.")
|
return KeyError("This card has no associated set search uri key.")
|
||||||
|
|
||||||
return self.scryfallJson['set_search_uri']
|
return self.scryfallJson['set_search_uri']
|
||||||
|
|
||||||
def scryfall_set_uri(self):
|
def scryfall_set_uri(self):
|
||||||
if self.__checkForKey('scryfall_set_uri') is None:
|
if self.__checkForKey('scryfall_set_uri') is None:
|
||||||
return KeyError("This card has no associated scryfall set uri.")
|
return KeyError("This card has no associated scryfall set uri key.")
|
||||||
|
|
||||||
return self.scryfallJson['scryfall_set_uri']
|
return self.scryfallJson['scryfall_set_uri']
|
||||||
|
|
||||||
def rulings_uri(self):
|
def rulings_uri(self):
|
||||||
if self.__checkForKey('rulings_uri') is None:
|
if self.__checkForKey('rulings_uri') is None:
|
||||||
return KeyError("This card has no associated rulings uri.")
|
return KeyError("This card has no associated rulings uri key.")
|
||||||
|
|
||||||
return self.scryfallJson['rulings_uri']
|
return self.scryfallJson['rulings_uri']
|
||||||
|
|
||||||
def prints_search_uri(self):
|
def prints_search_uri(self):
|
||||||
if self.__checkForKey('prints_search_uri') is None:
|
if self.__checkForKey('prints_search_uri') is None:
|
||||||
return KeyError("This card has no associated prints search uri.")
|
return KeyError("This card has no associated prints search uri key.")
|
||||||
|
|
||||||
return self.scryfallJson['prints_search_uri']
|
return self.scryfallJson['prints_search_uri']
|
||||||
|
|
||||||
def collector_number(self):
|
def collector_number(self):
|
||||||
if self.__checkForKey('collector_number') is None:
|
if self.__checkForKey('collector_number') is None:
|
||||||
return KeyError("This card has no associated collector number.")
|
return KeyError("This card has no associated collector number key.")
|
||||||
|
|
||||||
return self.scryfallJson['collector_number']
|
return self.scryfallJson['collector_number']
|
||||||
|
|
||||||
#TODO: Format Error
|
|
||||||
def digital(self):
|
def digital(self):
|
||||||
if self.__checkForKey('digital') is None:
|
if self.__checkForKey('digital') is None:
|
||||||
return KeyError("This card has no associated .")
|
return KeyError("This card has no associated digital key key.")
|
||||||
|
|
||||||
return self.scryfallJson['digital']
|
return self.scryfallJson['digital']
|
||||||
|
|
||||||
def rarity(self):
|
def rarity(self):
|
||||||
if self.__checkForKey('rarity') is None:
|
if self.__checkForKey('rarity') is None:
|
||||||
return KeyError("This card has no associated rarity.")
|
return KeyError("This card has no associated rarity key.")
|
||||||
|
|
||||||
return self.scryfallJson['rarity']
|
return self.scryfallJson['rarity']
|
||||||
|
|
||||||
def illustration_id(self):
|
def illustration_id(self):
|
||||||
if self.__checkForKey('illustration_id') is None:
|
if self.__checkForKey('illustration_id') is None:
|
||||||
return KeyError("This card has no associated illustration id.")
|
return KeyError("This card has no associated illustration id key.")
|
||||||
|
|
||||||
return self.scryfallJson['illustration_id']
|
return self.scryfallJson['illustration_id']
|
||||||
|
|
||||||
def artist(self):
|
def artist(self):
|
||||||
if self.__checkForKey('artist') is None:
|
if self.__checkForKey('artist') is None:
|
||||||
return KeyError("This card has no associated artist.")
|
return KeyError("This card has no associated artist key.")
|
||||||
|
|
||||||
return self.scryfallJson['artist']
|
return self.scryfallJson['artist']
|
||||||
|
|
||||||
def frame(self):
|
def frame(self):
|
||||||
if self.__checkForKey('frame') is None:
|
if self.__checkForKey('frame') is None:
|
||||||
return KeyError("This card has no associated frame.")
|
return KeyError("This card has no associated frame key.")
|
||||||
|
|
||||||
return self.scryfallJson['frame']
|
return self.scryfallJson['frame']
|
||||||
|
|
||||||
#TODO: Format error
|
|
||||||
def full_art(self):
|
def full_art(self):
|
||||||
if self.__checkForKey('') is None:
|
if self.__checkForKey('') is None:
|
||||||
return KeyError("This card has no associated .")
|
return KeyError("This card has no associated full art key key.")
|
||||||
|
|
||||||
return self.scryfallJson['full_art']
|
return self.scryfallJson['full_art']
|
||||||
|
|
||||||
def border_color(self):
|
def border_color(self):
|
||||||
if self.__checkForKey('border_color') is None:
|
if self.__checkForKey('border_color') is None:
|
||||||
return KeyError("This card has no associated border color.")
|
return KeyError("This card has no associated border color key.")
|
||||||
|
|
||||||
return self.scryfallJson['border_color']
|
return self.scryfallJson['border_color']
|
||||||
|
|
||||||
#TODO: Format Error
|
|
||||||
def timeshifted(self):
|
def timeshifted(self):
|
||||||
if self.__checkForKey('timeshifted') is None:
|
if self.__checkForKey('timeshifted') is None:
|
||||||
return KeyError("This card has no associated .")
|
return KeyError("This card has no associated timeshifted key key.")
|
||||||
|
|
||||||
return self.scryfallJson['timeshifted']
|
return self.scryfallJson['timeshifted']
|
||||||
|
|
||||||
#TODO: Format Error
|
|
||||||
def colorshifted(self):
|
def colorshifted(self):
|
||||||
if self.__checkForKey('colorshifted') is None:
|
if self.__checkForKey('colorshifted') is None:
|
||||||
return KeyError("This card has no associated .")
|
return KeyError("This card has no associated colorshifted key key.")
|
||||||
|
|
||||||
return self.scryfallJson['colorshifted']
|
return self.scryfallJson['colorshifted']
|
||||||
|
|
||||||
#TODO: Format Error
|
|
||||||
def futureshifted(self):
|
def futureshifted(self):
|
||||||
if self.__checkForKey('futureshifted') is None:
|
if self.__checkForKey('futureshifted') is None:
|
||||||
return KeyError("This card has no associated .")
|
return KeyError("This card has no associated futureshifted key key.")
|
||||||
|
|
||||||
return self.scryfallJson['futureshifted']
|
return self.scryfallJson['futureshifted']
|
||||||
|
|
||||||
def edhrec_rank(self):
|
def edhrec_rank(self):
|
||||||
if self.__checkForKey('edhrec_rank') is None:
|
if self.__checkForKey('edhrec_rank') is None:
|
||||||
return KeyError("This card has no associated edhrec rank.")
|
return KeyError("This card has no associated edhrec rank key.")
|
||||||
|
|
||||||
return self.scryfallJson['edhrec_rank']
|
return self.scryfallJson['edhrec_rank']
|
||||||
|
|
||||||
def currency(self, mode):
|
def currency(self, mode):
|
||||||
modes = ['usd', 'eur', 'tix']
|
modes = ['usd', 'eur', 'tix']
|
||||||
if mode not in modes:
|
if mode not in modes:
|
||||||
return KeyError("This card has no associated currency {}".format(mode))
|
return KeyError("{} is not a key.".format(mode))
|
||||||
|
|
||||||
if self.__checkForKey(mode) is None:
|
if self.__checkForKey(mode) is None:
|
||||||
return KeyError("This card has no associated currency {}".format(mode))
|
return KeyError("This card has no associated currency {} key".format(mode))
|
||||||
|
|
||||||
return self.scryfallJson[mode]
|
return self.scryfallJson[mode]
|
||||||
|
|
||||||
def related_uris(self):
|
def related_uris(self):
|
||||||
if self.__checkForKey('related_uris') is None:
|
if self.__checkForKey('related_uris') is None:
|
||||||
return KeyError("This card has no associated related uris.")
|
return KeyError("This card has no associated related uris key.")
|
||||||
|
|
||||||
return self.scryfallJson['related_uris']
|
return self.scryfallJson['related_uris']
|
||||||
|
|
||||||
def purchase_uris(self):
|
def purchase_uris(self):
|
||||||
if self.__checkForKey('purchase_uris') is None:
|
if self.__checkForKey('purchase_uris') is None:
|
||||||
return KeyError("This card has no associated purchase uris.")
|
return KeyError("This card has no associated purchase uris key.")
|
||||||
|
|
||||||
return self.scryfallJson['purchase_uris']
|
return self.scryfallJson['purchase_uris']
|
||||||
|
|
Loading…
Reference in New Issue