From 1d869b872c7d9194074f38305f1be4da3a406d0b Mon Sep 17 00:00:00 2001 From: Nanda Scott Date: Thu, 25 Oct 2018 16:04:36 -0400 Subject: [PATCH] Updated/added docs for rulings --- scrython/rulings/arena.py | 17 ++--- scrython/rulings/mtgo.py | 17 ++--- scrython/rulings/multiverse_id.py | 17 ++--- scrython/rulings/rulings_object.py | 105 +++++++++++++---------------- scrython/rulings/scryfall_id.py | 17 ++--- scrython/rulings/set_code.py | 19 +++--- 6 files changed, 92 insertions(+), 100 deletions(-) diff --git a/scrython/rulings/arena.py b/scrython/rulings/arena.py index ef7d280..385b22f 100644 --- a/scrython/rulings/arena.py +++ b/scrython/rulings/arena.py @@ -6,14 +6,15 @@ class Arena(RulingsObject): Gets the ruling of a card by the Arena Id. - Positional arguments: - id : str ................. The arena id of the card you want rulings for. - - Optional arguments: - All arguments inherited from RulingsObject - - Attributes: - All attributes inherited from RulingsObject + Args: + id (string): The arena id of the card you want rulings for. + format (string, optional): Returns data in the specified method. Defaults to JSON. + face (string, optional): + If you're using the `image` format, this will specify if you want the front or back face. + version (string, optional): + If you're using the `image` format, this will specify if you want the small, normal, large, etc version of the image. + pretty (string, optional): + Returns a prettier version of the json object. Note that this may break functionality with Scrython. Example usage: >>> rule = scrython.rulings.Arena(id='66975') diff --git a/scrython/rulings/mtgo.py b/scrython/rulings/mtgo.py index f1f7310..8fc9ab5 100644 --- a/scrython/rulings/mtgo.py +++ b/scrython/rulings/mtgo.py @@ -6,14 +6,15 @@ class Mtgo(RulingsObject): Gets the ruling of a card by the Mtgo Id. - Positional arguments: - id : str ................. The mtgo id of the card you want rulings for. - - Optional arguments: - All arguments inherited from RulingsObject - - Attributes: - All attributes inherited from RulingsObject + Args: + id (string): The mtgo id of the card you want rulings for. + format (string, optional): Returns data in the specified method. Defaults to JSON. + face (string, optional): + If you're using the `image` format, this will specify if you want the front or back face. + version (string, optional): + If you're using the `image` format, this will specify if you want the small, normal, large, etc version of the image. + pretty (string, optional): + Returns a prettier version of the json object. Note that this may break functionality with Scrython. Example usage: >>> rule = scrython.rulings.Mtgo(id='9611') diff --git a/scrython/rulings/multiverse_id.py b/scrython/rulings/multiverse_id.py index ceea643..8270f04 100644 --- a/scrython/rulings/multiverse_id.py +++ b/scrython/rulings/multiverse_id.py @@ -6,14 +6,15 @@ class Multiverse(RulingsObject): Gets the ruling of a card by the Multiverse Id. - Positional arguments: - id : str ........... The multiverse id of the card you want rulings for. - - Optional arguments: - All arguments inherited from RulingsObject - - Attributes: - All attributes inherited from RulingsObject + Args: + id (string): The multiverse id of the card you want rulings for. + format (string, optional): Returns data in the specified method. Defaults to JSON. + face (string, optional): + If you're using the `image` format, this will specify if you want the front or back face. + version (string, optional): + If you're using the `image` format, this will specify if you want the small, normal, large, etc version of the image. + pretty (string, optional): + Returns a prettier version of the json object. Note that this may break functionality with Scrython. Example usage: >>> rule = scrython.rulings.Id(id='4301') diff --git a/scrython/rulings/rulings_object.py b/scrython/rulings/rulings_object.py index ef587c3..9a47ddb 100644 --- a/scrython/rulings/rulings_object.py +++ b/scrython/rulings/rulings_object.py @@ -1,64 +1,66 @@ import sys sys.path.append('..') from scrython.foundation import FoundationObject -import asyncio -import aiohttp -import urllib.parse -from threading import Thread class RulingsObject(FoundationObject): """ Master class for all rulings objects. - Positional arguments: - No arguments required. + Args: + format (string, optional): Returns data in the specified method. Defaults to JSON. + face (string, optional): + If you're using the `image` format, this will specify if you want the front or back face. + version (string, optional): + If you're using the `image` format, this will specify if you want the small, normal, large, etc version of the image. + pretty (string, optional): + Returns a prettier version of the json object. Note that this may break functionality with Scrython. - 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) - had_more : bool ... If true, this ruling object has more rules than it currently displays. - data : list .................................. A list of ruling objects. - data_length : int ....................... The length of the `data` list. - - The following require an integer as an arg, which acts as a tuple. - ruling_object : str ............. The type of object for a given ruling. - ruling_source : str .......................... The source of the ruling. - ruling_published_at : str ...... The date when the ruling was published. - ruling_comment : str ............................. The effective ruling. """ - 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): - if not key in self.scryfallJson[parent][num]: - raise KeyError('This ruling has no key \'{}\''.format(key)) - def object(self): - self._checkForKey('object') + """Returns the type of object it is + (card, error, etc) + + Returns: + string + """ + super(RulingsObject, self)._checkForKey('object') return self.scryfallJson['object'] def has_more(self): - self._checkForKey('has_more') + """True if there is more than one page of results + + Returns: + boolean: True if there are more results + """ + super(RulingsObject, self)._checkForKey('has_more') return self.scryfallJson['has_more'] def data(self, index=None, key=None): - self._checkForKey('data') + """The data returned from the query + + Acceptable keys: + object (string): The type of object for a given ruling. + source (string): The source of the ruling. + published_at (string): The date when the ruling was published. + comment (string): The effective ruling. + + 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(RulingsObject, self)._checkForKey('data') if index is not None: if key is not None: - self._checkForTupleKey('data', index, key) + super(RulingsObject, self)._checkForTupleKey('data', index, key) return self.scryfallJson['data'][index][key] return self.scryfallJson['data'][index] @@ -66,26 +68,11 @@ class RulingsObject(FoundationObject): return self.scryfallJson['data'] def data_length(self): - self._checkForKey('data') + """The length of the `data` list. + + Returns: + Integer + """ + super(RulingsObject, self)._checkForKey('data') return len(self.scryfallJson['data']) - - def ruling_object(self, num): - self._checkForTupleKey('data', num, 'object') - - return self.scryfallJson['data'][num]['object'] - - def ruling_source(self, num): - self._checkForTupleKey('data', num, 'source') - - return self.scryfallJson['data'][num]['source'] - - def ruling_published_at(self, num): - self._checkForTupleKey('data', num, 'published_at') - - return self.scryfallJson['data'][num]['published_at'] - - def ruling_comment(self, num): - self._checkForTupleKey('data', num, 'comment') - - return self.scryfallJson['data'][num]['comment'] diff --git a/scrython/rulings/scryfall_id.py b/scrython/rulings/scryfall_id.py index 457adcd..5c5528d 100644 --- a/scrython/rulings/scryfall_id.py +++ b/scrython/rulings/scryfall_id.py @@ -6,14 +6,15 @@ class Id(RulingsObject): Gets the ruling of a card by the Scryfall Id. - Positional arguments: - id : str ...................... The id of the card you want rulings for. - - Optional arguments: - All arguments inherited from RulingsObject - - Attributes: - All attributes inherited from RulingsObject + Args: + id (string): The id of the card you want rulings for. + format (string, optional): Returns data in the specified method. Defaults to JSON. + face (string, optional): + If you're using the `image` format, this will specify if you want the front or back face. + version (string, optional): + If you're using the `image` format, this will specify if you want the small, normal, large, etc version of the image. + pretty (string, optional): + Returns a prettier version of the json object. Note that this may break functionality with Scrython. Example usage: >>> rule = scrython.rulings.Id(id='5976c352-ac49-4e0d-a4c0-ec9b6b78db9c') diff --git a/scrython/rulings/set_code.py b/scrython/rulings/set_code.py index 433352e..2b05b2d 100644 --- a/scrython/rulings/set_code.py +++ b/scrython/rulings/set_code.py @@ -6,15 +6,16 @@ class Code(RulingsObject): Gets the ruling of a card by the set and collector number. - Positional arguments: - set : str ...... The 3 letter set code of the card you want rulings for. - collector_number : ................... The collector number of the card. - - Optional arguments: - All arguments inherited from RulingsObject - - Attributes: - All attributes inherited from RulingsObject + Args: + set (string): The 3 letter set code of the card you want rulings for. + collector_number (string): The collector number of the card. + format (string, optional): Returns data in the specified method. Defaults to JSON. + face (string, optional): + If you're using the `image` format, this will specify if you want the front or back face. + version (string, optional): + If you're using the `image` format, this will specify if you want the small, normal, large, etc version of the image. + pretty (string, optional): + Returns a prettier version of the json object. Note that this may break functionality with Scrython. Example usage: >>> rule = scrython.rulings.Code(code='ddg', collector_number='42')