Added docstrings to Sets.

This commit is contained in:
Nanda Scott 2018-02-21 19:00:01 -05:00
parent 08c8e95c46
commit 3704ad40d2
4 changed files with 80 additions and 1 deletions

View File

@ -10,7 +10,7 @@ class CatalogsObject(object):
No arguments are required.
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.
Attributes:

View File

@ -1,6 +1,23 @@
from .sets_object import SetsObject
class Code(SetsObject):
"""
sets/:code
Get a set with a 3 letter code.
Positional arguments:
code : str ............................... The 3 letter code of the set.
Optional arguments:
All arguments are inherited from SetsObject
Attributes:
All attributes are inherited from SetsObject
Example usage:
>>> set = scrython.sets.Code(code='por')
>>> set.name()
"""
def __init__(self, code):
self._url = 'sets/{}?'.format(code)
super(Code, self).__init__(self._url)

View File

@ -1,6 +1,42 @@
from .sets_object import SetsObject
class Sets(SetsObject):
"""
/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(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.
Example usage:
>>> set = scrython.sets.Sets()
>>> set.name(5)
"""
def __init__(self):
self._url = 'sets?'
super(Sets, self).__init__(self._url)

View File

@ -3,6 +3,32 @@ import aiohttp
import urllib.parse
class SetsObject(object):
"""
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 : bool ........................... True if this set only has foils.
icon_svg_uri : str ................ A URI to the SVG of the set symbol.
search_uri : str .................. The scryfall API url for the search.
"""
def __init__(self, _url, **kwargs):
self.params = {'format': kwargs.get('format', 'json'), 'pretty': kwargs.get('pretty', '')}