Merge branch 'develop' of github.com:NandaScott/Scrython into develop

This commit is contained in:
Nanda Scott 2019-09-24 18:59:59 -04:00
commit 19cf7f39c4
4 changed files with 25 additions and 5 deletions

View File

@ -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'])

View File

@ -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',
]

View File

@ -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 = {

View File

@ -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.