Updated all sets docs

This commit is contained in:
Nanda Scott 2018-10-25 21:35:36 -04:00
parent 80581d125f
commit b3fd5610b2
5 changed files with 68 additions and 225 deletions

View File

@ -7,8 +7,7 @@ Scrython is a wrapper for the Scryfall API, designed for an easier use. Make sur
# Dependencies
- `python` >= 3.5.3
- `asyncio` >= 3.4.3
- `aiohttp` >= 1.0.5
- `threading`
- `aiohttp` >= 3.4.4
## Key features

View File

@ -3,12 +3,14 @@ import scrython
from scrython import *
import re
intro = """These docs will likely not be as detailed as the official Scryfall Documentation, and you should reference that for more information.
>In the event that a key isn't found or has been changed, you can access the full JSON output with the `scryfallJson` variable (`{Class_name}().scryfallJson`)."""
for _class in scrython.__all__:
intro = """These docs will likely not be as detailed as the official Scryfall Documentation, and you should reference that for more information.
>In the event that a key isn't found or has been changed, you can access the full JSON output with the `scryfallJson` variable (`{}().scryfallJson`).
""".format(eval(_class).__name__)
match = list(filter(None, (token.strip() for token in re.findall(r'[^\n]*', eval(_class).__doc__))))
with open('{}.md'.format(eval(_class).__name__), 'w') as f:

View File

@ -1,3 +1,2 @@
aiohttp==3.1.3
asyncio==3.4.3
threading
aiohttp==3.4.4
asyncio==3.4.3

View File

@ -5,130 +5,88 @@ from scrython.foundation import FoundationObject
class Sets(FoundationObject):
"""
/sets
`Sets()` gets it's own special attributes that don't match with the normal set attributes.
Positional arguments:
code : str ............................... The 3 letter code of the set.
Optional arguments:
All arguments are inherited from SetsObject
Attributes:
object : str ... Returns the type of object it is. (card, error, etc)
has_more : bool ... True if there are more pages available.
data : list ... List of all data returned.
data_length : int ... The length of the data returned.
The following require an integer as an arg, which acts as a tuple.
set_object(num) : str .................................. The set object.
set_code(num) : str .............. The three letter set code of the set.
set_mtgo_code(num) : str .............. The mtgo equivalent of `code()`.
set_name(num) : str .......................... The full name of the set.
set_set_type(num) : str ... The type of the set (expansion, commander, etc)
set_released_at(num) : str .............. The date the set was launched.
set_block_code(num) : str ... The the letter code for the block the set was in.
set_block(num) : str .......... The full name of the block a set was in.
set_parent_set_code(num) : str ........ The set code for the parent set.
set_card_count(num) : int .............. The number of cards in the set.
set_digital(num) : bool ..... True if this set is only featured on MTGO.
set_foil_only(num) : bool ............. True if this set only has foils.
set_icon_svg_uri(num) : str ........ A URI to the SVG of the set symbol.
set_search_uri(num) : str ......... The scryfall API url for the search.
Args:
code (string): The 3 letter code of the set
format (string, optional):
Returns data in the specified method. Defaults to JSON.
pretty (string, optional):
Returns a prettier version of the json object. Note that this may break functionality with Scrython.
Example usage:
>>> set = scrython.sets.Sets()
>>> set.name(5)
>>> set.data(3, 'name')
"""
def __init__(self):
self._url = 'sets?'
super(Sets, self).__init__(self._url)
def object(self):
"""Returns the type of object it is
(card, error, etc)
Returns:
string
"""
super(Sets, self)._checkForKey('object')
return self.scryfallJson['object']
def has_more(self):
"""True if there are more pages available
Returns:
boolean
"""
super(Sets, self)._checkForKey('has_more')
return self.scryfallJson['has_more']
def data(self):
def data(self, index=None, key=None):
"""The data returned from the query
Acceptable keys:
object (string): The set object.
code (string): The three letter set code of the set.
mtgo_code (string): The mtgo equivalent of `code()`.
name (string): The full name of the set.
set_type (string): The type of the set (expansion, commander, etc)
released_at (string): The date the set was launched.
block_code (string): The the letter code for the block the set was in.
block (string): The full name of the block a set was in.
parent_set_code (string): The set code for the parent set.
card_count (integer): The number of cards in the set.
digital (boolean): True if this set is only featured on MTGO.
foil_only (boolean): True if this set only has foils.
icon_svg_uri (string): A URI to the SVG of the set symbol.
search_uri (string): The scryfall API url for the search.
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.
"""
super(Sets, self)._checkForKey('data')
if index is not None:
if key is not None:
super(Sets, self)._checkForTupleKey('data', index, key)
return self.scryfallJson['data'][index][key]
return self.scryfallJson['data'][index]
return self.scryfallJson['data']
def data_length(self):
"""The length of the data returned
Returns:
integer
"""
super(Sets, self)._checkForKey('data')
return len(self.scryfallJson['data'])
def set_object(self, num):
super(Sets, self)._checkForTupleKey('data', num, 'object')
return self.scryfallJson['data'][num]['object']
def set_code(self, num):
super(Sets, self)._checkForTupleKey('data', num, 'code')
return self.scryfallJson['data'][num]['code']
def set_mtgo_code(self, num):
super(Sets, self)._checkForTupleKey('data', num, 'mtgo_code')
return self.scryfallJson['data'][num]['mtgo_code']
def set_name(self, num):
super(Sets, self)._checkForTupleKey('data', num, 'name')
return self.scryfallJson['data'][num]['name']
def set_set_type(self, num):
super(Sets, self)._checkForTupleKey('data', num, 'set_type')
return self.scryfallJson['data'][num]['set_type']
def set_released_at(self, num):
super(Sets, self)._checkForTupleKey('data', num, 'released_at')
return self.scryfallJson['data'][num]['released_at']
def set_block_code(self, num):
super(Sets, self)._checkForTupleKey('data', num, 'block_code')
return self.scryfallJson['data'][num]['block_code']
def set_block(self, num):
super(Sets, self)._checkForTupleKey('data', num, 'block')
return self.scryfallJson['data'][num]['block']
def set_parent_set_code(self, num):
super(Sets, self)._checkForTupleKey('data', num, 'parent_set_code')
return self.scryfallJson['data'][num]['parent_set_code']
def set_card_count(self, num):
super(Sets, self)._checkForTupleKey('data', num, 'card_count')
return self.scryfallJson['data'][num]['card_count']
def set_digital(self, num):
super(Sets, self)._checkForTupleKey('data', num, 'digital')
return self.scryfallJson['data'][num]['digital']
def set_foil_only(self, num):
super(Sets, self)._checkForTupleKey('data', num, 'foil_only')
return self.scryfallJson['data'][num]['foil_only']
def set_icon_svg_uri(self, num):
super(Sets, self)._checkForTupleKey('data', num, 'icon_svg_uri')
return self.scryfallJson['data'][num]['icon_svg_uri']
def set_search_uri(self, num):
super(Sets, self)._checkForTupleKey('data', num, 'search_uri')
return self.scryfallJson['data'][num]['search_uri']
return len(self.scryfallJson['data'])

