2018-02-07 03:01:08 +00:00
|
|
|
from .cards_object import CardsObject
|
2018-01-30 03:32:08 +00:00
|
|
|
import urllib.parse
|
2018-01-10 01:59:55 +00:00
|
|
|
|
2018-02-07 03:01:08 +00:00
|
|
|
class Named(CardsObject):
|
2018-10-22 14:19:38 +00:00
|
|
|
"""
|
|
|
|
cards/named
|
|
|
|
Gets a card by the name.
|
|
|
|
|
2018-10-24 00:54:28 +00:00
|
|
|
Args:
|
|
|
|
fuzzy (string): Uses the fuzzy parameter for the card name.
|
|
|
|
exact (string): Uses the exact parameter for the card name.
|
|
|
|
set (string, optional):
|
|
|
|
Defaults to empty string.
|
|
|
|
Returns the set of the card if specified.
|
|
|
|
Requires the 3 letter set code.
|
|
|
|
format (string, optional):
|
|
|
|
Defaults to 'json'.
|
|
|
|
Returns data in the specified method.
|
|
|
|
face (string, optional):
|
|
|
|
Defaults to empty string.
|
|
|
|
If you're using the `image` format, this will specify if you want the front or back face.
|
|
|
|
version (string, optional):
|
|
|
|
Defaults to empty string.
|
|
|
|
If you're using the `image` format, this will specify if you want the small, normal,
|
|
|
|
large, etc version of the image.
|
|
|
|
pretty (string, optional):
|
|
|
|
Defaults to empty string.
|
|
|
|
Returns a prettier version of the json object.
|
|
|
|
Note that this may break functionality with Scrython.
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
Exception: If the 'fuzzy' or 'exact' parameter is not provided.
|
|
|
|
Exception: If the object returned is an error.
|
2018-10-22 14:19:38 +00:00
|
|
|
|
|
|
|
Example usage:
|
|
|
|
>>> card = scrython.cards.Named(exact="Black Lotus")
|
|
|
|
>>> card.colors()
|
|
|
|
"""
|
|
|
|
def __init__(self, **kwargs):
|
2018-10-24 00:54:28 +00:00
|
|
|
if kwargs.get('exact') is None or kwargs.get('fuzzy') is None:
|
|
|
|
raise Exception('You must provide a `fuzzy` or `exact` parameter.')
|
|
|
|
|
2018-10-22 14:19:38 +00:00
|
|
|
self.dict = {
|
|
|
|
'set':kwargs.get('set', '')
|
|
|
|
}
|
|
|
|
|
|
|
|
if kwargs.get('exact') is not None:
|
|
|
|
self.dict['exact'] = kwargs.get('exact')
|
|
|
|
|
|
|
|
if kwargs.get('fuzzy') is not None:
|
|
|
|
self.dict['fuzzy'] = kwargs.get('fuzzy')
|
|
|
|
|
|
|
|
self.args = urllib.parse.urlencode(self.dict)
|
|
|
|
self.url = 'cards/named?' + self.args
|
|
|
|
super(Named, self).__init__(self.url)
|