Removed docstrings. Added error handling on rulings_object.
This commit is contained in:
parent
3c5071d813
commit
3bc4b06744
|
@ -1,7 +1,6 @@
|
||||||
from .rulings_object import RulingsObject
|
from .rulings_object import RulingsObject
|
||||||
|
|
||||||
class Mtgo(RulingsObject):
|
class Mtgo(RulingsObject):
|
||||||
"""docstring for Mtgo."""
|
|
||||||
def __init__(self, _id):
|
def __init__(self, _id):
|
||||||
self.id = _id
|
self.id = _id
|
||||||
self.url = 'cards/mtgo/{}/rulings'.format(self.id)
|
self.url = 'cards/mtgo/{}/rulings'.format(self.id)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
from .rulings_object import RulingsObject
|
from .rulings_object import RulingsObject
|
||||||
|
|
||||||
class Multiverse(RulingsObject):
|
class Multiverse(RulingsObject):
|
||||||
"""docstring for Multiverse."""
|
|
||||||
def __init__(self, _id):
|
def __init__(self, _id):
|
||||||
self.id = str(_id)
|
self.id = str(_id)
|
||||||
self.url = 'cards/multiverse/{}/rulings'.format(self.id)
|
self.url = 'cards/multiverse/{}/rulings'.format(self.id)
|
||||||
|
|
|
@ -2,7 +2,6 @@ import asyncio
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
||||||
class RulingsObject(object):
|
class RulingsObject(object):
|
||||||
|
|
||||||
def __init__(self, _url, **kwargs):
|
def __init__(self, _url, **kwargs):
|
||||||
self.pretty = kwargs.get('pretty')
|
self.pretty = kwargs.get('pretty')
|
||||||
self.format = kwargs.get('format')
|
self.format = kwargs.get('format')
|
||||||
|
@ -33,38 +32,56 @@ class RulingsObject(object):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def __checkForTupleKey(self, parent, num, key):
|
||||||
|
try:
|
||||||
|
return self.scryfallJson[parent][num][key]
|
||||||
|
except KeyError:
|
||||||
|
return None
|
||||||
|
|
||||||
def object(self):
|
def object(self):
|
||||||
if self.__checkForKey('object') is None:
|
if self.__checkForKey('object') is None:
|
||||||
return KeyError('This ruling has no associated object key.')
|
return KeyError('This ruling object has no associated object key.')
|
||||||
|
|
||||||
return self.scryfallJson['object']
|
return self.scryfallJson['object']
|
||||||
|
|
||||||
def has_more(self):
|
def has_more(self):
|
||||||
if self.__checkForKey('has_more') is None:
|
if self.__checkForKey('has_more') is None:
|
||||||
return KeyError('This ruling has no associated has_more key.')
|
return KeyError('This ruling object has no associated has_more key.')
|
||||||
|
|
||||||
return self.scryfallJson['has_more']
|
return self.scryfallJson['has_more']
|
||||||
|
|
||||||
def data(self):
|
def data(self):
|
||||||
if self.__checkForKey('data') is None:
|
if self.__checkForKey('data') is None:
|
||||||
return KeyError('This ruling has no associated data key.')
|
return KeyError('This ruling object has no associated data key.')
|
||||||
|
|
||||||
return self.scryfallJson['data']
|
return self.scryfallJson['data']
|
||||||
|
|
||||||
def data_length(self):
|
def data_length(self):
|
||||||
if self.__checkForKey('data') is None:
|
if self.__checkForKey('data') is None:
|
||||||
return KeyError('This ruling has no associated data key.')
|
return KeyError('This ruling object has no associated data key.')
|
||||||
|
|
||||||
return len(self.scryfallJson['data'])
|
return len(self.scryfallJson['data'])
|
||||||
|
|
||||||
def ruling_object(self, num):
|
def ruling_object(self, num):
|
||||||
|
if self.__checkForTupleKey('data', num, 'object') is None:
|
||||||
|
return KeyError('This ruling has no object key.')
|
||||||
|
|
||||||
return self.scryfallJson['data'][num]['object']
|
return self.scryfallJson['data'][num]['object']
|
||||||
|
|
||||||
def ruling_source(self, num):
|
def ruling_source(self, num):
|
||||||
|
if self.__checkForTupleKey('data', num, 'source') is None:
|
||||||
|
return KeyError('This ruling has no source key.')
|
||||||
|
|
||||||
return self.scryfallJson['data'][num]['source']
|
return self.scryfallJson['data'][num]['source']
|
||||||
|
|
||||||
def ruling_published_at(self, num):
|
def ruling_published_at(self, num):
|
||||||
|
if self.__checkForTupleKey('data', num, 'published_at') is None:
|
||||||
|
return KeyError('This ruling has no published_at key.')
|
||||||
|
|
||||||
return self.scryfallJson['data'][num]['published_at']
|
return self.scryfallJson['data'][num]['published_at']
|
||||||
|
|
||||||
def ruling_comment(self, num):
|
def ruling_comment(self, num):
|
||||||
|
if self.__checkForTupleKey('data', num, 'comment') is None:
|
||||||
|
return KeyError('This ruling has no comment key.')
|
||||||
|
|
||||||
return self.scryfallJson['data'][num]['comment']
|
return self.scryfallJson['data'][num]['comment']
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
from .rulings_object import RulingsObject
|
from .rulings_object import RulingsObject
|
||||||
|
|
||||||
class Id(RulingsObject):
|
class Id(RulingsObject):
|
||||||
"""docstring for Id."""
|
|
||||||
def __init__(self, _id):
|
def __init__(self, _id):
|
||||||
self.id = str(_id)
|
self.id = str(_id)
|
||||||
self.url = 'cards/{}/rulings'.format(self.id)
|
self.url = 'cards/{}/rulings'.format(self.id)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
from .rulings_object import RulingsObject
|
from .rulings_object import RulingsObject
|
||||||
|
|
||||||
class Code(RulingsObject):
|
class Code(RulingsObject):
|
||||||
"""docstring for Code."""
|
|
||||||
def __init__(self, code, number):
|
def __init__(self, code, number):
|
||||||
self.code = code.lower()
|
self.code = code.lower()
|
||||||
self.number = str(number)
|
self.number = str(number)
|
||||||
|
|
Loading…
Reference in New Issue