View File

@ -1,115 +0,0 @@
import sys
sys.path.append('..')
from scrython.foundation import FoundationObject
import asyncio
import aiohttp
import urllib.parse
from threading import Thread
class SetsObject(FoundationObject):
"""
The master class for all sets objects.
Positional arguments:
No arguments required.
Optional arguments:
format : str ................... The format to return. Defaults to JSON.
pretty : bool ... Makes the returned JSON prettier. The library may not work properly with this setting.
Attributes:
object : str ...... Returns the type of object it is. (card, error, etc)
code : str ........................ The three letter set code of the set
mtgo_code : str ........................ The mtgo equivalent of `code()`
name : str ................................... The full name of the set.
set_type : str ......... The type of the set (expansion, commander, etc)
released_at : str ....................... The date the set was launched.
block_code : str ..... The the letter code for the block the set was in.
block : str ................... The full name of the block a set was in.
parent_set_code : str ................. The set code for the parent set.
card_count : int ...................... The number of cards in the set.
digital : bool .............. True if this set is only featured on MTGO.
foil_only : bool ........................... True if this set only has foils.
icon_svg_uri : str ................ A URI to the SVG of the set symbol.
search_uri : str .................. The scryfall API url for the search.
"""
def _checkForKey(self, key):
if not key in self.scryfallJson:
raise KeyError('This object has no key \'{}\''.format(key))
def _checkForTupleKey(self, parent, num, key):
try:
return self.scryfallJson[parent][num][key]
except Exception:
raise KeyError('This object has no key \'{}\''.format(key))
def object(self):
self._checkForKey('object')
return self.scryfallJson['object']
def code(self):
self._checkForKey('object')
return self.scryfallJson['code']
def mtgo_code(self):
self._checkForKey('mtgo_code')
return self.scryfallJson['mtgo_code']
def name(self):
self._checkForKey('name')
return self.scryfallJson['name']
def set_type(self):
self._checkForKey('set_type')
return self.scryfallJson['set_type']
def released_at(self):
self._checkForKey('released_at')
return self.scryfallJson['released_at']
def block_code(self):
self._checkForKey('block_code')
return self.scryfallJson['block_code']
def block(self):
self._checkForKey('block')
return self.scryfallJson['block']
def parent_set_code(self):
self._checkForKey('parent_set_code')
return self.scryfallJson['parent_set_code']
def card_count(self):
self._checkForKey('card_count')
return self.scryfallJson['card_count']
def digital(self):
self._checkForKey('digital')
return self.scryfallJson['digital']
def foil_only(self):
self._checkForKey('foil_only')
return self.scryfallJson['foil_only']
def icon_svg_uri(self):
self._checkForKey('icon_svg_uri')
return self.scryfallJson['icon_svg_uri']
def search_uri(self):
self._checkForKey('search_uri')
return self.scryfallJson['search_uri']