Updated to use spaces over tabs.
This commit is contained in:
parent
0c6c04af5e
commit
c684bb7eb1
|
@ -1,5 +1,14 @@
|
|||
# Changelog
|
||||
|
||||
## 1.6.0
|
||||
|
||||
New stuff
|
||||
|
||||
Changes
|
||||
- Scrython has been changed to use spaces rather than tabs.
|
||||
|
||||
Bugfixes
|
||||
|
||||
## 1.5.0
|
||||
|
||||
New stuff
|
||||
|
|
|
@ -2,200 +2,200 @@ from .cards_object import CardsObject
|
|||
import urllib.parse
|
||||
|
||||
class Autocomplete(CardsObject):
|
||||
"""
|
||||
cards/autocomplete
|
||||
Get a list of potential autocompletion phrases.
|
||||
"""
|
||||
cards/autocomplete
|
||||
Get a list of potential autocompletion phrases.
|
||||
|
||||
Positional arguments:
|
||||
q : str ........... The query of the autocompletion.
|
||||
Positional arguments:
|
||||
q : str ........... The query of the autocompletion.
|
||||
|
||||
Optional arguments:
|
||||
Inherits arguments from CardsObject.
|
||||
Optional arguments:
|
||||
Inherits arguments from CardsObject.
|
||||
|
||||
Attributes:
|
||||
object : str ........ Returns what kind of object it is.
|
||||
total_items : int ...... How many items are in the list.
|
||||
data : list ....... The list of potential autocompletes.
|
||||
Attributes:
|
||||
object : str ........ Returns what kind of object it is.
|
||||
total_items : int ...... How many items are in the list.
|
||||
data : list ....... The list of potential autocompletes.
|
||||
|
||||
Example usage:
|
||||
>>> auto = scrython.cards.Autocomplete(q="Thal")
|
||||
>>> auto.total_items()
|
||||
"""
|
||||
def __init__(self, **kwargs):
|
||||
if kwargs.get('q') is None:
|
||||
raise TypeError('No query provided to search by')
|
||||
Example usage:
|
||||
>>> auto = scrython.cards.Autocomplete(q="Thal")
|
||||
>>> auto.total_items()
|
||||
"""
|
||||
def __init__(self, **kwargs):
|
||||
if kwargs.get('q') is None:
|
||||
raise TypeError('No query provided to search by')
|
||||
|
||||
self.dict = {
|
||||
'q': kwargs.get('q'),
|
||||
'pretty': kwargs.get('pretty', 'false'),
|
||||
'format': kwargs.get('format', 'json')
|
||||
}
|
||||
self.dict = {
|
||||
'q': kwargs.get('q'),
|
||||
'pretty': kwargs.get('pretty', 'false'),
|
||||
'format': kwargs.get('format', 'json')
|
||||
}
|
||||
|
||||
self.args = urllib.parse.urlencode(self.dict)
|
||||
self.url = 'cards/autocomplete?' + self.args
|
||||
super(Autocomplete, self).__init__(self.url)
|
||||
self.args = urllib.parse.urlencode(self.dict)
|
||||
self.url = 'cards/autocomplete?' + self.args
|
||||
super(Autocomplete, self).__init__(self.url)
|
||||
|
||||
def object(self):
|
||||
super(Autocomplete, self)._checkForKey('object')
|
||||
def object(self):
|
||||
super(Autocomplete, self)._checkForKey('object')
|
||||
|
||||
return self.scryfallJson['object']
|
||||
return self.scryfallJson['object']
|
||||
|
||||
def total_items(self):
|
||||
super(Autocomplete, self)._checkForKey('total_items')
|
||||
def total_items(self):
|
||||
super(Autocomplete, self)._checkForKey('total_items')
|
||||
|
||||
return self.scryfallJson['total_items']
|
||||
return self.scryfallJson['total_items']
|
||||
|
||||
def data(self):
|
||||
super(Autocomplete, self)._checkForKey('data')
|
||||
def data(self):
|
||||
super(Autocomplete, self)._checkForKey('data')
|
||||
|
||||
return self.scryfallJson['data']
|
||||
return self.scryfallJson['data']
|
||||
|
||||
#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
|
||||
#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 id(self):
|
||||
raise AttributeError('Search object has no attribute \'id\'')
|
||||
|
||||
def multiverse_ids(self):
|
||||
raise AttributeError('Search object has no attribute \'multiverse_ids\'')
|
||||
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_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 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 name(self):
|
||||
raise AttributeError('Search object has no attribute \'name\'')
|
||||
|
||||
def uri(self):
|
||||
raise AttributeError('Search object has no attribute \'uri\'')
|
||||
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 scryfall_uri(self):
|
||||
raise AttributeError('Search object has no attribute \'scryfall_uri\'')
|
||||
|
||||
def layout(self):
|
||||
raise AttributeError('Search object has no attribute \'layout\'')
|
||||
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 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 image_uris(self):
|
||||
raise AttributeError('Search object has no attribute \'image_uris\'')
|
||||
|
||||
def cmc(self):
|
||||
raise AttributeError('Search object has no attribute \'cmc\'')
|
||||
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 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 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 mana_cost(self):
|
||||
raise AttributeError('Search object has no attribute \'mana_cost\'')
|
||||
|
||||
def colors(self):
|
||||
raise AttributeError('Search object has no attribute \'colors\'')
|
||||
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 color_identity(self):
|
||||
raise AttributeError('Search object has no attribute \'color_identity\'')
|
||||
|
||||
def legalities(self):
|
||||
raise AttributeError('Search object has no attribute \'legalities\'')
|
||||
def legalities(self):
|
||||
raise AttributeError('Search object has no attribute \'legalities\'')
|
||||
|
||||
def reserved(self):
|
||||
raise AttributeError('Search object has no attribute \'reserved\'')
|
||||
def reserved(self):
|
||||
raise AttributeError('Search object has no attribute \'reserved\'')
|
||||
|
||||
def reprint(self):
|
||||
raise AttributeError('Search object has no attribute \'reprint\'')
|
||||
def reprint(self):
|
||||
raise AttributeError('Search object has no attribute \'reprint\'')
|
||||
|
||||
def set_code(self):
|
||||
raise AttributeError('Search object has no attribute \' def set_code\'')
|
||||
def set_code(self):
|
||||
raise AttributeError('Search object has no attribute \' def set_code\'')
|
||||
|
||||
def set_name(self):
|
||||
raise AttributeError('Search object has no attribute \' def set_name\'')
|
||||
def set_name(self):
|
||||
raise AttributeError('Search object has no attribute \' def set_name\'')
|
||||
|
||||
def set_uri(self):
|
||||
raise AttributeError('Search object has no attribute \'set_uri\'')
|
||||
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 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 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 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 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 collector_number(self):
|
||||
raise AttributeError('Search object has no attribute \'collector_number\'')
|
||||
|
||||
def digital(self):
|
||||
raise AttributeError('Search object has no attribute \'digital\'')
|
||||
def digital(self):
|
||||
raise AttributeError('Search object has no attribute \'digital\'')
|
||||
|
||||
def rarity(self):
|
||||
raise AttributeError('Search object has no attribute \'rarity\'')
|
||||
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 illustration_id(self):
|
||||
raise AttributeError('Search object has no attribute \'illustration_id\'')
|
||||
|
||||
def artist(self):
|
||||
raise AttributeError('Search object has no attribute \'artist\'')
|
||||
def artist(self):
|
||||
raise AttributeError('Search object has no attribute \'artist\'')
|
||||
|
||||
def frame(self):
|
||||
raise AttributeError('Search object has no attribute \'frame\'')
|
||||
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 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 border_color(self):
|
||||
raise AttributeError('Search object has no attribute \'border_color\'')
|
||||
|
||||
def timeshifted(self):
|
||||
raise AttributeError('Search object has no attribute \'timeshifted\'')
|
||||
def timeshifted(self):
|
||||
raise AttributeError('Search object has no attribute \'timeshifted\'')
|
||||
|
||||
def colorshifted(self):
|
||||
raise AttributeError('Search object has no attribute \'colorshifted\'')
|
||||
def colorshifted(self):
|
||||
raise AttributeError('Search object has no attribute \'colorshifted\'')
|
||||
|
||||
def futureshifted(self):
|
||||
raise AttributeError('Search object has no attribute \'futureshifted\'')
|
||||
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 edhrec_rank(self):
|
||||
raise AttributeError('Search object has no attribute \'edhrec_rank\'')
|
||||
|
||||
def currency(self, mode):
|
||||
raise AttributeError('Search object has no attribute \'currency(self,\'')
|
||||
def currency(self, mode):
|
||||
raise AttributeError('Search object has no attribute \'currency(self,\'')
|
||||
|
||||
def related_uris(self):
|
||||
raise AttributeError('Search object has no attribute \'related_uris\'')
|
||||
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 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 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 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 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 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 card_faces(self):
|
||||
raise AttributeError('Search object has no attribute \'card_faces\'')
|
||||
|
||||
def watermark(self):
|
||||
raise AttributeError('Search object has no attribute \'watermark\'')
|
||||
def watermark(self):
|
||||
raise AttributeError('Search object has no attribute \'watermark\'')
|
||||
|
||||
def story_spotlight_number(self):
|
||||
raise AttributeError('Search object has no attribute \'story_spotlight_number\'')
|
||||
def story_spotlight_number(self):
|
||||
raise AttributeError('Search object has no attribute \'story_spotlight_number\'')
|
||||
|
||||
def story_spotlight_uri(self):
|
||||
raise AttributeError('Search object has no attribute \'story_spotlight_uri\'')
|
||||
def story_spotlight_uri(self):
|
||||
raise AttributeError('Search object has no attribute \'story_spotlight_uri\'')
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
from .cards_object import CardsObject
|
||||
|
||||
class Id(CardsObject):
|
||||
"""
|
||||
cards/id
|
||||
Get a card by the Scryfall id.
|
||||
"""
|
||||
cards/id
|
||||
Get a card by the Scryfall id.
|
||||
|
||||
Positional arguments:
|
||||
id : str ....................... The Scryfall Id of the card.
|
||||
Positional arguments:
|
||||
id : str ....................... The Scryfall Id of the card.
|
||||
|
||||
Optional arguments:
|
||||
Inherits all arguments from CardsObject.
|
||||
Optional arguments:
|
||||
Inherits all arguments from CardsObject.
|
||||
|
||||
Attributes:
|
||||
All attributes are inherited from CardsObject.
|
||||
Attributes:
|
||||
All attributes are inherited from CardsObject.
|
||||
|
||||
Example usage:
|
||||
>>> card = scrython.cards.Id(id="5386a61c-4928-4bd1-babe-5b089ab8b2d9")
|
||||
>>> card.name()
|
||||
"""
|
||||
def __init__(self, **kwargs):
|
||||
if kwargs.get('id') is None:
|
||||
raise TypeError('No id provided to search by')
|
||||
Example usage:
|
||||
>>> card = scrython.cards.Id(id="5386a61c-4928-4bd1-babe-5b089ab8b2d9")
|
||||
>>> card.name()
|
||||
"""
|
||||
def __init__(self, **kwargs):
|
||||
if kwargs.get('id') is None:
|
||||
raise TypeError('No id provided to search by')
|
||||
|
||||
self.url = 'cards/{}?'.format(str(kwargs.get('id')))
|
||||
super(Id, self).__init__(self.url)
|
||||
self.url = 'cards/{}?'.format(str(kwargs.get('id')))
|
||||
super(Id, self).__init__(self.url)
|
||||
|
|
|
@ -4,412 +4,412 @@ import urllib.parse
|
|||
from threading import Thread
|
||||
|
||||
class CardsObject(object):
|
||||
"""
|
||||
Master class that all card objects inherit from.
|
||||
|
||||
Positional arguments:
|
||||
No positional arguments are 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)
|
||||
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.
|
||||
oracle_text : str ................. The official oracle text of a card.
|
||||
mana_cost : str .... The full mana cost using shorthanded mana symbols.
|
||||
colors : list ... An array of strings with all colors found in the mana cost.
|
||||
color_identity : list ... An array of strings with all colors found on the card itself.
|
||||
legalities : dict ..... A dictionary of all formats and their legality.
|
||||
reserved : bool ..... Returns True if the card is on the reserved list.
|
||||
reprint : bool .... Returns True if the card has been reprinted before.
|
||||
set_code : str ............. The 3 letter code for the set of the card.
|
||||
set_name : str ................. The full name for the set of the card.
|
||||
set_uri : str .......... The API uri for the full set list of the card.
|
||||
set_search_uri : str .......................... Same output as set_uri.
|
||||
scryfall_set_uri : str .......... The full link to the set on Scryfall.
|
||||
rulings_uri : str ............ The API uri for the rulings of the card.
|
||||
prints_search_uri : str ... A link to where you can begin paginating all re/prints for this card on Scryfall’s API.
|
||||
collector_number : str .............. The collector number of the card.
|
||||
digital : bool ....... Returns True if the card is the digital version.
|
||||
rarity : str .................................. The rarity of the card.
|
||||
illuStringation_id : str .............. The related id of the card art.
|
||||
artist : str .................................. The artist of the card.
|
||||
frame : str ............................... The year of the card frame.
|
||||
full_art : bool ...... Returns True if the card is considered full art.
|
||||
border_color : str ...................... The color of the card border.
|
||||
timeshifted : bool ........... Returns True if the card is timeshifted.
|
||||
colorshifted : bool ......... Returns True if the card is colorshifted.
|
||||
futureshifted : bool ....... Returns True if the card is futureshifted.
|
||||
edhrec_rank : int .................. The rank of the card on edhrec.com
|
||||
currency("<mode>")` : str ... Returns currency from modes `usd`, `eur`, and `tix`.
|
||||
related_uris : dict ... A dictionary of related websites for this card.
|
||||
purchase_uris : dict ...... A dictionary of links to purchase the card.
|
||||
life_modifier : str ... This is the cards life modifier value, assuming it's a Vanguard card.
|
||||
hand_modifier : str ... This cards hand modifier value, assuming it's a Vanguard card.
|
||||
color_indicator : list ... An array of all colors found in this card's color indicator.
|
||||
all_parts : list ... This this card is closely related to other cards, this property will be an array with it.
|
||||
card_faces : list ... If it exists, all parts found on a card's face will be found as an object from this array.
|
||||
watermark : str ......... The associated watermark of the card, if any.
|
||||
story_spotlight_number : int ... This card's story spotlight number, if any.
|
||||
story_spotlight_uri : str ... The URI for the card's story article, if any.
|
||||
power : str ................. The power of the creature, if applicable.
|
||||
toughness : str ......... The toughness of the creature, if applicable.
|
||||
flavor_text : str ................ The flavor text of the card, if any.
|
||||
arena_id : int ...................... The Arena ID of the card, if any.
|
||||
lang : str ... The language of the card.
|
||||
printed_name : str .. If the card is in a non-English language, this will be the name as it appears on the card.
|
||||
printed_type_line : str .. If the card is in a non-English language, this will be the type line as it appears on the card.
|
||||
printed_text : str ... If the card is in a non-English language, this will be the rules text as it appears on the card.
|
||||
"""
|
||||
def __init__(self, _url, **kwargs):
|
||||
|
||||
self.params = {
|
||||
'format': kwargs.get('format', 'json'), 'face': kwargs.get('face', ''),
|
||||
'version': kwargs.get('version', ''), 'pretty': kwargs.get('pretty', '')
|
||||
}
|
||||
|
||||
self.encodedParams = urllib.parse.urlencode(self.params)
|
||||
self._url = 'https://api.scryfall.com/{0}&{1}'.format(_url, self.encodedParams)
|
||||
|
||||
async def getRequest(client, url, **kwargs):
|
||||
async with client.get(url, **kwargs) as response:
|
||||
return await response.json()
|
||||
|
||||
async def main(loop):
|
||||
async with aiohttp.ClientSession(loop=loop) as client:
|
||||
self.scryfallJson = await getRequest(client, self._url)
|
||||
|
||||
def do_everything():
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
loop.run_until_complete(main(loop))
|
||||
|
||||
t = Thread(target=do_everything)
|
||||
t.run()
|
||||
|
||||
if self.scryfallJson['object'] == 'error':
|
||||
raise Exception(self.scryfallJson['details'])
|
||||
|
||||
def _checkForKey(self, key):
|
||||
if not key in self.scryfallJson:
|
||||
raise KeyError('This card has no key \'{}\''.format(key))
|
||||
|
||||
def _checkForTupleKey(self, parent, num, key):
|
||||
if not key in self.scryfallJson[parent][num]:
|
||||
raise KeyError('This tuple has no key \'{}\''.format(key))
|
||||
"""
|
||||
Master class that all card objects inherit from.
|
||||
|
||||
Positional arguments:
|
||||
No positional arguments are 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)
|
||||
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.
|
||||
oracle_text : str ................. The official oracle text of a card.
|
||||
mana_cost : str .... The full mana cost using shorthanded mana symbols.
|
||||
colors : list ... An array of strings with all colors found in the mana cost.
|
||||
color_identity : list ... An array of strings with all colors found on the card itself.
|
||||
legalities : dict ..... A dictionary of all formats and their legality.
|
||||
reserved : bool ..... Returns True if the card is on the reserved list.
|
||||
reprint : bool .... Returns True if the card has been reprinted before.
|
||||
set_code : str ............. The 3 letter code for the set of the card.
|
||||
set_name : str ................. The full name for the set of the card.
|
||||
set_uri : str .......... The API uri for the full set list of the card.
|
||||
set_search_uri : str .......................... Same output as set_uri.
|
||||
scryfall_set_uri : str .......... The full link to the set on Scryfall.
|
||||
rulings_uri : str ............ The API uri for the rulings of the card.
|
||||
prints_search_uri : str ... A link to where you can begin paginating all re/prints for this card on Scryfall’s API.
|
||||
collector_number : str .............. The collector number of the card.
|
||||
digital : bool ....... Returns True if the card is the digital version.
|
||||
rarity : str .................................. The rarity of the card.
|
||||
illuStringation_id : str .............. The related id of the card art.
|
||||
artist : str .................................. The artist of the card.
|
||||
frame : str ............................... The year of the card frame.
|
||||
full_art : bool ...... Returns True if the card is considered full art.
|
||||
border_color : str ...................... The color of the card border.
|
||||
timeshifted : bool ........... Returns True if the card is timeshifted.
|
||||
colorshifted : bool ......... Returns True if the card is colorshifted.
|
||||
futureshifted : bool ....... Returns True if the card is futureshifted.
|
||||
edhrec_rank : int .................. The rank of the card on edhrec.com
|
||||
currency("<mode>")` : str ... Returns currency from modes `usd`, `eur`, and `tix`.
|
||||
related_uris : dict ... A dictionary of related websites for this card.
|
||||
purchase_uris : dict ...... A dictionary of links to purchase the card.
|
||||
life_modifier : str ... This is the cards life modifier value, assuming it's a Vanguard card.
|
||||
hand_modifier : str ... This cards hand modifier value, assuming it's a Vanguard card.
|
||||
color_indicator : list ... An array of all colors found in this card's color indicator.
|
||||
all_parts : list ... This this card is closely related to other cards, this property will be an array with it.
|
||||
card_faces : list ... If it exists, all parts found on a card's face will be found as an object from this array.
|
||||
watermark : str ......... The associated watermark of the card, if any.
|
||||
story_spotlight_number : int ... This card's story spotlight number, if any.
|
||||
story_spotlight_uri : str ... The URI for the card's story article, if any.
|
||||
power : str ................. The power of the creature, if applicable.
|
||||
toughness : str ......... The toughness of the creature, if applicable.
|
||||
flavor_text : str ................ The flavor text of the card, if any.
|
||||
arena_id : int ...................... The Arena ID of the card, if any.
|
||||
lang : str ... The language of the card.
|
||||
printed_name : str .. If the card is in a non-English language, this will be the name as it appears on the card.
|
||||
printed_type_line : str .. If the card is in a non-English language, this will be the type line as it appears on the card.
|
||||
printed_text : str ... If the card is in a non-English language, this will be the rules text as it appears on the card.
|
||||
"""
|
||||
def __init__(self, _url, **kwargs):
|
||||
|
||||
self.params = {
|
||||
'format': kwargs.get('format', 'json'), 'face': kwargs.get('face', ''),
|
||||
'version': kwargs.get('version', ''), 'pretty': kwargs.get('pretty', '')
|
||||
}
|
||||
|
||||
self.encodedParams = urllib.parse.urlencode(self.params)
|
||||
self._url = 'https://api.scryfall.com/{0}&{1}'.format(_url, self.encodedParams)
|
||||
|
||||
async def getRequest(client, url, **kwargs):
|
||||
async with client.get(url, **kwargs) as response:
|
||||
return await response.json()
|
||||
|
||||
async def main(loop):
|
||||
async with aiohttp.ClientSession(loop=loop) as client:
|
||||
self.scryfallJson = await getRequest(client, self._url)
|
||||
|
||||
def do_everything():
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
loop.run_until_complete(main(loop))
|
||||
|
||||
t = Thread(target=do_everything)
|
||||
t.run()
|
||||
|
||||
if self.scryfallJson['object'] == 'error':
|
||||
raise Exception(self.scryfallJson['details'])
|
||||
|
||||
def _checkForKey(self, key):
|
||||
if not key in self.scryfallJson:
|
||||
raise KeyError('This card has no key \'{}\''.format(key))
|
||||
|
||||
def _checkForTupleKey(self, parent, num, key):
|
||||
if not key in self.scryfallJson[parent][num]:
|
||||
raise KeyError('This tuple has no key \'{}\''.format(key))
|
||||
|
||||
def object(self):
|
||||
self._checkForKey('object')
|
||||
def object(self):
|
||||
self._checkForKey('object')
|
||||
|
||||
return self.scryfallJson['object']
|
||||
return self.scryfallJson['object']
|
||||
|
||||
def id(self):
|
||||
self._checkForKey('id')
|
||||
def id(self):
|
||||
self._checkForKey('id')
|
||||
|
||||
return self.scryfallJson['id']
|
||||
return self.scryfallJson['id']
|
||||
|
||||
def multiverse_ids(self):
|
||||
self._checkForKey('multiverse_ids')
|
||||
def multiverse_ids(self):
|
||||
self._checkForKey('multiverse_ids')
|
||||
|
||||
return self.scryfallJson['multiverse_ids']
|
||||
return self.scryfallJson['multiverse_ids']
|
||||
|
||||
def mtgo_id(self):
|
||||
self._checkForKey('mtgo_id')
|
||||
def mtgo_id(self):
|
||||
self._checkForKey('mtgo_id')
|
||||
|
||||
return self.scryfallJson['mtgo_id']
|
||||
return self.scryfallJson['mtgo_id']
|
||||
|
||||
def mtgo_foil_id(self):
|
||||
self._checkForKey('mtgo_foil_id')
|
||||
def mtgo_foil_id(self):
|
||||
self._checkForKey('mtgo_foil_id')
|
||||
|
||||
return self.scryfallJson['mtgo_foil_id']
|
||||
return self.scryfallJson['mtgo_foil_id']
|
||||
|
||||
def name(self):
|
||||
self._checkForKey('name')
|
||||
def name(self):
|
||||
self._checkForKey('name')
|
||||
|
||||
return self.scryfallJson['name']
|
||||
return self.scryfallJson['name']
|
||||
|
||||
def uri(self):
|
||||
self._checkForKey('uri')
|
||||
def uri(self):
|
||||
self._checkForKey('uri')
|
||||
|
||||
return self.scryfallJson['uri']
|
||||
return self.scryfallJson['uri']
|
||||
|
||||
def scryfall_uri(self):
|
||||
self._checkForKey('scryfall_uri')
|
||||
def scryfall_uri(self):
|
||||
self._checkForKey('scryfall_uri')
|
||||
|
||||
return self.scryfallJson['scryfall_uri']
|
||||
return self.scryfallJson['scryfall_uri']
|
||||
|
||||
def layout(self):
|
||||
self._checkForKey('layout')
|
||||
def layout(self):
|
||||
self._checkForKey('layout')
|
||||
|
||||
return self.scryfallJson['layout']
|
||||
return self.scryfallJson['layout']
|
||||
|
||||
def highres_image(self):
|
||||
self._checkForKey('highres_image')
|
||||
def highres_image(self):
|
||||
self._checkForKey('highres_image')
|
||||
|
||||
return self.scryfallJson['highres_image']
|
||||
return self.scryfallJson['highres_image']
|
||||
|
||||
def image_uris(self):
|
||||
self._checkForKey('image_uris')
|
||||
def image_uris(self):
|
||||
self._checkForKey('image_uris')
|
||||
|
||||
return self.scryfallJson['image_uris']
|
||||
return self.scryfallJson['image_uris']
|
||||
|
||||
def cmc(self):
|
||||
self._checkForKey('cmc')
|
||||
def cmc(self):
|
||||
self._checkForKey('cmc')
|
||||
|
||||
return self.scryfallJson['cmc']
|
||||
return self.scryfallJson['cmc']
|
||||
|
||||
def type_line(self):
|
||||
self._checkForKey('type_line')
|
||||
def type_line(self):
|
||||
self._checkForKey('type_line')
|
||||
|
||||
return self.scryfallJson['type_line']
|
||||
return self.scryfallJson['type_line']
|
||||
|
||||
def oracle_text(self):
|
||||
self._checkForKey('oracle_text')
|
||||
def oracle_text(self):
|
||||
self._checkForKey('oracle_text')
|
||||
|
||||
return self.scryfallJson['oracle_text']
|
||||
return self.scryfallJson['oracle_text']
|
||||
|
||||
def mana_cost(self):
|
||||
self._checkForKey('mana_cost')
|
||||
def mana_cost(self):
|
||||
self._checkForKey('mana_cost')
|
||||
|
||||
return self.scryfallJson['mana_cost']
|
||||
return self.scryfallJson['mana_cost']
|
||||
|
||||
def colors(self):
|
||||
self._checkForKey('colors')
|
||||
def colors(self):
|
||||
self._checkForKey('colors')
|
||||
|
||||
return self.scryfallJson['colors']
|
||||
return self.scryfallJson['colors']
|
||||
|
||||
def color_identity(self):
|
||||
self._checkForKey('color_identity')
|
||||
def color_identity(self):
|
||||
self._checkForKey('color_identity')
|
||||
|
||||
return self.scryfallJson['color_identity']
|
||||
return self.scryfallJson['color_identity']
|
||||
|
||||
def legalities(self):
|
||||
self._checkForKey('legalities')
|
||||
def legalities(self):
|
||||
self._checkForKey('legalities')
|
||||
|
||||
return self.scryfallJson['legalities']
|
||||
return self.scryfallJson['legalities']
|
||||
|
||||
def reserved(self):
|
||||
self._checkForKey('reserved')
|
||||
def reserved(self):
|
||||
self._checkForKey('reserved')
|
||||
|
||||
return self.scryfallJson['reserved']
|
||||
return self.scryfallJson['reserved']
|
||||
|
||||
def reprint(self):
|
||||
self._checkForKey('reprint')
|
||||
def reprint(self):
|
||||
self._checkForKey('reprint')
|
||||
|
||||
return self.scryfallJson['reprint']
|
||||
return self.scryfallJson['reprint']
|
||||
|
||||
def set_code(self):
|
||||
self._checkForKey('set')
|
||||
def set_code(self):
|
||||
self._checkForKey('set')
|
||||
|
||||
return self.scryfallJson['set']
|
||||
return self.scryfallJson['set']
|
||||
|
||||
def set_name(self):
|
||||
self._checkForKey('set_name')
|
||||
def set_name(self):
|
||||
self._checkForKey('set_name')
|
||||
|
||||
return self.scryfallJson['set_name']
|
||||
return self.scryfallJson['set_name']
|
||||
|
||||
def set_uri(self):
|
||||
self._checkForKey('set_uri')
|
||||
def set_uri(self):
|
||||
self._checkForKey('set_uri')
|
||||
|
||||
return self.scryfallJson['set_uri']
|
||||
return self.scryfallJson['set_uri']
|
||||
|
||||
def set_search_uri(self):
|
||||
self._checkForKey('set_search_uri')
|
||||
def set_search_uri(self):
|
||||
self._checkForKey('set_search_uri')
|
||||
|
||||
return self.scryfallJson['set_search_uri']
|
||||
return self.scryfallJson['set_search_uri']
|
||||
|
||||
def scryfall_set_uri(self):
|
||||
self._checkForKey('scryfall_set_uri')
|
||||
def scryfall_set_uri(self):
|
||||
self._checkForKey('scryfall_set_uri')
|
||||
|
||||
return self.scryfallJson['scryfall_set_uri']
|
||||
return self.scryfallJson['scryfall_set_uri']
|
||||
|
||||
def rulings_uri(self):
|
||||
self._checkForKey('rulings_uri')
|
||||
def rulings_uri(self):
|
||||
self._checkForKey('rulings_uri')
|
||||
|
||||
return self.scryfallJson['rulings_uri']
|
||||
return self.scryfallJson['rulings_uri']
|
||||
|
||||
def prints_search_uri(self):
|
||||
self._checkForKey('prints_search_uri')
|
||||
def prints_search_uri(self):
|
||||
self._checkForKey('prints_search_uri')
|
||||
|
||||
return self.scryfallJson['prints_search_uri']
|
||||
return self.scryfallJson['prints_search_uri']
|
||||
|
||||
def collector_number(self):
|
||||
self._checkForKey('collector_number')
|
||||
def collector_number(self):
|
||||
self._checkForKey('collector_number')
|
||||
|
||||
return self.scryfallJson['collector_number']
|
||||
return self.scryfallJson['collector_number']
|
||||
|
||||
def digital(self):
|
||||
self._checkForKey('digital')
|
||||
def digital(self):
|
||||
self._checkForKey('digital')
|
||||
|
||||
return self.scryfallJson['digital']
|
||||
return self.scryfallJson['digital']
|
||||
|
||||
def rarity(self):
|
||||
self._checkForKey('rarity')
|
||||
def rarity(self):
|
||||
self._checkForKey('rarity')
|
||||
|
||||
return self.scryfallJson['rarity']
|
||||
return self.scryfallJson['rarity']
|
||||
|
||||
def illustration_id(self):
|
||||
self._checkForKey('illustration_id')
|
||||
def illustration_id(self):
|
||||
self._checkForKey('illustration_id')
|
||||
|
||||
return self.scryfallJson['illustration_id']
|
||||
return self.scryfallJson['illustration_id']
|
||||
|
||||
def artist(self):
|
||||
self._checkForKey('artist')
|
||||
def artist(self):
|
||||
self._checkForKey('artist')
|
||||
|
||||
return self.scryfallJson['artist']
|
||||
return self.scryfallJson['artist']
|
||||
|
||||
def frame(self):
|
||||
self._checkForKey('frame')
|
||||
def frame(self):
|
||||
self._checkForKey('frame')
|
||||
|
||||
return self.scryfallJson['frame']
|
||||
return self.scryfallJson['frame']
|
||||
|
||||
def full_art(self):
|
||||
self._checkForKey('')
|
||||
def full_art(self):
|
||||
self._checkForKey('')
|
||||
|
||||
return self.scryfallJson['full_art']
|
||||
return self.scryfallJson['full_art']
|
||||
|
||||
def border_color(self):
|
||||
self._checkForKey('border_color')
|
||||
def border_color(self):
|
||||
self._checkForKey('border_color')
|
||||
|
||||
return self.scryfallJson['border_color']
|
||||
return self.scryfallJson['border_color']
|
||||
|
||||
def timeshifted(self):
|
||||
self._checkForKey('timeshifted')
|
||||
def timeshifted(self):
|
||||
self._checkForKey('timeshifted')
|
||||
|
||||
return self.scryfallJson['timeshifted']
|
||||
return self.scryfallJson['timeshifted']
|
||||
|
||||
def colorshifted(self):
|
||||
self._checkForKey('colorshifted')
|
||||
def colorshifted(self):
|
||||
self._checkForKey('colorshifted')
|
||||
|
||||
return self.scryfallJson['colorshifted']
|
||||
return self.scryfallJson['colorshifted']
|
||||
|
||||
def futureshifted(self):
|
||||
self._checkForKey('futureshifted')
|
||||
def futureshifted(self):
|
||||
self._checkForKey('futureshifted')
|
||||
|
||||
return self.scryfallJson['futureshifted']
|
||||
return self.scryfallJson['futureshifted']
|
||||
|
||||
def edhrec_rank(self):
|
||||
self._checkForKey('edhrec_rank')
|
||||
def edhrec_rank(self):
|
||||
self._checkForKey('edhrec_rank')
|
||||
|
||||
return self.scryfallJson['edhrec_rank']
|
||||
return self.scryfallJson['edhrec_rank']
|
||||
|
||||
def currency(self, mode):
|
||||
modes = ['usd', 'eur', 'tix']
|
||||
if mode not in modes:
|
||||
raise KeyError("{} is not a key.".format(mode))
|
||||
def currency(self, mode):
|
||||
modes = ['usd', 'eur', 'tix']
|
||||
if mode not in modes:
|
||||
raise KeyError("{} is not a key.".format(mode))
|
||||
|
||||
self._checkForKey(mode)
|
||||
self._checkForKey(mode)
|
||||
|
||||
return self.scryfallJson[mode]
|
||||
return self.scryfallJson[mode]
|
||||
|
||||
def related_uris(self):
|
||||
self._checkForKey('related_uris')
|
||||
def related_uris(self):
|
||||
self._checkForKey('related_uris')
|
||||
|
||||
return self.scryfallJson['related_uris']
|
||||
return self.scryfallJson['related_uris']
|
||||
|
||||
def purchase_uris(self):
|
||||
self._checkForKey('purchase_uris')
|
||||
def purchase_uris(self):
|
||||
self._checkForKey('purchase_uris')
|
||||
|
||||
return self.scryfallJson['purchase_uris']
|
||||
return self.scryfallJson['purchase_uris']
|
||||
|
||||
def life_modifier(self):
|
||||
self._checkForKey('life_modifier')
|
||||
def life_modifier(self):
|
||||
self._checkForKey('life_modifier')
|
||||
|
||||
return self.scryfallJson['life_modifier']
|
||||
return self.scryfallJson['life_modifier']
|
||||
|
||||
def hand_modifier(self):
|
||||
self._checkForKey('hand_modifier')
|
||||
def hand_modifier(self):
|
||||
self._checkForKey('hand_modifier')
|
||||
|
||||
return self.scryfallJson['hand_modifier']
|
||||
return self.scryfallJson['hand_modifier']
|
||||
|
||||
def color_indicator(self):
|
||||
self._checkForKey('color_indicator')
|
||||
def color_indicator(self):
|
||||
self._checkForKey('color_indicator')
|
||||
|
||||
return self.scryfallJson['color_indicator']
|
||||
return self.scryfallJson['color_indicator']
|
||||
|
||||
def all_parts(self):
|
||||
self._checkForKey('all_parts')
|
||||
def all_parts(self):
|
||||
self._checkForKey('all_parts')
|
||||
|
||||
return self.scryfallJson['all_parts']
|
||||
return self.scryfallJson['all_parts']
|
||||
|
||||
def card_faces(self):
|
||||
self._checkForKey('card_faces')
|
||||
def card_faces(self):
|
||||
self._checkForKey('card_faces')
|
||||
|
||||
return self.scryfallJson['card_faces']
|
||||
return self.scryfallJson['card_faces']
|
||||
|
||||
def watermark(self):
|
||||
self._checkForKey('watermark')
|
||||
def watermark(self):
|
||||
self._checkForKey('watermark')
|
||||
|
||||
return self.scryfallJson['watermark']
|
||||
return self.scryfallJson['watermark']
|
||||
|
||||
def story_spotlight_number(self):
|
||||
self._checkForKey('story_spotlight_number')
|
||||
def story_spotlight_number(self):
|
||||
self._checkForKey('story_spotlight_number')
|
||||
|
||||
return self.scryfallJson['story_spotlight_number']
|
||||
return self.scryfallJson['story_spotlight_number']
|
||||
|
||||
def story_spotlight_uri(self):
|
||||
self._checkForKey('story_spotlight_uri')
|
||||
def story_spotlight_uri(self):
|
||||
self._checkForKey('story_spotlight_uri')
|
||||
|
||||
return self.scryfallJson['story_spotlight_uri']
|
||||
return self.scryfallJson['story_spotlight_uri']
|
||||
|
||||
def power(self):
|
||||
self._checkForKey('power')
|
||||
def power(self):
|
||||
self._checkForKey('power')
|
||||
|
||||
return self.scryfallJson['power']
|
||||
return self.scryfallJson['power']
|
||||
|
||||
def toughness(self):
|
||||
self._checkForKey('toughness')
|
||||
def toughness(self):
|
||||
self._checkForKey('toughness')
|
||||
|
||||
return self.scryfallJson['toughness']
|
||||
return self.scryfallJson['toughness']
|
||||
|
||||
def loyalty(self):
|
||||
self._checkForKey('loyalty')
|
||||
def loyalty(self):
|
||||
self._checkForKey('loyalty')
|
||||
|
||||
return self.scryfallJson['loyalty']
|
||||
return self.scryfallJson['loyalty']
|
||||
|
||||
def flavor_text(self):
|
||||
self._checkForKey('flavor_text')
|
||||
def flavor_text(self):
|
||||
self._checkForKey('flavor_text')
|
||||
|
||||
return self.scryfallJson['flavor_text']
|
||||
return self.scryfallJson['flavor_text']
|
||||
|
||||
def arena_id(self):
|
||||
self._checkForKey('arena_id')
|
||||
def arena_id(self):
|
||||
self._checkForKey('arena_id')
|
||||
|
||||
return self.scryfallJson['arena_id']
|
||||
return self.scryfallJson['arena_id']
|
||||
|
||||
def lang(self):
|
||||
self._checkForKey('lang')
|
||||
def lang(self):
|
||||
self._checkForKey('lang')
|
||||
|
||||
return self.scryfallJson['lang']
|
||||
return self.scryfallJson['lang']
|
||||
|
||||
def printed_name(self):
|
||||
self._checkForKey('printed_name')
|
||||
def printed_name(self):
|
||||
self._checkForKey('printed_name')
|
||||
|
||||
return self.scryfallJson['printed_name']
|
||||
return self.scryfallJson['printed_name']
|
||||
|
||||
def printed_type_line(self):
|
||||
self._checkForKey('printed_type_line')
|
||||
def printed_type_line(self):
|
||||
self._checkForKey('printed_type_line')
|
||||
|
||||
return self.scryfallJson['printed_type_line']
|
||||
return self.scryfallJson['printed_type_line']
|
||||
|
||||
def printed_text(self):
|
||||
self._checkForKey('printed_text')
|
||||
def printed_text(self):
|
||||
self._checkForKey('printed_text')
|
||||
|
||||
return self.scryfallJson['printed_text']
|
||||
return self.scryfallJson['printed_text']
|
|
@ -1,33 +1,33 @@
|
|||
from .cards_object import CardsObject
|
||||
|
||||
class Collector(CardsObject):
|
||||
"""
|
||||
cards/collector
|
||||
Get a card by collector number.
|
||||
"""
|
||||
cards/collector
|
||||
Get a card by collector number.
|
||||
|
||||
Positional arguments:
|
||||
code : str ....................... This is the 3 letter code for the set
|
||||
collector_number : str ........ This is the collector number of the card
|
||||
Positional arguments:
|
||||
code : str ....................... This is the 3 letter code for the set
|
||||
collector_number : str ........ This is the collector number of the card
|
||||
|
||||
Optional arguments:
|
||||
Inherits all arguments from CardsObject
|
||||
Optional arguments:
|
||||
Inherits all arguments from CardsObject
|
||||
|
||||
lang : str ............................... A 2-3 character language code
|
||||
lang : str ............................... A 2-3 character language code
|
||||
|
||||
Attributes:
|
||||
Inherits all attributes from CardsObject
|
||||
Attributes:
|
||||
Inherits all attributes from CardsObject
|
||||
|
||||
Example usage:
|
||||
>>> card = scrython.cards.Collector(code='exo', collector_number='96')
|
||||
>>> card.id()
|
||||
"""
|
||||
def __init__(self, **kwargs):
|
||||
if kwargs.get('code') is None:
|
||||
raise TypeError('No code provided to search by')
|
||||
Example usage:
|
||||
>>> card = scrython.cards.Collector(code='exo', collector_number='96')
|
||||
>>> card.id()
|
||||
"""
|
||||
def __init__(self, **kwargs):
|
||||
if kwargs.get('code') is None:
|
||||
raise TypeError('No code provided to search by')
|
||||
|
||||
self.url = 'cards/{}/{}/{}?'.format(
|
||||
kwargs.get('code'),
|
||||
str(kwargs.get('collector_number')),
|
||||
kwargs.get('lang', 'en')
|
||||
)
|
||||
super(Collector, self).__init__(self.url)
|
||||
self.url = 'cards/{}/{}/{}?'.format(
|
||||
kwargs.get('code'),
|
||||
str(kwargs.get('collector_number')),
|
||||
kwargs.get('lang', 'en')
|
||||
)
|
||||
super(Collector, self).__init__(self.url)
|
||||
|
|
|
@ -2,26 +2,26 @@ from .cards_object import CardsObject
|
|||
import urllib.parse
|
||||
|
||||
class Mtgo(CardsObject):
|
||||
"""
|
||||
cards/mtgo
|
||||
Get a card by MTGO id.
|
||||
"""
|
||||
cards/mtgo
|
||||
Get a card by MTGO id.
|
||||
|
||||
Positional arguments:
|
||||
id : str ............................. The required mtgo id of the card.
|
||||
Positional arguments:
|
||||
id : str ............................. The required mtgo id of the card.
|
||||
|
||||
Optional arguments:
|
||||
All arguments are inherited from CardsObject
|
||||
Optional arguments:
|
||||
All arguments are inherited from CardsObject
|
||||
|
||||
Attributes:
|
||||
All attributes are inherited from CardsObject
|
||||
Attributes:
|
||||
All attributes are inherited from CardsObject
|
||||
|
||||
Example usage:
|
||||
>>> card = scrython.cards.Mtgo(id="48296")
|
||||
>>> card.set_name()
|
||||
"""
|
||||
def __init__(self, **kwargs):
|
||||
if kwargs.get('id') is None:
|
||||
raise TypeError('No id provided to search by')
|
||||
Example usage:
|
||||
>>> card = scrython.cards.Mtgo(id="48296")
|
||||
>>> card.set_name()
|
||||
"""
|
||||
def __init__(self, **kwargs):
|
||||
if kwargs.get('id') is None:
|
||||
raise TypeError('No id provided to search by')
|
||||
|
||||
self.url = 'cards/mtgo/{}?'.format(str(kwargs.get('id')))
|
||||
super(Mtgo, self).__init__(self.url)
|
||||
self.url = 'cards/mtgo/{}?'.format(str(kwargs.get('id')))
|
||||
super(Mtgo, self).__init__(self.url)
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
from .cards_object import CardsObject
|
||||
|
||||
class Multiverse(CardsObject):
|
||||
"""
|
||||
cards/multiverse
|
||||
Get a card by Multiverse id
|
||||
"""
|
||||
cards/multiverse
|
||||
Get a card by Multiverse id
|
||||
|
||||
Positional arguments:
|
||||
id : str ....... This is the associated multiverse id of the given card.
|
||||
Positional arguments:
|
||||
id : str ....... This is the associated multiverse id of the given card.
|
||||
|
||||
Optional arguments:
|
||||
Inherits all arguments from CardsObject
|
||||
Optional arguments:
|
||||
Inherits all arguments from CardsObject
|
||||
|
||||
Attributes:
|
||||
Inherits all attributes from CardsObject
|
||||
Attributes:
|
||||
Inherits all attributes from CardsObject
|
||||
|
||||
Example usage:
|
||||
>>> card = scrython.cards.Multiverse(id='96865')
|
||||
>>> card.name()
|
||||
"""
|
||||
def __init__(self, **kwargs):
|
||||
if kwargs.get('id') is None:
|
||||
raise TypeError('No id provided to search by')
|
||||
Example usage:
|
||||
>>> card = scrython.cards.Multiverse(id='96865')
|
||||
>>> card.name()
|
||||
"""
|
||||
def __init__(self, **kwargs):
|
||||
if kwargs.get('id') is None:
|
||||
raise TypeError('No id provided to search by')
|
||||
|
||||
self.url = 'cards/multiverse/{}?'.format(str(kwargs.get('id')))
|
||||
super(Multiverse, self).__init__(self.url)
|
||||
self.url = 'cards/multiverse/{}?'.format(str(kwargs.get('id')))
|
||||
super(Multiverse, self).__init__(self.url)
|
||||
|
|
|
@ -2,37 +2,37 @@ from .cards_object import CardsObject
|
|||
import urllib.parse
|
||||
|
||||
class Named(CardsObject):
|
||||
"""
|
||||
cards/named
|
||||
Gets a card by the name.
|
||||
"""
|
||||
cards/named
|
||||
Gets a card by the name.
|
||||
|
||||
Positional arguments:
|
||||
fuzzy : str ................ Uses the fuzzy parameter for the card name.
|
||||
or
|
||||
exact : str ................ Uses the exact parameter for the card name.
|
||||
Positional arguments:
|
||||
fuzzy : str ................ Uses the fuzzy parameter for the card name.
|
||||
or
|
||||
exact : str ................ Uses the exact parameter for the card name.
|
||||
|
||||
Optional arguments:
|
||||
set : str . Returns the set of the card if specified. Requires the 3 letter set code.
|
||||
All arguments are inherited from CardsObject
|
||||
Optional arguments:
|
||||
set : str . Returns the set of the card if specified. Requires the 3 letter set code.
|
||||
All arguments are inherited from CardsObject
|
||||
|
||||
Attributes:
|
||||
All attributes are inherited from CardsObject
|
||||
Attributes:
|
||||
All attributes are inherited from CardsObject
|
||||
|
||||
Example usage:
|
||||
>>> card = scrython.cards.Named(exact="Black Lotus")
|
||||
>>> card.colors()
|
||||
"""
|
||||
def __init__(self, **kwargs):
|
||||
self.dict = {
|
||||
'set':kwargs.get('set', '')
|
||||
}
|
||||
Example usage:
|
||||
>>> card = scrython.cards.Named(exact="Black Lotus")
|
||||
>>> card.colors()
|
||||
"""
|
||||
def __init__(self, **kwargs):
|
||||
self.dict = {
|
||||
'set':kwargs.get('set', '')
|
||||
}
|
||||
|
||||
if kwargs.get('exact') is not None:
|
||||
self.dict['exact'] = kwargs.get('exact')
|
||||
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')
|
||||
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)
|
||||
self.args = urllib.parse.urlencode(self.dict)
|
||||
self.url = 'cards/named?' + self.args
|
||||
super(Named, self).__init__(self.url)
|
||||
|
|
|
@ -2,241 +2,241 @@ from .cards_object import CardsObject
|
|||
import urllib.parse
|
||||
|
||||
class Search(CardsObject):
|
||||
"""
|
||||
cards/search
|
||||
Uses a search query to gather relevant data.
|
||||
"""
|
||||
cards/search
|
||||
Uses a search query to gather relevant data.
|
||||
|
||||
Positional arguments:
|
||||
q : str ...... The query to search. This will be updated in the future.
|
||||
Positional arguments:
|
||||
q : str ...... The query to search. This will be updated in the future.
|
||||
|
||||
Optional arguments:
|
||||
order : str ................... The order you'd like the data returned.
|
||||
unique : str ........................... A way to filter similar cards.
|
||||
dir : str ......... The direction you'd like to sort. (asc, desc, auto)
|
||||
include_extras : bool ... Includes cards that are normally omitted from
|
||||
search results, like Un-sets.
|
||||
page : int .............. The page number you'd like to search, if any.
|
||||
Inherits all arguments from CardsObject.
|
||||
Optional arguments:
|
||||
order : str ................... The order you'd like the data returned.
|
||||
unique : str ........................... A way to filter similar cards.
|
||||
dir : str ......... The direction you'd like to sort. (asc, desc, auto)
|
||||
include_extras : bool ... Includes cards that are normally omitted from
|
||||
search results, like Un-sets.
|
||||
page : int .............. The page number you'd like to search, if any.
|
||||
Inherits all arguments from CardsObject.
|
||||
|
||||
Attributes:
|
||||
object : str ....................... Returns what kind of object it is.
|
||||
total_cards : int ......... How many cards are returned from the query.
|
||||
data : list ...................... The list of potential autocompletes.
|
||||
has_more : bool ......... True if there is more than 1 page of results.
|
||||
next_page : str ............ The API URI to the next page of the query.
|
||||
warnings : list .................. Provides an array of errors, if any.
|
||||
data_length : int .................... The length of the data returned.
|
||||
data_tuple : dict .......... Accesses an object at the specified index.
|
||||
Attributes:
|
||||
object : str ....................... Returns what kind of object it is.
|
||||
total_cards : int ......... How many cards are returned from the query.
|
||||
data : list ...................... The list of potential autocompletes.
|
||||
has_more : bool ......... True if there is more than 1 page of results.
|
||||
next_page : str ............ The API URI to the next page of the query.
|
||||
warnings : list .................. Provides an array of errors, if any.
|
||||
data_length : int .................... The length of the data returned.
|
||||
data_tuple : dict .......... Accesses an object at the specified index.
|
||||
|
||||
|
||||
Example usage:
|
||||
>>> search = scrython.cards.Search(q="++e:A25", order="spoiled")
|
||||
>>> search.data()
|
||||
"""
|
||||
def __init__(self, **kwargs):
|
||||
if kwargs.get('q') is None:
|
||||
raise TypeError('No query is specified.')
|
||||
Example usage:
|
||||
>>> search = scrython.cards.Search(q="++e:A25", order="spoiled")
|
||||
>>> search.data()
|
||||
"""
|
||||
def __init__(self, **kwargs):
|
||||
if kwargs.get('q') is None:
|
||||
raise TypeError('No query is specified.')
|
||||
|
||||
self.dict = {
|
||||
'q':kwargs.get('q'),
|
||||
'order':kwargs.get('order', 'none'),
|
||||
'unique':kwargs.get('unique', 'none'),
|
||||
'dir':kwargs.get('dir', 'none'),
|
||||
'include_extras':kwargs.get('include_extras', 'false'),
|
||||
'page':kwargs.get('page', '1')
|
||||
}
|
||||
self.dict = {
|
||||
'q':kwargs.get('q'),
|
||||
'order':kwargs.get('order', 'none'),
|
||||
'unique':kwargs.get('unique', 'none'),
|
||||
'dir':kwargs.get('dir', 'none'),
|
||||
'include_extras':kwargs.get('include_extras', 'false'),
|
||||
'page':kwargs.get('page', '1')
|
||||
}
|
||||
|
||||
self.args = urllib.parse.urlencode(self.dict)
|
||||
self.url = 'cards/search?' + self.args
|
||||
self.args = urllib.parse.urlencode(self.dict)
|
||||
self.url = 'cards/search?' + self.args
|
||||
|
||||
super(Search, self).__init__(self.url)
|
||||
super(Search, self).__init__(self.url)
|
||||
|
||||
def object(self):
|
||||
super(Search, self)._checkForKey('object')
|
||||
def object(self):
|
||||
super(Search, self)._checkForKey('object')
|
||||
|
||||
return self.scryfallJson['object']
|
||||
return self.scryfallJson['object']
|
||||
|
||||
def total_cards(self):
|
||||
super(Search, self)._checkForKey('total_cards')
|
||||
def total_cards(self):
|
||||
super(Search, self)._checkForKey('total_cards')
|
||||
|
||||
return self.scryfallJson['total_cards']
|
||||
return self.scryfallJson['total_cards']
|
||||
|
||||
def data(self):
|
||||
super(Search, self)._checkForKey('data')
|
||||
def data(self):
|
||||
super(Search, self)._checkForKey('data')
|
||||
|
||||
return self.scryfallJson['data']
|
||||
return self.scryfallJson['data']
|
||||
|
||||
def next_page(self):
|
||||
super(Search, self)._checkForKey('next_page')
|
||||
def next_page(self):
|
||||
super(Search, self)._checkForKey('next_page')
|
||||
|
||||
return self.scryfallJson['next_page']
|
||||
return self.scryfallJson['next_page']
|
||||
|
||||
def warnings(self):
|
||||
super(Search, self)._checkForKey('warnings')
|
||||
def warnings(self):
|
||||
super(Search, self)._checkForKey('warnings')
|
||||
|
||||
return self.scryfallJson['warnings']
|
||||
return self.scryfallJson['warnings']
|
||||
|
||||
def data_length(self):
|
||||
super(Search, self)._checkForKey('data')
|
||||
def data_length(self):
|
||||
super(Search, self)._checkForKey('data')
|
||||
|
||||
return len(self.scryfallJson['data'])
|
||||
return len(self.scryfallJson['data'])
|
||||
|
||||
def data_tuple(self, num):
|
||||
super(Search, self)._checkForKey('data')
|
||||
def data_tuple(self, num):
|
||||
super(Search, self)._checkForKey('data')
|
||||
|
||||
return self.scryfallJson['data'][num]
|
||||
return self.scryfallJson['data'][num]
|
||||
|
||||
def has_more(self):
|
||||
super(Search, self)._checkForKey('has_more')
|
||||
def has_more(self):
|
||||
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
|
||||
#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 id(self):
|
||||
raise AttributeError('Search object has no attribute \'id\'')
|
||||
|
||||
def multiverse_ids(self):
|
||||
raise AttributeError('Search object has no attribute \'multiverse_ids\'')
|
||||
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_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 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 name(self):
|
||||
raise AttributeError('Search object has no attribute \'name\'')
|
||||
|
||||
def uri(self):
|
||||
raise AttributeError('Search object has no attribute \'uri\'')
|
||||
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 scryfall_uri(self):
|
||||
raise AttributeError('Search object has no attribute \'scryfall_uri\'')
|
||||
|
||||
def layout(self):
|
||||
raise AttributeError('Search object has no attribute \'layout\'')
|
||||
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 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 image_uris(self):
|
||||
raise AttributeError('Search object has no attribute \'image_uris\'')
|
||||
|
||||
def cmc(self):
|
||||
raise AttributeError('Search object has no attribute \'cmc\'')
|
||||
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 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 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 mana_cost(self):
|
||||
raise AttributeError('Search object has no attribute \'mana_cost\'')
|
||||
|
||||
def colors(self):
|
||||
raise AttributeError('Search object has no attribute \'colors\'')
|
||||
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 color_identity(self):
|
||||
raise AttributeError('Search object has no attribute \'color_identity\'')
|
||||
|
||||
def legalities(self):
|
||||
raise AttributeError('Search object has no attribute \'legalities\'')
|
||||
def legalities(self):
|
||||
raise AttributeError('Search object has no attribute \'legalities\'')
|
||||
|
||||
def reserved(self):
|
||||
raise AttributeError('Search object has no attribute \'reserved\'')
|
||||
def reserved(self):
|
||||
raise AttributeError('Search object has no attribute \'reserved\'')
|
||||
|
||||
def reprint(self):
|
||||
raise AttributeError('Search object has no attribute \'reprint\'')
|
||||
def reprint(self):
|
||||
raise AttributeError('Search object has no attribute \'reprint\'')
|
||||
|
||||
def set_code(self):
|
||||
raise AttributeError('Search object has no attribute \' def set_code\'')
|
||||
def set_code(self):
|
||||
raise AttributeError('Search object has no attribute \' def set_code\'')
|
||||
|
||||
def set_name(self):
|
||||
raise AttributeError('Search object has no attribute \' def set_name\'')
|
||||
def set_name(self):
|
||||
raise AttributeError('Search object has no attribute \' def set_name\'')
|
||||
|
||||
def set_uri(self):
|
||||
raise AttributeError('Search object has no attribute \'set_uri\'')
|
||||
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 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 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 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 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 collector_number(self):
|
||||
raise AttributeError('Search object has no attribute \'collector_number\'')
|
||||
|
||||
def digital(self):
|
||||
raise AttributeError('Search object has no attribute \'digital\'')
|
||||
def digital(self):
|
||||
raise AttributeError('Search object has no attribute \'digital\'')
|
||||
|
||||
def rarity(self):
|
||||
raise AttributeError('Search object has no attribute \'rarity\'')
|
||||
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 illustration_id(self):
|
||||
raise AttributeError('Search object has no attribute \'illustration_id\'')
|
||||
|
||||
def artist(self):
|
||||
raise AttributeError('Search object has no attribute \'artist\'')
|
||||
def artist(self):
|
||||
raise AttributeError('Search object has no attribute \'artist\'')
|
||||
|
||||
def frame(self):
|
||||
raise AttributeError('Search object has no attribute \'frame\'')
|
||||
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 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 border_color(self):
|
||||
raise AttributeError('Search object has no attribute \'border_color\'')
|
||||
|
||||
def timeshifted(self):
|
||||
raise AttributeError('Search object has no attribute \'timeshifted\'')
|
||||
def timeshifted(self):
|
||||
raise AttributeError('Search object has no attribute \'timeshifted\'')
|
||||
|
||||
def colorshifted(self):
|
||||
raise AttributeError('Search object has no attribute \'colorshifted\'')
|
||||
def colorshifted(self):
|
||||
raise AttributeError('Search object has no attribute \'colorshifted\'')
|
||||
|
||||
def futureshifted(self):
|
||||
raise AttributeError('Search object has no attribute \'futureshifted\'')
|
||||
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 edhrec_rank(self):
|
||||
raise AttributeError('Search object has no attribute \'edhrec_rank\'')
|
||||
|
||||
def currency(self, mode):
|
||||
raise AttributeError('Search object has no attribute \'currency(self,\'')
|
||||
def currency(self, mode):
|
||||
raise AttributeError('Search object has no attribute \'currency(self,\'')
|
||||
|
||||
def related_uris(self):
|
||||
raise AttributeError('Search object has no attribute \'related_uris\'')
|
||||
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 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 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 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 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 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 card_faces(self):
|
||||
raise AttributeError('Search object has no attribute \'card_faces\'')
|
||||
|
||||
def watermark(self):
|
||||
raise AttributeError('Search object has no attribute \'watermark\'')
|
||||
def watermark(self):
|
||||
raise AttributeError('Search object has no attribute \'watermark\'')
|
||||
|
||||
def story_spotlight_number(self):
|
||||
raise AttributeError('Search object has no attribute \'story_spotlight_number\'')
|
||||
def story_spotlight_number(self):
|
||||
raise AttributeError('Search object has no attribute \'story_spotlight_number\'')
|
||||
|
||||
def story_spotlight_uri(self):
|
||||
raise AttributeError('Search object has no attribute \'story_spotlight_uri\'')
|
||||
def story_spotlight_uri(self):
|
||||
raise AttributeError('Search object has no attribute \'story_spotlight_uri\'')
|
||||
|
|
|
@ -4,67 +4,67 @@ import urllib.parse
|
|||
from threading import Thread
|
||||
|
||||
class CatalogsObject(object):
|
||||
"""
|
||||
Master object for all catalog objects.
|
||||
"""
|
||||
Master object for all catalog objects.
|
||||
|
||||
Positional Arguments:
|
||||
No arguments are required.
|
||||
Positional Arguments:
|
||||
No arguments are required.
|
||||
|
||||
Optional Arguments:
|
||||
format : str ................... The format to return. Defaults to JSON.
|
||||
pretty : bool ... Makes the returned JSON prettier. The library may not work properly with this setting.
|
||||
Optional Arguments:
|
||||
format : str ................... The format to return. Defaults to JSON.
|
||||
pretty : bool ... Makes the returned JSON prettier. The library may not work properly with this setting.
|
||||
|
||||
Attributes:
|
||||
object : str ...... Returns the type of object it is. (card, error, etc)
|
||||
uri : str .................. The API URI for the endpoint you've called.
|
||||
total_values : int ..................... The number of items in `data()`
|
||||
data : list .............. A list of all types returned by the endpoint.
|
||||
"""
|
||||
def __init__(self, _url, **kwargs):
|
||||
self.params = {'format': kwargs.get('format', 'json'), 'pretty': kwargs.get('pretty', '')}
|
||||
Attributes:
|
||||
object : str ...... Returns the type of object it is. (card, error, etc)
|
||||
uri : str .................. The API URI for the endpoint you've called.
|
||||
total_values : int ..................... The number of items in `data()`
|
||||
data : list .............. A list of all types returned by the endpoint.
|
||||
"""
|
||||
def __init__(self, _url, **kwargs):
|
||||
self.params = {'format': kwargs.get('format', 'json'), 'pretty': kwargs.get('pretty', '')}
|
||||
|
||||
self.encodedParams = urllib.parse.urlencode(self.params)
|
||||
self._url = 'https://api.scryfall.com/{0}&{1}'.format(_url, self.encodedParams)
|
||||
self.encodedParams = urllib.parse.urlencode(self.params)
|
||||
self._url = 'https://api.scryfall.com/{0}&{1}'.format(_url, self.encodedParams)
|
||||
|
||||
async def getRequest(client, url, **kwargs):
|
||||
async with client.get(url, **kwargs) as response:
|
||||
return await response.json()
|
||||
async def getRequest(client, url, **kwargs):
|
||||
async with client.get(url, **kwargs) as response:
|
||||
return await response.json()
|
||||
|
||||
async def main(loop):
|
||||
async with aiohttp.ClientSession(loop=loop) as client:
|
||||
self.scryfallJson = await getRequest(client, self._url)
|
||||
async def main(loop):
|
||||
async with aiohttp.ClientSession(loop=loop) as client:
|
||||
self.scryfallJson = await getRequest(client, self._url)
|
||||
|
||||
def do_everything():
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
loop.run_until_complete(main(loop))
|
||||
def do_everything():
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
loop.run_until_complete(main(loop))
|
||||
|
||||
t = Thread(target=do_everything)
|
||||
t.run()
|
||||
t = Thread(target=do_everything)
|
||||
t.run()
|
||||
|
||||
if self.scryfallJson['object'] == 'error':
|
||||
raise Exception(self.scryfallJson['details'])
|
||||
if self.scryfallJson['object'] == 'error':
|
||||
raise Exception(self.scryfallJson['details'])
|
||||
|
||||
def _checkForKey(self, key):
|
||||
if not key in self.scryfallJson:
|
||||
raise KeyError('This card has no key \'{}\''.format(key))
|
||||
def _checkForKey(self, key):
|
||||
if not key in self.scryfallJson:
|
||||
raise KeyError('This card has no key \'{}\''.format(key))
|
||||
|
||||
def object(self):
|
||||
self._checkForKey('object')
|
||||
def object(self):
|
||||
self._checkForKey('object')
|
||||
|
||||
return self.scryfallJson['object']
|
||||
return self.scryfallJson['object']
|
||||
|
||||
def uri(self):
|
||||
self._checkForKey('uri')
|
||||
def uri(self):
|
||||
self._checkForKey('uri')
|
||||
|
||||
return self.scryfallJson['uri']
|
||||
return self.scryfallJson['uri']
|
||||
|
||||
def total_values(self):
|
||||
self._checkForKey('total_values')
|
||||
def total_values(self):
|
||||
self._checkForKey('total_values')
|
||||
|
||||
return self.scryfallJson['total_values']
|
||||
return self.scryfallJson['total_values']
|
||||
|
||||
def data(self):
|
||||
self._checkForKey('data')
|
||||
def data(self):
|
||||
self._checkForKey('data')
|
||||
|
||||
return self.scryfallJson['data']
|
||||
return self.scryfallJson['data']
|
||||
|
|
|
@ -4,105 +4,105 @@ import urllib.parse
|
|||
from threading import Thread
|
||||
|
||||
class RulingsObject(object):
|
||||
"""
|
||||
Master class for all rulings objects.
|
||||
"""
|
||||
Master class for all rulings objects.
|
||||
|
||||
Positional arguments:
|
||||
No arguments required.
|
||||
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.
|
||||
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.
|
||||
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):
|
||||
self.params = {
|
||||
'format': kwargs.get('format', 'json'), 'face': kwargs.get('face', ''),
|
||||
'version': kwargs.get('version', ''), 'pretty': kwargs.get('pretty', '')
|
||||
}
|
||||
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):
|
||||
self.params = {
|
||||
'format': kwargs.get('format', 'json'), 'face': kwargs.get('face', ''),
|
||||
'version': kwargs.get('version', ''), 'pretty': kwargs.get('pretty', '')
|
||||
}
|
||||
|
||||
self.encodedParams = urllib.parse.urlencode(self.params)
|
||||
self._url = 'https://api.scryfall.com/{0}&{1}'.format(_url, self.encodedParams)
|
||||
self.encodedParams = urllib.parse.urlencode(self.params)
|
||||
self._url = 'https://api.scryfall.com/{0}&{1}'.format(_url, self.encodedParams)
|
||||
|
||||
async def getRequest(client, url, **kwargs):
|
||||
async with client.get(url, **kwargs) as response:
|
||||
return await response.json()
|
||||
async def getRequest(client, url, **kwargs):
|
||||
async with client.get(url, **kwargs) as response:
|
||||
return await response.json()
|
||||
|
||||
async def main(loop):
|
||||
async with aiohttp.ClientSession(loop=loop) as client:
|
||||
self.scryfallJson = await getRequest(client, self._url)
|
||||
async def main(loop):
|
||||
async with aiohttp.ClientSession(loop=loop) as client:
|
||||
self.scryfallJson = await getRequest(client, self._url)
|
||||
|
||||
def do_everything():
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
loop.run_until_complete(main(loop))
|
||||
def do_everything():
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
loop.run_until_complete(main(loop))
|
||||
|
||||
t = Thread(target=do_everything)
|
||||
t.run()
|
||||
t = Thread(target=do_everything)
|
||||
t.run()
|
||||
|
||||
if self.scryfallJson['object'] == 'error':
|
||||
raise Exception(self.scryfallJson['details'])
|
||||
if self.scryfallJson['object'] == 'error':
|
||||
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 _checkForKey(self, key):
|
||||
if not key in self.scryfallJson:
|
||||
raise KeyError('This object has no key \'{}\''.format(key))
|
||||
|
||||
def _checkForTupleKey(self, parent, num, key):
|
||||
if not key in self.scryfallJson[parent][num]:
|
||||
raise KeyError('This ruling has no key \'{}\''.format(key))
|
||||
def _checkForTupleKey(self, parent, num, key):
|
||||
if not key in self.scryfallJson[parent][num]:
|
||||
raise KeyError('This ruling has no key \'{}\''.format(key))
|
||||
|
||||
def object(self):
|
||||
self._checkForKey('object')
|
||||
def object(self):
|
||||
self._checkForKey('object')
|
||||
|
||||
return self.scryfallJson['object']
|
||||
return self.scryfallJson['object']
|
||||
|
||||
def has_more(self):
|
||||
self._checkForKey('has_more')
|
||||
def has_more(self):
|
||||
self._checkForKey('has_more')
|
||||
|
||||
return self.scryfallJson['has_more']
|
||||
return self.scryfallJson['has_more']
|
||||
|
||||
def data(self):
|
||||
self._checkForKey('data')
|
||||
def data(self):
|
||||
self._checkForKey('data')
|
||||
|
||||
return self.scryfallJson['data']
|
||||
return self.scryfallJson['data']
|
||||
|
||||
def data_length(self):
|
||||
self._checkForKey('data')
|
||||
def data_length(self):
|
||||
self._checkForKey('data')
|
||||
|
||||
return len(self.scryfallJson['data'])
|
||||
return len(self.scryfallJson['data'])
|
||||
|
||||
def ruling_object(self, num):
|
||||
self._checkForTupleKey('data', num, 'object')
|
||||
def ruling_object(self, num):
|
||||
self._checkForTupleKey('data', num, 'object')
|
||||
|
||||
return self.scryfallJson['data'][num]['object']
|
||||
return self.scryfallJson['data'][num]['object']
|
||||
|
||||
def ruling_source(self, num):
|
||||
self._checkForTupleKey('data', num, 'source')
|
||||
def ruling_source(self, num):
|
||||
self._checkForTupleKey('data', num, 'source')
|
||||
|
||||
return self.scryfallJson['data'][num]['source']
|
||||
return self.scryfallJson['data'][num]['source']
|
||||
|
||||
def ruling_published_at(self, num):
|
||||
self._checkForTupleKey('data', num, 'published_at')
|
||||
def ruling_published_at(self, num):
|
||||
self._checkForTupleKey('data', num, 'published_at')
|
||||
|
||||
return self.scryfallJson['data'][num]['published_at']
|
||||
return self.scryfallJson['data'][num]['published_at']
|
||||
|
||||
def ruling_comment(self, num):
|
||||
self._checkForTupleKey('data', num, 'comment')
|
||||
def ruling_comment(self, num):
|
||||
self._checkForTupleKey('data', num, 'comment')
|
||||
|
||||
return self.scryfallJson['data'][num]['comment']
|
||||
return self.scryfallJson['data'][num]['comment']
|
||||
|
|
|
@ -4,133 +4,133 @@ import urllib.parse
|
|||
from threading import Thread
|
||||
|
||||
class SetsObject(object):
|
||||
"""
|
||||
The master class for all sets objects.
|
||||
"""
|
||||
The master class for all sets objects.
|
||||
|
||||
Positional arguments:
|
||||
No arguments required.
|
||||
Positional arguments:
|
||||
No arguments required.
|
||||
|
||||
Optional arguments:
|
||||
format : str ................... The format to return. Defaults to JSON.
|
||||
pretty : bool ... Makes the returned JSON prettier. The library may not work properly with this setting.
|
||||
Optional arguments:
|
||||
format : str ................... The format to return. Defaults to JSON.
|
||||
pretty : bool ... Makes the returned JSON prettier. The library may not work properly with this setting.
|
||||
|
||||
Attributes:
|
||||
object : str ...... Returns the type of object it is. (card, error, etc)
|
||||
code : str ........................ The three letter set code of the set
|
||||
mtgo_code : str ........................ The mtgo equivalent of `code()`
|
||||
name : str ................................... The full name of the set.
|
||||
set_type : str ......... The type of the set (expansion, commander, etc)
|
||||
released_at : str ....................... The date the set was launched.
|
||||
block_code : str ..... The the letter code for the block the set was in.
|
||||
block : str ................... The full name of the block a set was in.
|
||||
parent_set_code : str ................. The set code for the parent set.
|
||||
card_count : int ...................... The number of cards in the set.
|
||||
digital : bool .............. True if this set is only featured on MTGO.
|
||||
foil : bool ........................... True if this set only has foils.
|
||||
icon_svg_uri : str ................ A URI to the SVG of the set symbol.
|
||||
search_uri : str .................. The scryfall API url for the search.
|
||||
"""
|
||||
def __init__(self, _url, **kwargs):
|
||||
self.params = {'format': kwargs.get('format', 'json'), 'pretty': kwargs.get('pretty', '')}
|
||||
Attributes:
|
||||
object : str ...... Returns the type of object it is. (card, error, etc)
|
||||
code : str ........................ The three letter set code of the set
|
||||
mtgo_code : str ........................ The mtgo equivalent of `code()`
|
||||
name : str ................................... The full name of the set.
|
||||
set_type : str ......... The type of the set (expansion, commander, etc)
|
||||
released_at : str ....................... The date the set was launched.
|
||||
block_code : str ..... The the letter code for the block the set was in.
|
||||
block : str ................... The full name of the block a set was in.
|
||||
parent_set_code : str ................. The set code for the parent set.
|
||||
card_count : int ...................... The number of cards in the set.
|
||||
digital : bool .............. True if this set is only featured on MTGO.
|
||||
foil : bool ........................... True if this set only has foils.
|
||||
icon_svg_uri : str ................ A URI to the SVG of the set symbol.
|
||||
search_uri : str .................. The scryfall API url for the search.
|
||||
"""
|
||||
def __init__(self, _url, **kwargs):
|
||||
self.params = {'format': kwargs.get('format', 'json'), 'pretty': kwargs.get('pretty', '')}
|
||||
|
||||
self.encodedParams = urllib.parse.urlencode(self.params)
|
||||
self._url = 'https://api.scryfall.com/{0}&{1}'.format(_url, self.encodedParams)
|
||||
self.encodedParams = urllib.parse.urlencode(self.params)
|
||||
self._url = 'https://api.scryfall.com/{0}&{1}'.format(_url, self.encodedParams)
|
||||
|
||||
async def getRequest(client, url, **kwargs):
|
||||
async with client.get(url, **kwargs) as response:
|
||||
return await response.json()
|
||||
async def getRequest(client, url, **kwargs):
|
||||
async with client.get(url, **kwargs) as response:
|
||||
return await response.json()
|
||||
|
||||
async def main(loop):
|
||||
async with aiohttp.ClientSession(loop=loop) as client:
|
||||
self.scryfallJson = await getRequest(client, self._url)
|
||||
async def main(loop):
|
||||
async with aiohttp.ClientSession(loop=loop) as client:
|
||||
self.scryfallJson = await getRequest(client, self._url)
|
||||
|
||||
def do_everything():
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
loop.run_until_complete(main(loop))
|
||||
def do_everything():
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
loop.run_until_complete(main(loop))
|
||||
|
||||
t = Thread(target=do_everything)
|
||||
t.run()
|
||||
t = Thread(target=do_everything)
|
||||
t.run()
|
||||
|
||||
if self.scryfallJson['object'] == 'error':
|
||||
raise Exception(self.scryfallJson['details'])
|
||||
if self.scryfallJson['object'] == 'error':
|
||||
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 _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[parent][num][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')
|
||||
def object(self):
|
||||
self._checkForKey('object')
|
||||
|
||||
return self.scryfallJson['object']
|
||||
return self.scryfallJson['object']
|
||||
|
||||
def code(self):
|
||||
self._checkForKey('object')
|
||||
def code(self):
|
||||
self._checkForKey('object')
|
||||
|
||||
return self.scryfallJson['code']
|
||||
return self.scryfallJson['code']
|
||||
|
||||
def mtgo_code(self):
|
||||
self._checkForKey('mtgo_code')
|
||||
def mtgo_code(self):
|
||||
self._checkForKey('mtgo_code')
|
||||
|
||||
return self.scryfallJson['mtgo_code']
|
||||
return self.scryfallJson['mtgo_code']
|
||||
|
||||
def name(self):
|
||||
self._checkForKey('name')
|
||||
def name(self):
|
||||
self._checkForKey('name')
|
||||
|
||||
return self.scryfallJson['name']
|
||||
return self.scryfallJson['name']
|
||||
|
||||
def set_type(self):
|
||||
self._checkForKey('set_type')
|
||||
def set_type(self):
|
||||
self._checkForKey('set_type')
|
||||
|
||||
return self.scryfallJson['set_type']
|
||||
return self.scryfallJson['set_type']
|
||||
|
||||
def released_at(self):
|
||||
self._checkForKey('released_at')
|
||||
def released_at(self):
|
||||
self._checkForKey('released_at')
|
||||
|
||||
return self.scryfallJson['released_at']
|
||||
return self.scryfallJson['released_at']
|
||||
|
||||
def block_code(self):
|
||||
self._checkForKey('block_code')
|
||||
def block_code(self):
|
||||
self._checkForKey('block_code')
|
||||
|
||||
return self.scryfallJson['block_code']
|
||||
return self.scryfallJson['block_code']
|
||||
|
||||
def block(self):
|
||||
self._checkForKey('block')
|
||||
def block(self):
|
||||
self._checkForKey('block')
|
||||
|
||||
return self.scryfallJson['block']
|
||||
return self.scryfallJson['block']
|
||||
|
||||
def parent_set_code(self):
|
||||
self._checkForKey('parent_set_code')
|
||||
def parent_set_code(self):
|
||||
self._checkForKey('parent_set_code')
|
||||
|
||||
return self.scryfallJson['parent_set_code']
|
||||
return self.scryfallJson['parent_set_code']
|
||||
|
||||
def card_count(self):
|
||||
self._checkForKey('card_count')
|
||||
def card_count(self):
|
||||
self._checkForKey('card_count')
|
||||
|
||||
return self.scryfallJson['card_count']
|
||||
return self.scryfallJson['card_count']
|
||||
|
||||
def digital(self):
|
||||
self._checkForKey('digital')
|
||||
def digital(self):
|
||||
self._checkForKey('digital')
|
||||
|
||||
return self.scryfallJson['digital']
|
||||
return self.scryfallJson['digital']
|
||||
|
||||
def foil(self):
|
||||
self._checkForKey('foil')
|
||||
def foil(self):
|
||||
self._checkForKey('foil')
|
||||
|
||||
return self.scryfallJson['foil']
|
||||
return self.scryfallJson['foil']
|
||||
|
||||
def icon_svg_uri(self):
|
||||
self._checkForKey('icon_svg_uri')
|
||||
def icon_svg_uri(self):
|
||||
self._checkForKey('icon_svg_uri')
|
||||
|
||||
return self.scryfallJson['icon_svg_uri']
|
||||
return self.scryfallJson['icon_svg_uri']
|
||||
|
||||
def search_uri(self):
|
||||
self._checkForKey('search_uri')
|
||||
def search_uri(self):
|
||||
self._checkForKey('search_uri')
|
||||
|
||||
return self.scryfallJson['search_uri']
|
||||
return self.scryfallJson['search_uri']
|
||||
|
|
|
@ -1,64 +1,64 @@
|
|||
from .symbology_object import SymbologyObject
|
||||
|
||||
class ParseMana(SymbologyObject):
|
||||
"""
|
||||
symbology/parse-mana
|
||||
"""
|
||||
symbology/parse-mana
|
||||
|
||||
Positional arguments:
|
||||
cost : str ....................... The given mana cost you want. (`RUG`)
|
||||
Positional arguments:
|
||||
cost : str ....................... The given mana cost you want. (`RUG`)
|
||||
|
||||
Optional arguments:
|
||||
All arguments are inherited from SymbologyObject
|
||||
Optional arguments:
|
||||
All arguments are inherited from SymbologyObject
|
||||
|
||||
Attributes:
|
||||
object : str ...... Returns the type of object it is. (card, error, etc)
|
||||
mana_cost : str ............................... The formatted mana cost.
|
||||
cmc : float ....................... The converted mana cost of the card.
|
||||
colors : list ................... A list of all colors in the mana cost.
|
||||
colorless : bool ................... True if the mana cost is colorless.
|
||||
monocolored : bool .............. True if the mana cost is mono colored.
|
||||
multicolored : bool ...... True if the mana cost is a multicolored cost.
|
||||
Attributes:
|
||||
object : str ...... Returns the type of object it is. (card, error, etc)
|
||||
mana_cost : str ............................... The formatted mana cost.
|
||||
cmc : float ....................... The converted mana cost of the card.
|
||||
colors : list ................... A list of all colors in the mana cost.
|
||||
colorless : bool ................... True if the mana cost is colorless.
|
||||
monocolored : bool .............. True if the mana cost is mono colored.
|
||||
multicolored : bool ...... True if the mana cost is a multicolored cost.
|
||||
|
||||
Example usage:
|
||||
>>> mana = scrython.symbology.ParseMana(cost="xcug")
|
||||
>>> mana.colors()
|
||||
"""
|
||||
def __init__(self, cost):
|
||||
self.cost = cost
|
||||
self.url = 'symbology/parse-mana?cost=' + self.cost
|
||||
super(ParseMana, self).__init__(self.url)
|
||||
Example usage:
|
||||
>>> mana = scrython.symbology.ParseMana(cost="xcug")
|
||||
>>> mana.colors()
|
||||
"""
|
||||
def __init__(self, cost):
|
||||
self.cost = cost
|
||||
self.url = 'symbology/parse-mana?cost=' + self.cost
|
||||
super(ParseMana, self).__init__(self.url)
|
||||
|
||||
def object(self):
|
||||
super(ParseMana, self)._checkForKey('object')
|
||||
def object(self):
|
||||
super(ParseMana, self)._checkForKey('object')
|
||||
|
||||
return self.scryfallJson['object']
|
||||
return self.scryfallJson['object']
|
||||
|
||||
def mana_cost(self):
|
||||
super(ParseMana, self)._checkForKey('cost')
|
||||
def mana_cost(self):
|
||||
super(ParseMana, self)._checkForKey('cost')
|
||||
|
||||
return self.scryfallJson['cost']
|
||||
return self.scryfallJson['cost']
|
||||
|
||||
def cmc(self):
|
||||
super(ParseMana, self)._checkForKey('cmc')
|
||||
def cmc(self):
|
||||
super(ParseMana, self)._checkForKey('cmc')
|
||||
|
||||
return self.scryfallJson['cmc']
|
||||
return self.scryfallJson['cmc']
|
||||
|
||||
def colors(self):
|
||||
super(ParseMana, self)._checkForKey('colors')
|
||||
def colors(self):
|
||||
super(ParseMana, self)._checkForKey('colors')
|
||||
|
||||
return self.scryfallJson['colors']
|
||||
return self.scryfallJson['colors']
|
||||
|
||||
def colorless(self):
|
||||
super(ParseMana, self)._checkForKey('colorless')
|
||||
def colorless(self):
|
||||
super(ParseMana, self)._checkForKey('colorless')
|
||||
|
||||
return self.scryfallJson['colorless']
|
||||
return self.scryfallJson['colorless']
|
||||
|
||||
def monocolored(self):
|
||||
super(ParseMana, self)._checkForKey('monocolored')
|
||||
def monocolored(self):
|
||||
super(ParseMana, self)._checkForKey('monocolored')
|
||||
|
||||
return self.scryfallJson['monocolored']
|
||||
return self.scryfallJson['monocolored']
|
||||
|
||||
def multicolored(self):
|
||||
super(ParseMana, self)._checkForKey('multicolored')
|
||||
def multicolored(self):
|
||||
super(ParseMana, self)._checkForKey('multicolored')
|
||||
|
||||
return self.scryfallJson['multicolored']
|
||||
return self.scryfallJson['multicolored']
|
||||
|
|
|
@ -1,94 +1,94 @@
|
|||
from .symbology_object import SymbologyObject
|
||||
|
||||
class Symbology(SymbologyObject):
|
||||
"""
|
||||
/symbology
|
||||
"""
|
||||
/symbology
|
||||
|
||||
Positional arguments:
|
||||
No arguments are required.
|
||||
Positional arguments:
|
||||
No arguments are required.
|
||||
|
||||
Optional arguments:
|
||||
All arguments are inherited from SymbologyObject
|
||||
Optional arguments:
|
||||
All arguments are inherited from SymbologyObject
|
||||
|
||||
Attributes:
|
||||
object : str . Returns the type of object it is. (card, error, etc)
|
||||
has_more : bool . True if there are more pages to the object.
|
||||
data : list . A list of all data returned.
|
||||
data_length : int . The length of the data returned.
|
||||
Attributes:
|
||||
object : str . Returns the type of object it is. (card, error, etc)
|
||||
has_more : bool . True if there are more pages to the object.
|
||||
data : list . A list of all data returned.
|
||||
data_length : int . The length of the data returned.
|
||||
|
||||
The following require an integer as an arg, which acts as a tuple.
|
||||
symbol_symbol(num) : str . The plaintext symbol, usually written with curly braces.
|
||||
symbol_loose_variant(num) : str . The alternate version of the symbol, without curly braces.
|
||||
symbol_transposable(num): bool . True if it's possibly to write the symbol backwards.
|
||||
symbol_represents_mana(num): bool . True if this is a mana symbol.
|
||||
symbol_cmc(num): float . The total converted mana cost of the symbol.
|
||||
symbol_appears_in_mana_costs(num): bool . True if the symbol appears on the mana cost of any card.
|
||||
symbol_funny(num): bool . True if the symbol is featured on any funny cards.
|
||||
symbol_colors(num): float . An array of all colors in the given symbol.
|
||||
The following require an integer as an arg, which acts as a tuple.
|
||||
symbol_symbol(num) : str . The plaintext symbol, usually written with curly braces.
|
||||
symbol_loose_variant(num) : str . The alternate version of the symbol, without curly braces.
|
||||
symbol_transposable(num): bool . True if it's possibly to write the symbol backwards.
|
||||
symbol_represents_mana(num): bool . True if this is a mana symbol.
|
||||
symbol_cmc(num): float . The total converted mana cost of the symbol.
|
||||
symbol_appears_in_mana_costs(num): bool . True if the symbol appears on the mana cost of any card.
|
||||
symbol_funny(num): bool . True if the symbol is featured on any funny cards.
|
||||
symbol_colors(num): float . An array of all colors in the given symbol.
|
||||
|
||||
Example usage:
|
||||
>>> symbol = scrython.symbology.Symbology()
|
||||
"""
|
||||
def __init__(self):
|
||||
self.url = 'symbology?'
|
||||
super(Symbology, self).__init__(self.url)
|
||||
Example usage:
|
||||
>>> symbol = scrython.symbology.Symbology()
|
||||
"""
|
||||
def __init__(self):
|
||||
self.url = 'symbology?'
|
||||
super(Symbology, self).__init__(self.url)
|
||||
|
||||
def object(self):
|
||||
super(Symbology, self)._checkForKey('object')
|
||||
def object(self):
|
||||
super(Symbology, self)._checkForKey('object')
|
||||
|
||||
return self.scryfallJson['object']
|
||||
return self.scryfallJson['object']
|
||||
|
||||
def has_more(self):
|
||||
super(Symbology, self)._checkForKey('has_more')
|
||||
def has_more(self):
|
||||
super(Symbology, self)._checkForKey('has_more')
|
||||
|
||||
return self.scryfallJson['has_more']
|
||||
return self.scryfallJson['has_more']
|
||||
|
||||
def data(self):
|
||||
super(Symbology, self)._checkForKey('has_more')
|
||||
def data(self):
|
||||
super(Symbology, self)._checkForKey('has_more')
|
||||
|
||||
return self.scryfallJson['data']
|
||||
return self.scryfallJson['data']
|
||||
|
||||
def data_length(self):
|
||||
super(Symbology, self)._checkForKey('data')
|
||||
def data_length(self):
|
||||
super(Symbology, self)._checkForKey('data')
|
||||
|
||||
return len(self.scryfallJson['data'])
|
||||
return len(self.scryfallJson['data'])
|
||||
|
||||
def symbol_symbol(self, num):
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'symbol')
|
||||
def symbol_symbol(self, num):
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'symbol')
|
||||
|
||||
return self.scryfallJson['data'][num]['symbol']
|
||||
return self.scryfallJson['data'][num]['symbol']
|
||||
|
||||
def symbol_loose_variant(self, num):
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'loose_variant')
|
||||
def symbol_loose_variant(self, num):
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'loose_variant')
|
||||
|
||||
return self.scryfallJson['data'][num]['loose_variant']
|
||||
return self.scryfallJson['data'][num]['loose_variant']
|
||||
|
||||
def symbol_transposable(self, num):
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'transposable')
|
||||
def symbol_transposable(self, num):
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'transposable')
|
||||
|
||||
return self.scryfallJson['data'][num]['transposable']
|
||||
return self.scryfallJson['data'][num]['transposable']
|
||||
|
||||
def symbol_represents_mana(self, num):
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'represents_mana')
|
||||
def symbol_represents_mana(self, num):
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'represents_mana')
|
||||
|
||||
return self.scryfallJson['data'][num]['represents_mana']
|
||||
return self.scryfallJson['data'][num]['represents_mana']
|
||||
|
||||
def symbol_cmc(self, num):
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'cmc')
|
||||
def symbol_cmc(self, num):
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'cmc')
|
||||
|
||||
return self.scryfallJson['data'][num]['cmc']
|
||||
return self.scryfallJson['data'][num]['cmc']
|
||||
|
||||
def symbol_appears_in_mana_costs(self, num):
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'appears_in_mana_costs')
|
||||
def symbol_appears_in_mana_costs(self, num):
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'appears_in_mana_costs')
|
||||
|
||||
return self.scryfallJson['data'][num]['appears_in_mana_costs']
|
||||
return self.scryfallJson['data'][num]['appears_in_mana_costs']
|
||||
|
||||
def symbol_funny(self, num):
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'funny')
|
||||
def symbol_funny(self, num):
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'funny')
|
||||
|
||||
return self.scryfallJson['data'][num]['funny']
|
||||
return self.scryfallJson['data'][num]['funny']
|
||||
|
||||
def symbol_colors(self, num):
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'colors')
|
||||
def symbol_colors(self, num):
|
||||
super(Symbology, self)._checkForTupleKey('data', num, 'colors')
|
||||
|
||||
return self.scryfallJson['data'][num]['colors']
|
||||
return self.scryfallJson['data'][num]['colors']
|
||||
|
|
|
@ -4,48 +4,48 @@ import urllib.parse
|
|||
from threading import Thread
|
||||
|
||||
class SymbologyObject(object):
|
||||
"""
|
||||
The master class for all symbology objects.
|
||||
"""
|
||||
The master class for all symbology objects.
|
||||
|
||||
Positional arguments:
|
||||
No arguments required.
|
||||
Positional arguments:
|
||||
No arguments required.
|
||||
|
||||
Optional arguments:
|
||||
format : str ................... The format to return. Defaults to JSON.
|
||||
pretty : bool ... Makes the returned JSON prettier. The library may not work properly with this setting.
|
||||
Optional arguments:
|
||||
format : str ................... The format to return. Defaults to JSON.
|
||||
pretty : bool ... Makes the returned JSON prettier. The library may not work properly with this setting.
|
||||
|
||||
Attributes:
|
||||
No attributes to call.
|
||||
"""
|
||||
def __init__(self, _url, **kwargs):
|
||||
self.params = {'format': kwargs.get('format', 'json'), 'pretty': kwargs.get('pretty', '')}
|
||||
Attributes:
|
||||
No attributes to call.
|
||||
"""
|
||||
def __init__(self, _url, **kwargs):
|
||||
self.params = {'format': kwargs.get('format', 'json'), 'pretty': kwargs.get('pretty', '')}
|
||||
|
||||
self.encodedParams = urllib.parse.urlencode(self.params)
|
||||
self._url = 'https://api.scryfall.com/{0}&{1}'.format(_url, self.encodedParams)
|
||||
self.encodedParams = urllib.parse.urlencode(self.params)
|
||||
self._url = 'https://api.scryfall.com/{0}&{1}'.format(_url, self.encodedParams)
|
||||
|
||||
async def getRequest(client, url, **kwargs):
|
||||
async with client.get(url, **kwargs) as response:
|
||||
return await response.json()
|
||||
async def getRequest(client, url, **kwargs):
|
||||
async with client.get(url, **kwargs) as response:
|
||||
return await response.json()
|
||||
|
||||
async def main(loop):
|
||||
async with aiohttp.ClientSession(loop=loop) as client:
|
||||
self.scryfallJson = await getRequest(client, self._url)
|
||||
async def main(loop):
|
||||
async with aiohttp.ClientSession(loop=loop) as client:
|
||||
self.scryfallJson = await getRequest(client, self._url)
|
||||
|
||||
def do_everything():
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
loop.run_until_complete(main(loop))
|
||||
def do_everything():
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
loop.run_until_complete(main(loop))
|
||||
|
||||
t = Thread(target=do_everything)
|
||||
t.run()
|
||||
t = Thread(target=do_everything)
|
||||
t.run()
|
||||
|
||||
if self.scryfallJson['object'] == 'error':
|
||||
raise Exception(self.scryfallJson['details'])
|
||||
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 _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))
|
||||
def _checkForTupleKey(self, parent, num, key):
|
||||
if not key in self.scryfallJson[parent][num]:
|
||||
raise KeyError('This object has no key \'{}\''.format(key))
|
Loading…
Reference in New Issue