Merge branch 'develop' of github.com:NandaScott/Scrython into develop
This commit is contained in:
commit
19cf7f39c4
|
@ -0,0 +1,8 @@
|
|||
import scrython
|
||||
|
||||
# oops, we asked for an exact match to a card, but failed to put the name in quotes
|
||||
# that's going to throw a Scryfall error
|
||||
try:
|
||||
search = scrython.cards.Search(q="!Black Lotus")
|
||||
except scrython.ScryfallError as e:
|
||||
print(str(e.error_details['status']) + ' ' + e.error_details['code'] + ': ' + e.error_details['details'])
|
|
@ -41,6 +41,9 @@ from scrython.symbology import Symbology
|
|||
#Import bulk-data
|
||||
from scrython.bulk_data import BulkData
|
||||
|
||||
#Utility
|
||||
from scrython.foundation import ScryfallError
|
||||
|
||||
__all__ = [
|
||||
'Autocomplete',
|
||||
'Collector',
|
||||
|
@ -72,5 +75,6 @@ __all__ = [
|
|||
'ArtistNames',
|
||||
'ParseMana',
|
||||
'Symbology',
|
||||
'BulkData'
|
||||
]
|
||||
'BulkData',
|
||||
'ScryfallError',
|
||||
]
|
||||
|
|
|
@ -174,7 +174,8 @@ class CardsObject(FoundationObject):
|
|||
'double_faced_token': lambda num: self.scryfallJson['card_faces'][num]['image_uris'],
|
||||
'emblem': lambda num: self.scryfallJson['image_uris'],
|
||||
'augment': lambda num: self.scryfallJson['image_uris'],
|
||||
'host': lambda num: self.scryfallJson['image_uris']
|
||||
'host': lambda num: self.scryfallJson['image_uris'],
|
||||
'adventure': lambda num: self.scryfallJson['image_uris']
|
||||
}
|
||||
|
||||
image_types = {
|
||||
|
|
|
@ -2,6 +2,13 @@ import aiohttp
|
|||
import asyncio
|
||||
import urllib
|
||||
|
||||
class ScryfallError(Exception):
|
||||
def __init__(self, error_obj, *args, **kwargs):
|
||||
super(self.__class__, self).__init__(*args, **kwargs)
|
||||
self.error_details = {}
|
||||
self.error_details.update(error_obj)
|
||||
|
||||
|
||||
class FoundationObject(object):
|
||||
|
||||
def __init__(self, _url, override=False, **kwargs):
|
||||
|
@ -28,7 +35,7 @@ class FoundationObject(object):
|
|||
loop.run_until_complete(main(loop))
|
||||
|
||||
if self.scryfallJson['object'] == 'error':
|
||||
raise Exception(self.scryfallJson['details'])
|
||||
raise ScryfallError(self.scryfallJson, self.scryfallJson['details'])
|
||||
|
||||
def _checkForKey(self, key):
|
||||
"""Checks for a key in the scryfallJson object.
|
||||
|
@ -58,4 +65,4 @@ class FoundationObject(object):
|
|||
KeyError: If key is not found.
|
||||
"""
|
||||
if not key in self.scryfallJson[parent][num]:
|
||||
raise KeyError('This tuple has no key \'{}\''.format(key))
|
||||
raise KeyError('This tuple has no key \'{}\''.format(key))
|
||||
|
|
Loading…
Reference in New Issue