From 3f05856b4acce553e8c0edac087eaea3c4063ff5 Mon Sep 17 00:00:00 2001 From: Nanda Scott Date: Wed, 21 Feb 2018 14:42:58 -0500 Subject: [PATCH] Added docstrings to all Cards classes. --- scrython/cards/autocomplete.py | 19 ++++++++++ scrython/cards/cardid.py | 17 +++++++++ scrython/cards/cards_object.py | 66 ++++++++++++++++++++++++++++++++++ scrython/cards/collector.py | 18 ++++++++++ scrython/cards/mtgo.py | 17 +++++++++ scrython/cards/multiverse.py | 17 +++++++++ scrython/cards/named.py | 20 +++++++++++ scrython/cards/randomcard.py | 17 +++++++++ scrython/cards/search.py | 27 ++++++++++++++ 9 files changed, 218 insertions(+) diff --git a/scrython/cards/autocomplete.py b/scrython/cards/autocomplete.py index 360bfe3..ab79e49 100644 --- a/scrython/cards/autocomplete.py +++ b/scrython/cards/autocomplete.py @@ -2,6 +2,25 @@ from .cards_object import CardsObject import urllib.parse class Autocomplete(CardsObject): + """ + cards/autocomplete + Get a list of potential autocompletion phrases. + + Positional arguments: + query : str ........... The query of the autocompletion. + + Optional arguments: + Inherits arguments from CardsObject. + + Attributes: + object : str ........ Returns what kind of object it is. + total_items : int ...... How many items are in the list. + data : list ....... The list of potential autocompletes. + + Example usage: + >>> auto = scrython.cards.Autocomplete(q="Thal") + >>> auto.total_items() + """ def __init__(self, **kwargs): if kwargs.get('query') is None: raise TypeError('No query provided to search by') diff --git a/scrython/cards/cardid.py b/scrython/cards/cardid.py index d5390d0..351530c 100644 --- a/scrython/cards/cardid.py +++ b/scrython/cards/cardid.py @@ -1,6 +1,23 @@ from .cards_object import CardsObject class Id(CardsObject): + """ + cards/id + Get a card by the Scryfall id. + + Positional arguments: + id : str ....................... The Scryfall Id of the card. + + Optional arguments: + Inherits all arguments from CardsObject. + + Attributes: + All attributes are inherited from CardsObject. + + Example usage: + >>> card = scrython.cards.Id(id="5386a61c-4928-4bd1-babe-5b089ab8b2d9") + >>> card.name() + """ def __init__(self, **kwargs): if kwargs.get('id') is None: raise TypeError('No id provided to search by') diff --git a/scrython/cards/cards_object.py b/scrython/cards/cards_object.py index de220dc..2490d9f 100644 --- a/scrython/cards/cards_object.py +++ b/scrython/cards/cards_object.py @@ -3,6 +3,72 @@ import asyncio import urllib.parse class CardsObject(object): + """ + Master class that all card objects inherit from. + + Positional arguments: + No positional arguments are required. + + Optional arguments: + format : str ... Returns data in the specified method. Defaults to JSON. + face : str ... If you're using the `image` format, this will specify if + you want the front or back face. + version : str ... If you're using the `image` format, this will specify if + you want the small, normal, large, etc version of the image. + pretty : str ... Returns a prettier version of the json object. Note that + this may break functionality with Scrython. + Attributes: + object : str ..... Returns the type of object it is. (card, error, etc) + id : str ................................. The scryfall id of the card. + multiverse_ids : list ...... The associated multiverse ids 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. + name : str ................................. The full name of the card. + uri : str .......................... The Scryfall API uri for the card. + scryfall_uri : str ................ The full Scryfall page of the card. + layout : str ... The image layout of the card. (normal, transform, etc) + 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. + cmc : float ........... A float of the converted mana cost of the card. + type_line : str ....................... The full type line of the card. + oracle_text : str ................. The official oracle text of a card. + 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. + 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. + reserved : bool ..... Returns True if the card is on the reserved list. + 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_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_search_uri : str .......................... Same output as set_uri. + scryfall_set_uri : str .......... The full link to the set on Scryfall. + 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. + collector_number : str .............. The collector number of the card. + digital : bool ....... Returns True if the card is the digital version. + rarity : str .................................. The rarity of the card. + illuStringation_id : str .............. The related id of the card art. + artist : str .................................. The artist of the card. + frame : str ............................... The year of the card frame. + full_art : bool ...... Returns True if the card is considered full art. + border_color : str ...................... The color of the card border. + timeshifted : bool ........... Returns True if the card is timeshifted. + colorshifted : bool ......... Returns True if the card is colorshifted. + futureshifted : bool ....... Returns True if the card is futureshifted. + edhrec_rank : int .................. The rank of the card on edhrec.com + currency("")` : str ... Returns currency from modes `usd`, `eur`, and `tix`. + related_uris : dict ... A dictionary of related websites for this 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. + 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. + 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. + watermark : str ......... The associated watermark of the card, 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. + """ def __init__(self, _url, **kwargs): self.params = { diff --git a/scrython/cards/collector.py b/scrython/cards/collector.py index 5e8e54e..0b02915 100644 --- a/scrython/cards/collector.py +++ b/scrython/cards/collector.py @@ -1,6 +1,24 @@ from .cards_object import CardsObject class Collector(CardsObject): + """ + cards/collector + Get a card by collector number. + + Positional arguments: + code : str ....................... This is the 3 letter code for the set + collector_number : str ........ This is the collector number of the card + + Optional arguments: + Inherits all arguments from CardsObject + + Attributes: + Inherits all attributes from CardsObject + + Example usage: + >>> card = scrython.cards.Collector(code='exo', collector_number='96') + >>> card.id() + """ def __init__(self, **kwargs): if kwargs.get('code') is None: raise TypeError('No code provided to search by') diff --git a/scrython/cards/mtgo.py b/scrython/cards/mtgo.py index 694262e..342bcda 100644 --- a/scrython/cards/mtgo.py +++ b/scrython/cards/mtgo.py @@ -2,6 +2,23 @@ from .cards_object import CardsObject import urllib.parse class Mtgo(CardsObject): + """ + cards/mtgo + Get a card by MTGO id. + + Positional arguments: + id : str ............................. The required mtgo id of the card. + + Optional arguments: + All arguments are inherited from CardsObject + + Attributes: + All attributes are inherited from CardsObject + + Example usage: + >>> card = scrython.cards.Mtgo(id="48296") + >>> card.set_name() + """ def __init__(self, **kwargs): if kwargs.get('id') is None: raise TypeError('No id provided to search by') diff --git a/scrython/cards/multiverse.py b/scrython/cards/multiverse.py index 819ae44..4174868 100644 --- a/scrython/cards/multiverse.py +++ b/scrython/cards/multiverse.py @@ -1,6 +1,23 @@ from .cards_object import CardsObject class Multiverse(CardsObject): + """ + cards/multiverse + Get a card by Multiverse id + + Positional arguments: + id : str ....... This is the associated multiverse id of the given card. + + Optional arguments: + Inherits all arguments from CardsObject + + Attributes: + Inherits all attributes from CardsObject + + Example usage: + >>> card = scrython.cards.Multiverse(id='96865') + >>> card.name() + """ def __init__(self, **kwargs): if kwargs.get('id') is None: raise TypeError('No id provided to search by') diff --git a/scrython/cards/named.py b/scrython/cards/named.py index c28a42f..325fa38 100644 --- a/scrython/cards/named.py +++ b/scrython/cards/named.py @@ -2,6 +2,26 @@ from .cards_object import CardsObject import urllib.parse class Named(CardsObject): + """ + cards/named + Gets a card by the name. + + Positional arguments: + fuzzy : str ................ Uses the fuzzy parameter for the card name. + or + exact : str ................ Uses the exact parameter for the card name. + + Optional arguments: + set : str . Returns the set of the card if specified. Requires the 3 letter set code. + All arguments are inherited from CardsObject + + Attributes: + All attributes are inherited from CardsObject + + Example usage: + >>> card = scrython.cards.Named(exact="Black Lotus") + >>> card.colors() + """ def __init__(self, **kwargs): self.dict = { 'set':kwargs.get('set', '') diff --git a/scrython/cards/randomcard.py b/scrython/cards/randomcard.py index 7b2ea82..5b0e272 100644 --- a/scrython/cards/randomcard.py +++ b/scrython/cards/randomcard.py @@ -2,6 +2,23 @@ from .cards_object import CardsObject class Random(CardsObject): + """ + cards/random + Get a random card. + + Positional arguments: + No arguments are required. + + Optional arguments: + All arguments are inherited from CardsObject + + Attributes: + All attributes are inherited from CardsObject + + Example usage: + >>> card = scrython.cards.Random() + >>> card.purchase_uris() + """ def __init__(self): self.url = 'cards/random?' super(Random, self).__init__(self.url) diff --git a/scrython/cards/search.py b/scrython/cards/search.py index 528a7af..0faf90b 100644 --- a/scrython/cards/search.py +++ b/scrython/cards/search.py @@ -2,6 +2,33 @@ from .cards_object import CardsObject import urllib.parse class Search(CardsObject): + """ + cards/search + Uses a search query to gather relevant data. + + Positional arguments: + q : str ...... The query to search. This will be updated in the future. + + Optional arguments: + order : str ................... The order you'd like the data returned. + unique : str ........................... A way to filter similar cards. + dir : str ......... The direction you'd like to sort. (asc, desc, auto) + include_extras : bool ... Includes cards that are normally omitted from + search results, like Un-sets. + page : int .............. The page number you'd like to search, if any. + Inherits all arguments from CardsObject. + + Attributes: + object : str ....................... Returns what kind of object it is. + total_cards : int ......... How many cards are returned from the query. + data : list ...................... The list of potential autocompletes. + 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. + + Example usage: + >>> search = scrython.cards.Search(q="++e:A25", order="spoiled") + >>> search.data() + """ def __init__(self, **kwargs): if kwargs.get('q') is None: raise TypeError('No query is specified.')