From 3704ad40d26dd70ae24131494e4ed6ae7f79ccf8 Mon Sep 17 00:00:00 2001 From: Nanda Scott Date: Wed, 21 Feb 2018 19:00:01 -0500 Subject: [PATCH] Added docstrings to Sets. --- scrython/catalog/catalogs_object.py | 2 +- scrython/sets/code.py | 17 ++++++++++++++ scrython/sets/sets.py | 36 +++++++++++++++++++++++++++++ scrython/sets/sets_object.py | 26 +++++++++++++++++++++ 4 files changed, 80 insertions(+), 1 deletion(-) diff --git a/scrython/catalog/catalogs_object.py b/scrython/catalog/catalogs_object.py index 533e64a..9b5cda8 100644 --- a/scrython/catalog/catalogs_object.py +++ b/scrython/catalog/catalogs_object.py @@ -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: diff --git a/scrython/sets/code.py b/scrython/sets/code.py index 9ac8e7b..51f1b34 100644 --- a/scrython/sets/code.py +++ b/scrython/sets/code.py @@ -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) diff --git a/scrython/sets/sets.py b/scrython/sets/sets.py index e929e4a..a19ff69 100644 --- a/scrython/sets/sets.py +++ b/scrython/sets/sets.py @@ -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) diff --git a/scrython/sets/sets_object.py b/scrython/sets/sets_object.py index 0b1c8d5..698548d 100644 --- a/scrython/sets/sets_object.py +++ b/scrython/sets/sets_object.py @@ -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', '')}