Scrython/scrython/symbology/symbology.py

89 lines
2.7 KiB
Python
Raw Normal View History

import sys
sys.path.append('..')
from scrython.foundation import FoundationObject
2018-02-19 17:20:05 +00:00
class Symbology(FoundationObject):
2018-10-22 14:19:38 +00:00
"""
/symbology
2018-02-22 00:17:22 +00:00
2018-10-28 05:09:09 +00:00
Args:
N/A
Returns:
N/A
Raises:
N/A
Examples:
2018-10-22 14:19:38 +00:00
>>> symbol = scrython.symbology.Symbology()
"""
def __init__(self):
self.url = 'symbology?'
super(Symbology, self).__init__(self.url)
2018-02-19 17:20:05 +00:00
2018-10-22 14:19:38 +00:00
def object(self):
2018-10-26 14:45:05 +00:00
"""Returns the type of object it is
(card, error, etc)
Returns:
string
"""
2018-10-22 14:19:38 +00:00
super(Symbology, self)._checkForKey('object')
2018-02-19 17:20:05 +00:00
2018-10-22 14:19:38 +00:00
return self.scryfallJson['object']
2018-02-19 17:20:05 +00:00
2018-10-22 14:19:38 +00:00
def has_more(self):
2018-10-26 14:45:05 +00:00
"""True if there are more pages to the object
Returns:
boolean
"""
2018-10-22 14:19:38 +00:00
super(Symbology, self)._checkForKey('has_more')
2018-02-19 17:20:05 +00:00
2018-10-22 14:19:38 +00:00
return self.scryfallJson['has_more']
2018-02-19 17:20:05 +00:00
2018-10-26 14:45:05 +00:00
def data(self, index=None, key=None):
"""The data returned from the query
Acceptable keys:
symbol (string): The plaintext symbol, usually written with curly braces
loose_variant (string): The alternate version of the symbol, without curly braces
transposable (boolean): True if it's possibly to write the symbol backwards
represents_mana (boolean): True if this is a mana symbol
cmc (float): The total converted mana cost of the symbol
appears_in_mana_costs (boolean): True if the symbol appears on the mana cost of any card
funny (boolean): True if the symbol is featured on any funny cards
colors (array): An array of all colors in the given symbol
english (string): An english sentence describing the mana cost
gatherer_alternate (array): An array of Gatherer like costs
Args:
index (integer, optional): Defaults to None. Access a specific index.
key (string, optional): Defaults to None. Returns the value of the given key. Requires the `index` argument.
Returns:
List: The full list of data.
Dictionary: If given an index
String: If given an index and key.
"""
2018-10-22 14:19:38 +00:00
super(Symbology, self)._checkForKey('has_more')
2018-02-19 17:20:05 +00:00
2018-10-26 14:45:05 +00:00
if index is not None:
if key is not None:
super(Symbology, self)._checkForTupleKey('data', index, key)
return self.scryfallJson['data'][index][key]
return self.scryfallJson['data'][index]
2018-10-22 14:19:38 +00:00
return self.scryfallJson['data']
2018-02-19 17:20:05 +00:00
2018-10-22 14:19:38 +00:00
def data_length(self):
2018-10-26 14:45:05 +00:00
"""The length of the data returned
Returns:
integer
"""
2018-10-22 14:19:38 +00:00
super(Symbology, self)._checkForKey('data')
2018-02-19 17:20:05 +00:00
2018-10-26 14:45:05 +00:00
return len(self.scryfallJson['data'])