Updated docstrings and some functionality. Still working on cards_object
This commit is contained in:
parent
50516684f9
commit
b90946240c
|
@ -7,7 +7,7 @@ class ArenaId(CardsObject):
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
id (string):
|
id (string):
|
||||||
The Scryfall Id of the card.
|
The Arena Id of the card.
|
||||||
format (string, optional):
|
format (string, optional):
|
||||||
Defaults to 'json'.
|
Defaults to 'json'.
|
||||||
Returns data in the specified method.
|
Returns data in the specified method.
|
||||||
|
@ -23,8 +23,9 @@ class ArenaId(CardsObject):
|
||||||
Returns a prettier version of the json object.
|
Returns a prettier version of the json object.
|
||||||
Note that this may break functionality with Scrython.
|
Note that this may break functionality with Scrython.
|
||||||
|
|
||||||
Attributes:
|
Raises:
|
||||||
All attributes are inherited from CardsObject.
|
Exception: If the 'id' parameter is not provided.
|
||||||
|
Exception: If the object returned is an error.
|
||||||
|
|
||||||
Example usage:
|
Example usage:
|
||||||
>>> card = scrython.cards.ArenaId(id="66975")
|
>>> card = scrython.cards.ArenaId(id="66975")
|
||||||
|
@ -32,7 +33,7 @@ class ArenaId(CardsObject):
|
||||||
"""
|
"""
|
||||||
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 Exception('No id provided to search by')
|
||||||
|
|
||||||
self.url = 'cards/arena/{}?'.format(str(kwargs.get('id')))
|
self.url = 'cards/arena/{}?'.format(str(kwargs.get('id')))
|
||||||
super(ArenaId, self).__init__(self.url)
|
super(ArenaId, self).__init__(self.url)
|
||||||
|
|
|
@ -25,13 +25,17 @@ class Autocomplete(CardsObject):
|
||||||
Returns a prettier version of the json object.
|
Returns a prettier version of the json object.
|
||||||
Note that this may break functionality with Scrython.
|
Note that this may break functionality with Scrython.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
Exception: If the 'q' parameter is not provided.
|
||||||
|
Exception: If the object returned is an error.
|
||||||
|
|
||||||
Example usage:
|
Example usage:
|
||||||
>>> auto = scrython.cards.Autocomplete(q="Thal")
|
>>> auto = scrython.cards.Autocomplete(q="Thal")
|
||||||
>>> auto.total_items()
|
>>> auto.total_items()
|
||||||
"""
|
"""
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
if kwargs.get('q') is None:
|
if kwargs.get('q') is None:
|
||||||
raise TypeError('No query provided to search by')
|
raise Exception('No query provided to search by')
|
||||||
|
|
||||||
self.dict = { 'q': kwargs.get('q') }
|
self.dict = { 'q': kwargs.get('q') }
|
||||||
|
|
||||||
|
|
|
@ -5,14 +5,27 @@ class Id(CardsObject):
|
||||||
cards/id
|
cards/id
|
||||||
Get a card by the Scryfall id.
|
Get a card by the Scryfall id.
|
||||||
|
|
||||||
Positional arguments:
|
Args:
|
||||||
id : str ....................... The Scryfall Id of the card.
|
id (string):
|
||||||
|
The Scryfall Id of the card.
|
||||||
|
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.
|
||||||
|
|
||||||
Optional arguments:
|
Raises:
|
||||||
Inherits all arguments from CardsObject.
|
Exception: If the 'id' parameter is not provided.
|
||||||
|
Exception: If the object returned is an error.
|
||||||
Attributes:
|
|
||||||
All attributes are inherited from CardsObject.
|
|
||||||
|
|
||||||
Example usage:
|
Example usage:
|
||||||
>>> card = scrython.cards.Id(id="5386a61c-4928-4bd1-babe-5b089ab8b2d9")
|
>>> card = scrython.cards.Id(id="5386a61c-4928-4bd1-babe-5b089ab8b2d9")
|
||||||
|
@ -20,7 +33,7 @@ class Id(CardsObject):
|
||||||
"""
|
"""
|
||||||
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 Exception('No id provided to search by')
|
||||||
|
|
||||||
self.url = 'cards/{}?'.format(str(kwargs.get('id')))
|
self.url = 'cards/{}?'.format(str(kwargs.get('id')))
|
||||||
super(Id, self).__init__(self.url)
|
super(Id, self).__init__(self.url)
|
||||||
|
|
|
@ -19,18 +19,6 @@ class CardsObject(object):
|
||||||
pretty : str ... Returns a prettier version of the json object. Note that
|
pretty : str ... Returns a prettier version of the json object. Note that
|
||||||
this may break functionality with Scrython.
|
this may break functionality with Scrython.
|
||||||
Attributes:
|
Attributes:
|
||||||
object : str ..... Returns the type of object it is. (card, error, etc)
|
|
||||||
id : str ................................. The scryfall id of the card.
|
|
||||||
multiverse_ids : list ...... The associated multiverse ids of the card.
|
|
||||||
mtgo_id : int ........................ The Magic Online id of the card.
|
|
||||||
mtgo_foil_id : int .............. The Magic Online foil id of the card.
|
|
||||||
name : str ................................. The full name of the card.
|
|
||||||
uri : str .......................... The Scryfall API uri for the card.
|
|
||||||
scryfall_uri : str ................ The full Scryfall page of the card.
|
|
||||||
layout : str ... The image layout of the card. (normal, transform, etc)
|
|
||||||
highres_image : bool ... Returns True if the card has a high res image.
|
|
||||||
image_uris : dict .... All image uris of the card in various qualities.
|
|
||||||
cmc : float ........... A float of the converted mana cost of the card.
|
|
||||||
type_line : str ....................... The full type line of the card.
|
type_line : str ....................... The full type line of the card.
|
||||||
oracle_text : str ................. The official oracle text of a card.
|
oracle_text : str ................. The official oracle text of a card.
|
||||||
mana_cost : str .... The full mana cost using shorthanded mana symbols.
|
mana_cost : str .... The full mana cost using shorthanded mana symbols.
|
||||||
|
@ -112,69 +100,153 @@ class CardsObject(object):
|
||||||
raise Exception(self.scryfallJson['details'])
|
raise Exception(self.scryfallJson['details'])
|
||||||
|
|
||||||
def _checkForKey(self, key):
|
def _checkForKey(self, key):
|
||||||
|
"""Checks for a key in the scryfallJson object.
|
||||||
|
This function should be considered private, and
|
||||||
|
should not be accessed in production.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
key (string): The key to check
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
KeyError: If key is not found.
|
||||||
|
"""
|
||||||
if not key in self.scryfallJson:
|
if not key in self.scryfallJson:
|
||||||
raise KeyError('This card has no key \'{}\''.format(key))
|
raise KeyError('This card has no key \'{}\''.format(key))
|
||||||
|
|
||||||
def _checkForTupleKey(self, parent, num, key):
|
def _checkForTupleKey(self, parent, num, key):
|
||||||
|
"""Checks for a key of an object in an array.
|
||||||
|
This function should be considered private, and
|
||||||
|
should not be accessed in production.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
parent (string): The key for the array to be accessed
|
||||||
|
num (int): The index of the array
|
||||||
|
key (string): The key to check
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
KeyError: If key is not found.
|
||||||
|
"""
|
||||||
if not key in self.scryfallJson[parent][num]:
|
if not key in self.scryfallJson[parent][num]:
|
||||||
raise KeyError('This tuple has no key \'{}\''.format(key))
|
raise KeyError('This tuple has no key \'{}\''.format(key))
|
||||||
|
|
||||||
def object(self):
|
def object(self):
|
||||||
|
"""Returns the type of object it is
|
||||||
|
(card, error, etc)
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
string: The type of object
|
||||||
|
"""
|
||||||
self._checkForKey('object')
|
self._checkForKey('object')
|
||||||
|
|
||||||
return self.scryfallJson['object']
|
return self.scryfallJson['object']
|
||||||
|
|
||||||
def id(self):
|
def id(self):
|
||||||
|
"""A unique ID for the returned card object
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
string: The scryfall id of the card
|
||||||
|
"""
|
||||||
self._checkForKey('id')
|
self._checkForKey('id')
|
||||||
|
|
||||||
return self.scryfallJson['id']
|
return self.scryfallJson['id']
|
||||||
|
|
||||||
def multiverse_ids(self):
|
def multiverse_ids(self):
|
||||||
|
"""The official Gatherer multiverse ids of the card
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list: The associated multiverse ids of the card
|
||||||
|
"""
|
||||||
self._checkForKey('multiverse_ids')
|
self._checkForKey('multiverse_ids')
|
||||||
|
|
||||||
return self.scryfallJson['multiverse_ids']
|
return self.scryfallJson['multiverse_ids']
|
||||||
|
|
||||||
def mtgo_id(self):
|
def mtgo_id(self):
|
||||||
|
"""The official MTGO id of the of the card
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
integer: The Magic Online id of the card
|
||||||
|
"""
|
||||||
self._checkForKey('mtgo_id')
|
self._checkForKey('mtgo_id')
|
||||||
|
|
||||||
return self.scryfallJson['mtgo_id']
|
return self.scryfallJson['mtgo_id']
|
||||||
|
|
||||||
def mtgo_foil_id(self):
|
def mtgo_foil_id(self):
|
||||||
|
"""The corresponding MTGO foil ID of the card
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
integer: The Magic Online foil id of the card
|
||||||
|
"""
|
||||||
self._checkForKey('mtgo_foil_id')
|
self._checkForKey('mtgo_foil_id')
|
||||||
|
|
||||||
return self.scryfallJson['mtgo_foil_id']
|
return self.scryfallJson['mtgo_foil_id']
|
||||||
|
|
||||||
def name(self):
|
def name(self):
|
||||||
|
"""The oracle name of the card
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
string: The card name
|
||||||
|
"""
|
||||||
self._checkForKey('name')
|
self._checkForKey('name')
|
||||||
|
|
||||||
return self.scryfallJson['name']
|
return self.scryfallJson['name']
|
||||||
|
|
||||||
def uri(self):
|
def uri(self):
|
||||||
|
"""The Scryfall API uri for the card
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
string: An API uri for the card
|
||||||
|
"""
|
||||||
self._checkForKey('uri')
|
self._checkForKey('uri')
|
||||||
|
|
||||||
return self.scryfallJson['uri']
|
return self.scryfallJson['uri']
|
||||||
|
|
||||||
def scryfall_uri(self):
|
def scryfall_uri(self):
|
||||||
|
"""The full Scryfall page of the card
|
||||||
|
As if it was a URL from the site.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
string: The Scryfall URL for the card
|
||||||
|
"""
|
||||||
self._checkForKey('scryfall_uri')
|
self._checkForKey('scryfall_uri')
|
||||||
|
|
||||||
return self.scryfallJson['scryfall_uri']
|
return self.scryfallJson['scryfall_uri']
|
||||||
|
|
||||||
def layout(self):
|
def layout(self):
|
||||||
|
"""The image layout of the card. (normal, transform, etc)
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
string: The card layout
|
||||||
|
"""
|
||||||
self._checkForKey('layout')
|
self._checkForKey('layout')
|
||||||
|
|
||||||
return self.scryfallJson['layout']
|
return self.scryfallJson['layout']
|
||||||
|
|
||||||
def highres_image(self):
|
def highres_image(self):
|
||||||
|
"""Determine if a card has a highres scan available
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
boolean: True if card has a highres image available
|
||||||
|
"""
|
||||||
self._checkForKey('highres_image')
|
self._checkForKey('highres_image')
|
||||||
|
|
||||||
return self.scryfallJson['highres_image']
|
return self.scryfallJson['highres_image']
|
||||||
|
|
||||||
def image_uris(self):
|
def image_uris(self):
|
||||||
|
"""All image uris of the card in various qualities
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: The dictionary of image uris
|
||||||
|
"""
|
||||||
self._checkForKey('image_uris')
|
self._checkForKey('image_uris')
|
||||||
|
|
||||||
return self.scryfallJson['image_uris']
|
return self.scryfallJson['image_uris']
|
||||||
|
|
||||||
def cmc(self):
|
def cmc(self):
|
||||||
|
"""A float of the converted mana cost of the card
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
float: The cmc of the card
|
||||||
|
"""
|
||||||
self._checkForKey('cmc')
|
self._checkForKey('cmc')
|
||||||
|
|
||||||
return self.scryfallJson['cmc']
|
return self.scryfallJson['cmc']
|
||||||
|
|
|
@ -5,17 +5,15 @@ class Collector(CardsObject):
|
||||||
cards/collector
|
cards/collector
|
||||||
Get a card by collector number.
|
Get a card by collector number.
|
||||||
|
|
||||||
Positional arguments:
|
Args:
|
||||||
code : str ....................... This is the 3 letter code for the set
|
code (string): This is the 3 letter code for the set
|
||||||
collector_number : str ........ This is the collector number of the card
|
collector_number (string): This is the collector number of the card
|
||||||
|
lang (string, optional): Defaults to 'en'. A 2-3 character language code.
|
||||||
|
|
||||||
Optional arguments:
|
Raises:
|
||||||
Inherits all arguments from CardsObject
|
Exception: If the 'code' parameter is not provided.
|
||||||
|
Exception: If the 'collector_number' parameter is not provided.
|
||||||
lang : str ............................... A 2-3 character language code
|
Exception: If the object returned is an error.
|
||||||
|
|
||||||
Attributes:
|
|
||||||
Inherits all attributes from CardsObject
|
|
||||||
|
|
||||||
Example usage:
|
Example usage:
|
||||||
>>> card = scrython.cards.Collector(code='exo', collector_number='96')
|
>>> card = scrython.cards.Collector(code='exo', collector_number='96')
|
||||||
|
@ -23,7 +21,9 @@ class Collector(CardsObject):
|
||||||
"""
|
"""
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
if kwargs.get('code') is None:
|
if kwargs.get('code') is None:
|
||||||
raise TypeError('No code provided to search by')
|
raise Exception('No code provided to search by')
|
||||||
|
elif kwargs.get('collector_number') is None:
|
||||||
|
raise Exception('No collector number provided to search by')
|
||||||
|
|
||||||
self.url = 'cards/{}/{}/{}?'.format(
|
self.url = 'cards/{}/{}/{}?'.format(
|
||||||
kwargs.get('code'),
|
kwargs.get('code'),
|
||||||
|
|
|
@ -6,14 +6,27 @@ class Mtgo(CardsObject):
|
||||||
cards/mtgo
|
cards/mtgo
|
||||||
Get a card by MTGO id.
|
Get a card by MTGO id.
|
||||||
|
|
||||||
Positional arguments:
|
Args:
|
||||||
id : str ............................. The required mtgo id of the card.
|
id (string):
|
||||||
|
The MTGO Id of the card.
|
||||||
|
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.
|
||||||
|
|
||||||
Optional arguments:
|
Raises:
|
||||||
All arguments are inherited from CardsObject
|
Exception: If the 'id' parameter is not provided.
|
||||||
|
Exception: If the object returned is an error.
|
||||||
Attributes:
|
|
||||||
All attributes are inherited from CardsObject
|
|
||||||
|
|
||||||
Example usage:
|
Example usage:
|
||||||
>>> card = scrython.cards.Mtgo(id="48296")
|
>>> card = scrython.cards.Mtgo(id="48296")
|
||||||
|
|
|
@ -5,14 +5,27 @@ class Multiverse(CardsObject):
|
||||||
cards/multiverse
|
cards/multiverse
|
||||||
Get a card by Multiverse id
|
Get a card by Multiverse id
|
||||||
|
|
||||||
Positional arguments:
|
Args:
|
||||||
id : str ....... This is the associated multiverse id of the given card.
|
id (string):
|
||||||
|
The Multiverse Id of the card.
|
||||||
|
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.
|
||||||
|
|
||||||
Optional arguments:
|
Raises:
|
||||||
Inherits all arguments from CardsObject
|
Exception: If the 'id' parameter is not provided.
|
||||||
|
Exception: If the object returned is an error.
|
||||||
Attributes:
|
|
||||||
Inherits all attributes from CardsObject
|
|
||||||
|
|
||||||
Example usage:
|
Example usage:
|
||||||
>>> card = scrython.cards.Multiverse(id='96865')
|
>>> card = scrython.cards.Multiverse(id='96865')
|
||||||
|
|
|
@ -6,23 +6,40 @@ class Named(CardsObject):
|
||||||
cards/named
|
cards/named
|
||||||
Gets a card by the name.
|
Gets a card by the name.
|
||||||
|
|
||||||
Positional arguments:
|
Args:
|
||||||
fuzzy : str ................ Uses the fuzzy parameter for the card name.
|
fuzzy (string): Uses the fuzzy parameter for the card name.
|
||||||
or
|
exact (string): Uses the exact parameter for the card name.
|
||||||
exact : str ................ 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.
|
||||||
|
|
||||||
Optional arguments:
|
Raises:
|
||||||
set : str . Returns the set of the card if specified. Requires the 3 letter set code.
|
Exception: If the 'fuzzy' or 'exact' parameter is not provided.
|
||||||
All arguments are inherited from CardsObject
|
Exception: If the object returned is an error.
|
||||||
|
|
||||||
Attributes:
|
|
||||||
All attributes are inherited from CardsObject
|
|
||||||
|
|
||||||
Example usage:
|
Example usage:
|
||||||
>>> card = scrython.cards.Named(exact="Black Lotus")
|
>>> card = scrython.cards.Named(exact="Black Lotus")
|
||||||
>>> card.colors()
|
>>> card.colors()
|
||||||
"""
|
"""
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
if kwargs.get('exact') is None or kwargs.get('fuzzy') is None:
|
||||||
|
raise Exception('You must provide a `fuzzy` or `exact` parameter.')
|
||||||
|
|
||||||
self.dict = {
|
self.dict = {
|
||||||
'set':kwargs.get('set', '')
|
'set':kwargs.get('set', '')
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,14 +6,25 @@ class Random(CardsObject):
|
||||||
cards/random
|
cards/random
|
||||||
Get a random card.
|
Get a random card.
|
||||||
|
|
||||||
Positional arguments:
|
Args:
|
||||||
No arguments are required.
|
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.
|
||||||
|
|
||||||
Optional arguments:
|
Raises:
|
||||||
All arguments are inherited from CardsObject
|
Exception: If the object returned is an error.
|
||||||
|
|
||||||
Attributes:
|
|
||||||
All attributes are inherited from CardsObject
|
|
||||||
|
|
||||||
Example usage:
|
Example usage:
|
||||||
>>> card = scrython.cards.Random()
|
>>> card = scrython.cards.Random()
|
||||||
|
|
|
@ -6,28 +6,46 @@ class Search(CardsObject):
|
||||||
cards/search
|
cards/search
|
||||||
Uses a search query to gather relevant data.
|
Uses a search query to gather relevant data.
|
||||||
|
|
||||||
Positional arguments:
|
Args:
|
||||||
q : str ...... The query to search. This will be updated in the future.
|
q (string):
|
||||||
|
The query to search. This will be updated in the future.
|
||||||
Optional arguments:
|
order (string, optional):
|
||||||
order : str ................... The order you'd like the data returned.
|
Defaults to 'none'
|
||||||
unique : str ........................... A way to filter similar cards.
|
The order you'd like the data returned.
|
||||||
dir : str ......... The direction you'd like to sort. (asc, desc, auto)
|
unique (string, optional):
|
||||||
include_extras : bool ... Includes cards that are normally omitted from
|
Defaults to 'none'
|
||||||
search results, like Un-sets.
|
A way to filter similar cards.
|
||||||
page : int .............. The page number you'd like to search, if any.
|
dir (string, optional)
|
||||||
Inherits all arguments from CardsObject.
|
Defaults to 'none'
|
||||||
|
The direction you'd like to sort. (asc, desc, auto)
|
||||||
Attributes:
|
include_extras (boolean, optional):
|
||||||
object : str ....................... Returns what kind of object it is.
|
Defaults to 'false'
|
||||||
total_cards : int ......... How many cards are returned from the query.
|
Includes cards that are normally omitted from search results, like Un-sets.
|
||||||
data : list ...................... The list of potential autocompletes.
|
include_multilingual (boolean, optional):
|
||||||
has_more : bool ......... True if there is more than 1 page of results.
|
Defaults to 'false'
|
||||||
next_page : str ............ The API URI to the next page of the query.
|
Includes cards that are in the language specified. (en, ja, etc).
|
||||||
warnings : list .................. Provides an array of errors, if any.
|
page (integer, optional):
|
||||||
data_length : int .................... The length of the data returned.
|
Defaults to '1'
|
||||||
data_tuple : dict .......... Accesses an object at the specified index.
|
The page number you'd like to search, if any.
|
||||||
|
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 'q' parameter is not provided.
|
||||||
|
Exception: If the object returned is an error.
|
||||||
|
|
||||||
Example usage:
|
Example usage:
|
||||||
>>> search = scrython.cards.Search(q="++e:A25", order="spoiled")
|
>>> search = scrython.cards.Search(q="++e:A25", order="spoiled")
|
||||||
|
@ -35,7 +53,7 @@ class Search(CardsObject):
|
||||||
"""
|
"""
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
if kwargs.get('q') is None:
|
if kwargs.get('q') is None:
|
||||||
raise TypeError('No query is specified.')
|
raise Exception('No query is specified.')
|
||||||
|
|
||||||
self.dict = {
|
self.dict = {
|
||||||
'q':kwargs.get('q'),
|
'q':kwargs.get('q'),
|
||||||
|
@ -52,220 +70,141 @@ class Search(CardsObject):
|
||||||
|
|
||||||
super(Search, self).__init__(self.url)
|
super(Search, self).__init__(self.url)
|
||||||
|
|
||||||
|
# The following block of methods are not compatible with object returned from
|
||||||
|
# the cards/autocomplete endpoint. Doing it this way as to not repeat defining another
|
||||||
|
# getRequest function in the __init__. Will be refactored in the future.
|
||||||
|
del CardsObject.id
|
||||||
|
del CardsObject.multiverse_ids
|
||||||
|
del CardsObject.mtgo_id
|
||||||
|
del CardsObject.mtgo_foil_id
|
||||||
|
del CardsObject.name
|
||||||
|
del CardsObject.uri
|
||||||
|
del CardsObject.scryfall_uri
|
||||||
|
del CardsObject.layout
|
||||||
|
del CardsObject.highres_image
|
||||||
|
del CardsObject.image_uris
|
||||||
|
del CardsObject.cmc
|
||||||
|
del CardsObject.type_line
|
||||||
|
del CardsObject.oracle_text
|
||||||
|
del CardsObject.mana_cost
|
||||||
|
del CardsObject.colors
|
||||||
|
del CardsObject.color_identity
|
||||||
|
del CardsObject.legalities
|
||||||
|
del CardsObject.reserved
|
||||||
|
del CardsObject.reprint
|
||||||
|
del CardsObject.set_code
|
||||||
|
del CardsObject.set_name
|
||||||
|
del CardsObject.set_uri
|
||||||
|
del CardsObject.set_search_uri
|
||||||
|
del CardsObject.scryfall_set_uri
|
||||||
|
del CardsObject.rulings_uri
|
||||||
|
del CardsObject.prints_search_uri
|
||||||
|
del CardsObject.collector_number
|
||||||
|
del CardsObject.digital
|
||||||
|
del CardsObject.rarity
|
||||||
|
del CardsObject.illustration_id
|
||||||
|
del CardsObject.artist
|
||||||
|
del CardsObject.frame
|
||||||
|
del CardsObject.full_art
|
||||||
|
del CardsObject.border_color
|
||||||
|
del CardsObject.timeshifted
|
||||||
|
del CardsObject.colorshifted
|
||||||
|
del CardsObject.futureshifted
|
||||||
|
del CardsObject.edhrec_rank
|
||||||
|
del CardsObject.currency
|
||||||
|
del CardsObject.related_uris
|
||||||
|
del CardsObject.purchase_uris
|
||||||
|
del CardsObject.life_modifier
|
||||||
|
del CardsObject.hand_modifier
|
||||||
|
del CardsObject.color_indicator
|
||||||
|
del CardsObject.all_parts
|
||||||
|
del CardsObject.card_faces
|
||||||
|
del CardsObject.watermark
|
||||||
|
del CardsObject.story_spotlight
|
||||||
|
del CardsObject.power
|
||||||
|
del CardsObject.toughness
|
||||||
|
del CardsObject.loyalty
|
||||||
|
del CardsObject.flavor_text
|
||||||
|
del CardsObject.arena_id
|
||||||
|
del CardsObject.lang
|
||||||
|
del CardsObject.printed_name
|
||||||
|
del CardsObject.printed_type_line
|
||||||
|
del CardsObject.printed_text
|
||||||
|
del CardsObject.oracle_id
|
||||||
|
del CardsObject.foil
|
||||||
|
del CardsObject.nonfoil
|
||||||
|
del CardsObject.oversized
|
||||||
|
|
||||||
def object(self):
|
def object(self):
|
||||||
|
"""Returns the type of object it is.
|
||||||
|
(card, error, etc)
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
string: The type of object
|
||||||
|
"""
|
||||||
super(Search, self)._checkForKey('object')
|
super(Search, self)._checkForKey('object')
|
||||||
|
|
||||||
return self.scryfallJson['object']
|
return self.scryfallJson['object']
|
||||||
|
|
||||||
def total_cards(self):
|
def total_cards(self):
|
||||||
|
"""How many cards are returned from the query
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
integer: The number of cards returned
|
||||||
|
"""
|
||||||
super(Search, self)._checkForKey('total_cards')
|
super(Search, self)._checkForKey('total_cards')
|
||||||
|
|
||||||
return self.scryfallJson['total_cards']
|
return self.scryfallJson['total_cards']
|
||||||
|
|
||||||
def data(self):
|
def data(self):
|
||||||
|
"""The data returned from the query
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list: A list of card objects
|
||||||
|
"""
|
||||||
super(Search, self)._checkForKey('data')
|
super(Search, self)._checkForKey('data')
|
||||||
|
|
||||||
return self.scryfallJson['data']
|
return self.scryfallJson['data']
|
||||||
|
|
||||||
def next_page(self):
|
def next_page(self):
|
||||||
|
"""The API URI to the next page of the query
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
string: A URI to the next page of the query
|
||||||
|
"""
|
||||||
super(Search, self)._checkForKey('next_page')
|
super(Search, self)._checkForKey('next_page')
|
||||||
|
|
||||||
return self.scryfallJson['next_page']
|
return self.scryfallJson['next_page']
|
||||||
|
|
||||||
def data_length(self):
|
def data_length(self):
|
||||||
|
"""
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
integer: The length of data returned
|
||||||
|
"""
|
||||||
super(Search, self)._checkForKey('data')
|
super(Search, self)._checkForKey('data')
|
||||||
|
|
||||||
return len(self.scryfallJson['data'])
|
return len(self.scryfallJson['data'])
|
||||||
|
|
||||||
def data_tuple(self, num):
|
def data_tuple(self, num):
|
||||||
|
"""Accesses an object at the specified index
|
||||||
|
|
||||||
|
Args:
|
||||||
|
num (int): The index of the object in the `data` key
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: The card object at the specified index
|
||||||
|
"""
|
||||||
super(Search, self)._checkForKey('data')
|
super(Search, self)._checkForKey('data')
|
||||||
|
|
||||||
return self.scryfallJson['data'][num]
|
return self.scryfallJson['data'][num]
|
||||||
|
|
||||||
def has_more(self):
|
def has_more(self):
|
||||||
|
"""Determines if there are more pages of results.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
boolean: True if there is more than 1 page of results
|
||||||
|
"""
|
||||||
super(Search, self)._checkForKey('has_more')
|
super(Search, self)._checkForKey('has_more')
|
||||||
|
|
||||||
return self.scryfallJson['has_more']
|
return self.scryfallJson['has_more']
|
||||||
|
|
||||||
#The following attributes are only to override the inherited class attributes.
|
|
||||||
#This class has no matching attributes but we still need the getRequest function from CardsObject
|
|
||||||
|
|
||||||
def id(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'id\'')
|
|
||||||
|
|
||||||
def multiverse_ids(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'multiverse_ids\'')
|
|
||||||
|
|
||||||
def mtgo_id(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'mtgo_id\'')
|
|
||||||
|
|
||||||
def mtgo_foil_id(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'mtgo_foil_id\'')
|
|
||||||
|
|
||||||
def name(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'name\'')
|
|
||||||
|
|
||||||
def uri(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'uri\'')
|
|
||||||
|
|
||||||
def scryfall_uri(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'scryfall_uri\'')
|
|
||||||
|
|
||||||
def layout(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'layout\'')
|
|
||||||
|
|
||||||
def highres_image(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'highres_image\'')
|
|
||||||
|
|
||||||
def image_uris(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'image_uris\'')
|
|
||||||
|
|
||||||
def cmc(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'cmc\'')
|
|
||||||
|
|
||||||
def type_line(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'type_line\'')
|
|
||||||
|
|
||||||
def oracle_text(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'oracle_text\'')
|
|
||||||
|
|
||||||
def mana_cost(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'mana_cost\'')
|
|
||||||
|
|
||||||
def colors(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'colors\'')
|
|
||||||
|
|
||||||
def color_identity(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'color_identity\'')
|
|
||||||
|
|
||||||
def legalities(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'legalities\'')
|
|
||||||
|
|
||||||
def reserved(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'reserved\'')
|
|
||||||
|
|
||||||
def reprint(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'reprint\'')
|
|
||||||
|
|
||||||
def set_code(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'set_code\'')
|
|
||||||
|
|
||||||
def set_name(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'set_name\'')
|
|
||||||
|
|
||||||
def set_uri(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'set_uri\'')
|
|
||||||
|
|
||||||
def set_search_uri(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'set_search_uri\'')
|
|
||||||
|
|
||||||
def scryfall_set_uri(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'scryfall_set_uri\'')
|
|
||||||
|
|
||||||
def rulings_uri(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'rulings_uri\'')
|
|
||||||
|
|
||||||
def prints_search_uri(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'prints_search_uri\'')
|
|
||||||
|
|
||||||
def collector_number(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'collector_number\'')
|
|
||||||
|
|
||||||
def digital(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'digital\'')
|
|
||||||
|
|
||||||
def rarity(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'rarity\'')
|
|
||||||
|
|
||||||
def illustration_id(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'illustration_id\'')
|
|
||||||
|
|
||||||
def artist(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'artist\'')
|
|
||||||
|
|
||||||
def frame(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'frame\'')
|
|
||||||
|
|
||||||
def full_art(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'full_art\'')
|
|
||||||
|
|
||||||
def border_color(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'border_color\'')
|
|
||||||
|
|
||||||
def timeshifted(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'timeshifted\'')
|
|
||||||
|
|
||||||
def colorshifted(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'colorshifted\'')
|
|
||||||
|
|
||||||
def futureshifted(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'futureshifted\'')
|
|
||||||
|
|
||||||
def edhrec_rank(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'edhrec_rank\'')
|
|
||||||
|
|
||||||
def currency(self, mode):
|
|
||||||
raise AttributeError('Search object has no attribute \'currency\'')
|
|
||||||
|
|
||||||
def related_uris(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'related_uris\'')
|
|
||||||
|
|
||||||
def purchase_uris(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'purchase_uris\'')
|
|
||||||
|
|
||||||
def life_modifier(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'life_modifier\'')
|
|
||||||
|
|
||||||
def hand_modifier(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'hand_modifier\'')
|
|
||||||
|
|
||||||
def color_indicator(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'color_indicator\'')
|
|
||||||
|
|
||||||
def all_parts(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'all_parts\'')
|
|
||||||
|
|
||||||
def card_faces(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'card_faces\'')
|
|
||||||
|
|
||||||
def watermark(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'watermark\'')
|
|
||||||
|
|
||||||
def story_spotlight(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'story_spotlight\'')
|
|
||||||
|
|
||||||
def power(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'power\'')
|
|
||||||
|
|
||||||
def toughness(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'toughness\'')
|
|
||||||
|
|
||||||
def loyalty(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'loyalty\'')
|
|
||||||
|
|
||||||
def flavor_text(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'flavor_text\'')
|
|
||||||
|
|
||||||
def arena_id(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'arena_id\'')
|
|
||||||
|
|
||||||
def lang(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'lang\'')
|
|
||||||
|
|
||||||
def printed_name(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'printed_name\'')
|
|
||||||
|
|
||||||
def printed_type_line(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'printed_type_line\'')
|
|
||||||
|
|
||||||
def printed_text(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'printed_text\'')
|
|
||||||
|
|
||||||
def oracle_id(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'oracle_id\'')
|
|
||||||
|
|
||||||
def nonfoil(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'nonfoil\'')
|
|
||||||
|
|
||||||
def oversized(self):
|
|
||||||
raise AttributeError('Search object has no attribute \'oversized\'')
|
|
||||||
|
|
Loading…
Reference in New Issue