Merge branch 'develop' of github.com:NandaScott/Scrython into develop
This commit is contained in:
commit
f83f2768d4
|
@ -1,5 +1,13 @@
|
|||
# Changelog
|
||||
|
||||
## 1.5.0
|
||||
|
||||
Changes
|
||||
|
||||
- Key errors are now handled more cleanly, and doesn't return two traceback errors.
|
||||
- Updated sets to be more like the other classes in structure.
|
||||
- Updated symbology to be more like the other classes in structure.
|
||||
|
||||
## 1.4.2
|
||||
|
||||
Bugfixes
|
||||
|
|
|
@ -103,15 +103,11 @@ class CardsObject(object):
|
|||
raise Exception(self.scryfallJson['details'])
|
||||
|
||||
def _checkForKey(self, key):
|
||||
try:
|
||||
return self.scryfallJson[key]
|
||||
except Exception:
|
||||
if not key in self.scryfallJson:
|
||||
raise KeyError('This card has no key \'{}\''.format(key))
|
||||
|
||||
def _checkForTupleKey(self, parent, num, key):
|
||||
try:
|
||||
return self.scryfallJson[parent][num][key]
|
||||
except Exception:
|
||||
if not key in self.scryfallJson[parent][num]:
|
||||
raise KeyError('This tuple has no key \'{}\''.format(key))
|
||||
|
||||
def object(self):
|
||||
|
|
|
@ -46,9 +46,7 @@ class CatalogsObject(object):
|
|||
raise Exception(self.scryfallJson['details'])
|
||||
|
||||
def _checkForKey(self, key):
|
||||
try:
|
||||
return self.scryfallJson[key]
|
||||
except Exception:
|
||||
if not key in self.scryfallJson:
|
||||
raise KeyError('This card has no key \'{}\''.format(key))
|
||||
|
||||
def object(self):
|
||||
|
|
|
@ -60,15 +60,11 @@ class RulingsObject(object):
|
|||
raise Exception(self.scryfallJson['details'])
|
||||
|
||||
def _checkForKey(self, key):
|
||||
try:
|
||||
return self.scryfallJson[key]
|
||||
except Exception:
|
||||
if not key in self.scryfallJson:
|
||||
raise KeyError('This object has no key \'{}\''.format(key))
|
||||
|
||||
def _checkForTupleKey(self, parent, num, key):
|
||||
try:
|
||||
return self.scryfallJson[parent][num][key]
|
||||
except Exception:
|
||||
if not key in self.scryfallJson[parent][num]:
|
||||
raise KeyError('This ruling has no key \'{}\''.format(key))
|
||||
|
||||
def object(self):
|
||||
|
|
|
@ -41,105 +41,93 @@ class Sets(SetsObject):
|
|||
self._url = 'sets?'
|
||||
super(Sets, self).__init__(self._url)
|
||||
|
||||
def _checkForKey(self, key):
|
||||
try:
|
||||
return self.scryfallJson[key]
|
||||
except Exception:
|
||||
raise KeyError('This object has no key \'{}\''.format(key))
|
||||
|
||||
def _checkForTupleKey(self, parent, num, key):
|
||||
try:
|
||||
return self.scryfallJson[parent][num][key]
|
||||
except Exception:
|
||||
raise KeyError('This object has no key \'{}\''.format(key))
|
||||
|
||||
def object(self):
|
||||
self._checkForKey('object')
|
||||
super(Sets, self)._checkForKey('object')
|
||||
|
||||
return self.scryfallJson['object']
|
||||
|
||||
def has_more(self):
|
||||
self._checkForKey('has_more')
|
||||
super(Sets, self)._checkForKey('has_more')
|
||||
|
||||
return self.scryfallJson['has_more']
|
||||
|
||||
def data(self):
|
||||
self._checkForKey('data')
|
||||
super(Sets, self)._checkForKey('data')
|
||||
|
||||
return self.scryfallJson['data']
|
||||
|
||||
def data_length(self):
|
||||
self._checkForKey('data')
|
||||
super(Sets, self)._checkForKey('data')
|
||||
|
||||
return len(self.scryfallJson['data'])
|
||||
|
||||
def set_object(self, num):
|
||||
self._checkForTupleKey('data', num, 'object')
|
||||
super(Sets, self)._checkForTupleKey('data', num, 'object')
|
||||
|
||||
return self.scryfallJson['data'][num]['object']
|
||||
|
||||
def set_code(self, num):
|
||||
self._checkForTupleKey('data', num, 'code')
|
||||
super(Sets, self)._checkForTupleKey('data', num, 'code')
|
||||
|
||||
return self.scryfallJson['data'][num]['code']
|
||||
|
||||
def set_mtgo_code(self, num):
|
||||
self._checkForTupleKey('data', num, 'mtgo_code')
|
||||
super(Sets, self)._checkForTupleKey('data', num, 'mtgo_code')
|
||||
|
||||
return self.scryfallJson['data'][num]['mtgo_code']
|
||||
|
||||
def set_name(self, num):
|
||||
self._checkForTupleKey('data', num, 'name')
|
||||
super(Sets, self)._checkForTupleKey('data', num, 'name')
|
||||
|
||||
return self.scryfallJson['data'][num]['name']
|
||||
|
||||
def set_set_type(self, num):
|
||||
self._checkForTupleKey('data', num, 'set_type')
|
||||
super(Sets, self)._checkForTupleKey('data', num, 'set_type')
|
||||
|
||||
return self.scryfallJson['data'][num]['set_type']
|
||||
|
||||
def set_released_at(self, num):
|
||||
self._checkForTupleKey('data', num, 'released_at')
|
||||
super(Sets, self)._checkForTupleKey('data', num, 'released_at')
|
||||
|
||||
return self.scryfallJson['data'][num]['released_at']
|
||||
|
||||
def set_block_code(self, num):
|
||||
self._checkForTupleKey('data', num, 'block_code')
|
||||
super(Sets, self)._checkForTupleKey('data', num, 'block_code')
|
||||
|
||||
return self.scryfallJson['data'][num]['block_code']
|
||||
|
||||
def set_block(self, num):
|
||||
self._checkForTupleKey('data', num, 'block')
|
||||
super(Sets, self)._checkForTupleKey('data', num, 'block')
|
||||
|
||||
return self.scryfallJson['data'][num]['block']
|
||||
|
||||
def set_parent_set_code(self, num):
|
||||
self._checkForTupleKey('data', num, 'parent_set_code')
|
||||
super(Sets, self)._checkForTupleKey('data', num, 'parent_set_code')
|
||||
|
||||
return self.scryfallJson['data'][num]['parent_set_code']
|
||||
|
||||
def set_card_count(self, num):
|
||||
self._checkForTupleKey('data', num, 'card_count')
|
||||
super(Sets, self)._checkForTupleKey('data', num, 'card_count')
|
||||
|
||||
return self.scryfallJson['data'][num]['card_count']
|
||||
|
||||
def set_digital(self, num):
|
||||
self._checkForTupleKey('data', num, 'digital')
|
||||
super(Sets, self)._checkForTupleKey('data', num, 'digital')
|
||||
|
||||
return self.scryfallJson['data'][num]['digital']
|
||||
|
||||
def set_foil(self, num):
|
||||
self._checkForTupleKey('data', num, 'foil')
|
||||
super(Sets, self)._checkForTupleKey('data', num, 'foil')
|
||||
|
||||
return self.scryfallJson['data'][num]['foil']
|
||||
|
||||
def set_icon_svg_uri(self, num):
|
||||
self._checkForTupleKey('data', num, 'icon_svg_uri')
|
||||
super(Sets, self)._checkForTupleKey('data', num, 'icon_svg_uri')
|
||||
|
||||
return self.scryfallJson['data'][num]['icon_svg_uri']
|
||||
|
||||
def set_search_uri(self, num):
|
||||
self._checkForTupleKey('data', num, 'search_uri')
|
||||
super(Sets, self)._checkForTupleKey('data', num, 'search_uri')
|
||||
|
||||
return self.scryfallJson['data'][num]['search_uri']
|
||||
|
||||
|
|
|
@ -56,8 +56,12 @@ class SetsObject(object):
|
|||
raise Exception(self.scryfallJson['details'])
|
||||
|
||||
def _checkForKey(self, key):
|
||||
if not key in self.scryfallJson:
|
||||
raise KeyError('This object has no key \'{}\''.format(key))
|
||||
|
||||
def _checkForTupleKey(self, parent, num, key):
|
||||
try:
|
||||
return self.scryfallJson[key]
|
||||
return self.scryfallJson[parent][num][key]
|
||||
except Exception:
|
||||
raise KeyError('This object has no key \'{}\''.format(key))
|
||||
|
||||
|
|
|
@ -28,43 +28,37 @@ class ParseMana(SymbologyObject):
|
|||
self.url = 'symbology/parse-mana?cost=' + self.cost
|
||||
super(ParseMana, self).__init__(self.url)
|
||||
|
||||
def _checkForKey(self, key):
|
||||
try:
|
||||
return self.scryfallJson[key]
|
||||
except Exception:
|
||||
raise KeyError('This object has no key \'{}\''.format(key))
|
||||
|
||||
def object(self):
|
||||
self._checkForKey('object')
|
||||
super(ParseMana, self)._checkForKey('object')
|
||||
|
||||
return self.scryfallJson['object']
|
||||
|
||||
def mana_cost(self):
|
||||
self._checkForKey('cost')
|
||||
super(ParseMana, self)._checkForKey('cost')
|
||||
|
||||
return self.scryfallJson['cost']
|
||||
|
||||
def cmc(self):
|
||||
self._checkForKey('cmc')
|
||||
super(ParseMana, self)._checkForKey('cmc')
|
||||
|
||||
return self.scryfallJson['cmc']
|
||||
|
||||
def colors(self):
|
||||
self._checkForKey('colors')
|
||||
super(ParseMana, self)._checkForKey('colors')
|
||||
|
||||
return self.scryfallJson['colors']
|
||||
|
||||
def colorless(self):
|
||||
self._checkForKey('colorless')
|
||||
super(ParseMana, self)._checkForKey('colorless')
|
||||
|
||||
return self.scryfallJson['colorless']
|
||||
|
||||
def monocolored(self):
|
||||
self._checkForKey('monocolored')
|
||||
super(ParseMana, self)._checkForKey('monocolored')
|
||||
|
||||
return self.scryfallJson['monocolored']
|
||||
|
||||
def multicolored(self):
|
||||
self._checkForKey('multicolored')
|
||||
super(ParseMana, self)._checkForKey('multicolored')
|
||||
|
||||
return self.scryfallJson['multicolored']
|
||||
|
|
|
@ -33,74 +33,62 @@ class Symbology(SymbologyObject):
|
|||
self.url = 'symbology?'
|
||||
super(Symbology, self).__init__(self.url)
|
||||
|
||||
def _checkForKey(self, key):
|
||||
try:
|
||||
return self.scryfallJson[key]
|
||||
except Exception:
|
||||
raise KeyError('This object ahs no key \'{}\''.format(key))
|
||||
|
||||
def _checkForTupleKey(self, parent, num, key):
|
||||
try:
|
||||
return self.scryfallJson[parent][num][key]
|
||||
except Exception:
|
||||
raise KeyError('This object has no key \'{}\''.format(key))
|
||||
|
||||
def object(self):
|
||||
self._checkForKey('object')
|
||||
super(Symbology, self)._checkForKey('object')
|
||||
|
||||
return self.scryfallJson['object']
|
||||
|
||||
def has_more(self):
|
||||
self._checkForKey('has_more')
|
||||
super(Symbology, self)._checkForKey('has_more')
|
||||
|
||||
return self.scryfallJson['has_more']
|
||||
|
||||
def data(self):
|
||||
self._checkForKey('has_more')
|
||||
super(Symbology, self)._checkForKey('has_more')
|
||||
|
||||
return self.scryfallJson['data']
|
||||
|
||||
def data_length(self):
|
||||
self._checkForKey('data')
|
||||
super(Symbology, self)._checkForKey('data')
|
||||
|
||||
return len(self.scryfallJson['data'])
|
||||
|
||||
def symbol_symbol(self, num):
|
||||
self._checkForTupleKey('data', num, 'symbol')
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'symbol')
|
||||
|
||||
return self.scryfallJson['data'][num]['symbol']
|
||||
|
||||
def symbol_loose_variant(self, num):
|
||||
self._checkForTupleKey('data', num, 'loose_variant')
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'loose_variant')
|
||||
|
||||
return self.scryfallJson['data'][num]['loose_variant']
|
||||
|
||||
def symbol_transposable(self, num):
|
||||
self._checkForTupleKey('data', num, 'transposable')
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'transposable')
|
||||
|
||||
return self.scryfallJson['data'][num]['transposable']
|
||||
|
||||
def symbol_represents_mana(self, num):
|
||||
self._checkForTupleKey('data', num, 'represents_mana')
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'represents_mana')
|
||||
|
||||
return self.scryfallJson['data'][num]['represents_mana']
|
||||
|
||||
def symbol_cmc(self, num):
|
||||
self._checkForTupleKey('data', num, 'cmc')
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'cmc')
|
||||
|
||||
return self.scryfallJson['data'][num]['cmc']
|
||||
|
||||
def symbol_appears_in_mana_costs(self, num):
|
||||
self._checkForTupleKey('data', num, 'appears_in_mana_costs')
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'appears_in_mana_costs')
|
||||
|
||||
return self.scryfallJson['data'][num]['appears_in_mana_costs']
|
||||
|
||||
def symbol_funny(self, num):
|
||||
self._checkForTupleKey('data', num, 'funny')
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'funny')
|
||||
|
||||
return self.scryfallJson['data'][num]['funny']
|
||||
|
||||
def symbol_colors(self, num):
|
||||
self._checkForTupleKey('data', num, 'colors')
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'colors')
|
||||
|
||||
return self.scryfallJson['data'][num]['colors']
|
||||
|
|
|
@ -41,3 +41,11 @@ class SymbologyObject(object):
|
|||
|
||||
if self.scryfallJson['object'] == 'error':
|
||||
raise Exception(self.scryfallJson['details'])
|
||||
|
||||
def _checkForKey(self, key):
|
||||
if not key in self.scryfallJson:
|
||||
raise KeyError('This object ahs no key \'{}\''.format(key))
|
||||
|
||||
def _checkForTupleKey(self, parent, num, key):
|
||||
if not key in self.scryfallJson[parent][num]:
|
||||
raise KeyError('This object has no key \'{}\''.format(key))
|
2
setup.py
2
setup.py
|
@ -3,7 +3,7 @@ from setuptools import setup
|
|||
setup(
|
||||
name='scrython',
|
||||
packages=['scrython', 'scrython.cards', 'scrython.rulings', 'scrython.catalog', 'scrython.sets', 'scrython.symbology'],
|
||||
version='1.4.2',
|
||||
version='1.5.0',
|
||||
description='A wrapper for using the Scryfall API.',
|
||||
long_description='https://github.com/NandaScott/Scrython/blob/master/README.md',
|
||||
url='https://github.com/NandaScott/Scrython',
|
||||
|
|
Loading…
Reference in New Issue