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