Added docstrings to Rulings.
This commit is contained in:
parent
15967521f3
commit
08c8e95c46
|
@ -1,6 +1,24 @@
|
||||||
from .rulings_object import RulingsObject
|
from .rulings_object import RulingsObject
|
||||||
|
|
||||||
class Mtgo(RulingsObject):
|
class Mtgo(RulingsObject):
|
||||||
|
"""
|
||||||
|
cards/mtgo/:id/rulings
|
||||||
|
|
||||||
|
Gets the ruling of a card by the Mtgo Id.
|
||||||
|
|
||||||
|
Positional arguments:
|
||||||
|
id : str ................. The mtgo id of the card you want rulings for.
|
||||||
|
|
||||||
|
Optional arguments:
|
||||||
|
All arguments inherited from RulingsObject
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
All attributes inherited from RulingsObject
|
||||||
|
|
||||||
|
Example usage:
|
||||||
|
>>> rule = scrython.rulings.Mtgo(id='9611')
|
||||||
|
>>> rule.data_length()
|
||||||
|
"""
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
if kwargs.get('id') is None:
|
if kwargs.get('id') is None:
|
||||||
raise TypeError('No id provided to search by')
|
raise TypeError('No id provided to search by')
|
||||||
|
|
|
@ -1,6 +1,24 @@
|
||||||
from .rulings_object import RulingsObject
|
from .rulings_object import RulingsObject
|
||||||
|
|
||||||
class Multiverse(RulingsObject):
|
class Multiverse(RulingsObject):
|
||||||
|
"""
|
||||||
|
cards/multiverse/:id/rulings
|
||||||
|
|
||||||
|
Gets the ruling of a card by the Multiverse Id.
|
||||||
|
|
||||||
|
Positional arguments:
|
||||||
|
id : str ........... The multiverse id of the card you want rulings for.
|
||||||
|
|
||||||
|
Optional arguments:
|
||||||
|
All arguments inherited from RulingsObject
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
All attributes inherited from RulingsObject
|
||||||
|
|
||||||
|
Example usage:
|
||||||
|
>>> rule = scrython.rulings.Id(id='4301')
|
||||||
|
>>> rule.data_length()
|
||||||
|
"""
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
if kwargs.get('id') is None:
|
if kwargs.get('id') is None:
|
||||||
raise TypeError('No id provided to search by')
|
raise TypeError('No id provided to search by')
|
||||||
|
|
|
@ -3,6 +3,33 @@ import aiohttp
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
class RulingsObject(object):
|
class RulingsObject(object):
|
||||||
|
"""
|
||||||
|
Master class for all rulings objects.
|
||||||
|
|
||||||
|
Positional arguments:
|
||||||
|
No arguments required.
|
||||||
|
|
||||||
|
Optional arguments:
|
||||||
|
format : str ... Returns data in the specified method. Defaults to JSON.
|
||||||
|
face : str ... If you're using the `image` format, this will specify if
|
||||||
|
you want the front or back face.
|
||||||
|
version : str ... If you're using the `image` format, this will specify if
|
||||||
|
you want the small, normal, large, etc version of the image.
|
||||||
|
pretty : str ... Returns a prettier version of the json object. Note that
|
||||||
|
this may break functionality with Scrython.
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
object : str ...... Returns the type of object it is. (card, error, etc)
|
||||||
|
had_more : bool ... If true, this ruling object has more rules than it currently displays.
|
||||||
|
data : list .................................. A list of ruling objects.
|
||||||
|
data_length : int ....................... The length of the `data` list.
|
||||||
|
|
||||||
|
The following require an integer as an arg, which acts as a tuple.
|
||||||
|
ruling_object : str ............. The type of object for a given ruling.
|
||||||
|
ruling_source : str .......................... The source of the ruling.
|
||||||
|
ruling_published_at : str ...... The date when the ruling was published.
|
||||||
|
ruling_comment : str ............................. The effective ruling.
|
||||||
|
"""
|
||||||
def __init__(self, _url, **kwargs):
|
def __init__(self, _url, **kwargs):
|
||||||
self.params = {
|
self.params = {
|
||||||
'format': kwargs.get('format', 'json'), 'face': kwargs.get('face', ''),
|
'format': kwargs.get('format', 'json'), 'face': kwargs.get('face', ''),
|
||||||
|
|
|
@ -1,6 +1,24 @@
|
||||||
from .rulings_object import RulingsObject
|
from .rulings_object import RulingsObject
|
||||||
|
|
||||||
class Id(RulingsObject):
|
class Id(RulingsObject):
|
||||||
|
"""
|
||||||
|
cards/:id/rulings
|
||||||
|
|
||||||
|
Gets the ruling of a card by the Scryfall Id.
|
||||||
|
|
||||||
|
Positional arguments:
|
||||||
|
id : str ...................... The id of the card you want rulings for.
|
||||||
|
|
||||||
|
Optional arguments:
|
||||||
|
All arguments inherited from RulingsObject
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
All attributes inherited from RulingsObject
|
||||||
|
|
||||||
|
Example usage:
|
||||||
|
>>> rule = scrython.rulings.Id(id='5976c352-ac49-4e0d-a4c0-ec9b6b78db9c')
|
||||||
|
>>> rule.data_length()
|
||||||
|
"""
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
if kwargs.get('id') is None:
|
if kwargs.get('id') is None:
|
||||||
raise TypeError('No id provided to search by')
|
raise TypeError('No id provided to search by')
|
||||||
|
|
|
@ -1,6 +1,25 @@
|
||||||
from .rulings_object import RulingsObject
|
from .rulings_object import RulingsObject
|
||||||
|
|
||||||
class Code(RulingsObject):
|
class Code(RulingsObject):
|
||||||
|
"""
|
||||||
|
cards/:code/:collector_number/rulings
|
||||||
|
|
||||||
|
Gets the ruling of a card by the set and collector number.
|
||||||
|
|
||||||
|
Positional arguments:
|
||||||
|
set : str ...... The 3 letter set code of the card you want rulings for.
|
||||||
|
collector_number : ................... The collector number of the card.
|
||||||
|
|
||||||
|
Optional arguments:
|
||||||
|
All arguments inherited from RulingsObject
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
All attributes inherited from RulingsObject
|
||||||
|
|
||||||
|
Example usage:
|
||||||
|
>>> rule = scrython.rulings.Code(code='ddg', collector_number='42')
|
||||||
|
>>> rule.data_length()
|
||||||
|
"""
|
||||||
def __init__(self, code, collector_number):
|
def __init__(self, code, collector_number):
|
||||||
self.url = 'cards/{}/{}/rulings?'.format(code.lower(), str(collector_number))
|
self.url = 'cards/{}/{}/rulings?'.format(code.lower(), str(collector_number))
|
||||||
super(Code, self).__init__(self.url)
|
super(Code, self).__init__(self.url)
|
||||||
|
|
Loading…
Reference in New Issue