Created docs, and cleaned up some code for more consistency.

This commit is contained in:
Nanda Scott 2018-02-19 17:04:43 -05:00
parent bb48c4ca83
commit b76e9032d5
12 changed files with 251 additions and 300 deletions

View File

@ -33,4 +33,4 @@ For the most part I've kept all the class attributes the same as their key names
## Key features ## Key features
- Asyncronous requests. This library utilizes the `asyncio` and `aiohttp` libraries to ensure that requests are not blocked when used in asyncronous environments. There is no delay limiting when making a request, so be careful how many objects are created. - Asyncronous requests. This library utilizes the `asyncio` and `aiohttp` libraries to ensure that requests are not blocked when used in asyncronous environments. There is no delay limiting when making a request, so be careful how many objects are created.
- Full use of all endpoints in a given category. This library uses every endpoint within `cards` and `rulings`as of writing this. I hope to include more as this is developed. - Full use of all endpoints in a given category. This library uses every endpoint within `cards` and `rulings` as of writing this. I hope to include more as this is developed.

View File

@ -1,4 +1,5 @@
# Cards # Cards
Documentation for a card object. These docs will likely not be as detailed as the official Scryfall Documentation, and you should reference that for more information. Documentation for a card object. 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 (`card.scryfallJson`). >In the event that a key isn't found or has been changed, you can access the full JSON output with the `scryfallJson` variable (`card.scryfallJson`).
@ -59,3 +60,88 @@ All attributes are listed assuming the following
|`card.watermark()`|String | The associated watermark of the card, if any. |`card.watermark()`|String | The associated watermark of the card, if any.
|`card.story_spotlight_number()`|Integer | This card's story spotlight number, if any. |`card.story_spotlight_number()`|Integer | This card's story spotlight number, if any.
|`card.story_spotlight_uri()`|String | The URI for the card's story article, if any. |`card.story_spotlight_uri()`|String | The URI for the card's story article, if any.
## *class* `cards.Named()`
Gets a card by the name.
**Parameters:**
| Param |Required [y/n]| Input type | Function |
| :---: | :---: | :---: |:---: |
|fuzzy|Yes|string|Uses the fuzzy parameter for the card name.|
|exact|Yes|string|Uses the exact parameter for the card name.|
|set|No|string|Returns the set of the card if specified. If not the card edition will be the most recent printing. Requires the 3 letter set code.
>Since the `/cards/named` endpoint specifically requires the fuzzy or exact markers, they are required to be explicitly denoted.
---
## *class* `cards.Random()`
Get a random card.
**Parameters:**
No parameters are required.
---
## *class* `cards.Multiverse()`
Get a card by Multiverse id
**Parameters:**
| Param |Required [y/n]| Input type | Function |
|:---:|:---:|:---:|:---:|
|id|Yes|Integer or String| This is the associated multiverse id of the given card.
---
## *class* `cards.Mtgo()`
Get a card by MTGO id.
**Parameters:**
| Param |Required [y/n]| Input type | Function |
|:---:|:---:|:---:|:---:|
|id|Yes|String|The required mtgo id of the card.
---
## *class* `cards.Collector()`
Get a card by collector number.
**Parameters:**
| Param |Required [y/n]| Input type | Function |
|:---:|:---:|:---:|:---:|
|code|Yes|String|This is the 3 letter code for the set|
|collector_number|Yes|String|This is the collector number of the card.|
---
## *class* `cards.Id()`
Get a card by the Scryfall id.
**Parameters:**
| Param |Required [y/n]| Input type | Function |
|:---:|:---:|:---:|:---:|
|id|Yes|String|The Scryfall Id of the card.|
---
## *class* `cards.Autocomplete()`
Get a list of potential autocompletion phrases.
**Parameters:**
| Param |Required [y/n]| Input type | Function |
|:---:|:---:|:---:|:---:|
|query|Yes|String| The query of the autocompletion.|
**Attributes:**
|Name|Output Type|Description|
|:--:|:--:|:--:|
|`object()`|String|Returns what kind of object it is.|
|`total_items()`|Integer|How many items are in the list.|
|`data()`|List|The list of potential autocompletes.|

View File

@ -1,122 +0,0 @@
# Cards Classes
## `cards.Named()`
Gets a card by the name.
**Parameters:**
| Param |Required [y/n]| Input type | Function |
| :---: | :---: | :---: |:---: |
|fuzzy|Yes|string|Uses the fuzzy parameter for the card name.|
|exact|Yes|string|Uses the exact parameter for the card name.|
|set|No|string|Returns the set of the card if specified. If not the card edition will be the most recent printing. Requires the 3 letter set code.
**Attributes:**
The same listed in the `cards` documentation.
Since the `/cards/named` endpoint specifically requires the fuzzy or exact markers, they are required to be explicitly denoted.
Example usage:
card = scrython.cards.Named(fuzzy="Blacker Lotus")
card = scrython.cards.Named(exact="Saheeli Rai")
card = scrython.cards.Named(fuzzy="Austere Command",
set="IMA")
## `cards.Random()`
Get a random card.
**Parameters:**
No parameters are required.
**Attributes:**
The same listed in the `cards` documentation.
Example usage:
card = scrython.cards.Random()
## `cards.Multiverse()`
Get a card by Multiverse id
**Parameters:**
| Param |Required [y/n]| Input type | Function |
|:---:|:---:|:---:|:---:|
|id|Yes|Integer or String| This is the associated multiverse id of the given card.
**Attributes:**
The same listed in the `cards` documentation.
Example usage:
card = scrython.cards.Multiverse(id="389511")
## `cards.Mtgo()`
Get a card by MTGO id.
**Parameters:**
| Param |Required [y/n]| Input type | Function |
|:---:|:---:|:---:|:---:|
|id|Yes|String|The required mtgo id of the card.
**Attributes:**
The same listed in the `cards` documentation.
Example usage:
card = scrython.cards.Mtgo(id="14943")
## `cards.Collector()`
Get a card by collector number.
**Parameters:**
| Param |Required [y/n]| Input type | Function |
|:---:|:---:|:---:|:---:|
|code|Yes|String|This is the 3 letter code for the set|
|collector_number|Yes|String|This is the collector number of the card.|
**Attributes:**
The same listed in the `cards` documentation.
Example usage:
card = scrython.cards.Collector(code="vma", collector_number="100")
## `cards.Id()`
Get a card by the Scryfall id.
**Attributes:**
The same listed in the `cards` documentation.
**Parameters:**
| Param |Required [y/n]| Input type | Function |
|:---:|:---:|:---:|:---:|
|id|Yes|String|The Scryfall Id of the card.|
Example usage:
card = scrython.cards.Id(id="696ca38e-3035-492f-8f1b-258f60b8788c")
## `cards.Autocomplete()`
Get a list of potential autocompletion phrases.
**Parameters:**
| Param |Required [y/n]| Input type | Function |
|:---:|:---:|:---:|:---:|
|query|Yes|String| The query of the autocompletion.|
**Attributes:**
|Name|Output Type|Description|
|:--:|:--:|:--:|
|`object()`|String|Returns what kind of object it is.|
|`total_items()`|Integer|How many items are in the list.|
|`data()`|List|The list of potential autocompletes.|
Example usage:
card = scrython.cards.Autocomplete(query="Ezuri")

View File

@ -1,5 +1,6 @@
# Cards # Catalog
Documentation for a card object. These docs will likely not be as detailed as the official Scryfall Documentation, and you should reference that for more information.
Documentation for a catalog object. 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 (`card.scryfallJson`). >In the event that a key isn't found or has been changed, you can access the full JSON output with the `scryfallJson` variable (`card.scryfallJson`).

View File

@ -24,3 +24,56 @@ Example usage:
rule = scrython.rulings.Id(id="0f91d225-788e-42fc-9d01-8668f672b717") rule = scrython.rulings.Id(id="0f91d225-788e-42fc-9d01-8668f672b717")
rule.ruling_comment(5) rule.ruling_comment(5)
>>>"If you control multiple As Foretolds, you may cast one spell for each of them paying {0}." >>>"If you control multiple As Foretolds, you may cast one spell for each of them paying {0}."
## *class* `rulings.Id()`
Gets the ruling of a card by the Scryfall Id.
**Parameters:**
| Param |Required [y/n]| Input type | Description |
| :---: | :---: | :---: |:---: |
|id|Yes|String|The id of the card you want rulings for.|
Example usage:
rule = scrython.rulings.Id(id='31412335-110c-449a-9c2f-bff8763a6504')
## *class* `rulings.Mtgo()`
Gets the ruling of a card by the Mtgo Id.
**Parameters:**
|Param|Required [y/n]|Input type|Description|
|:---:|:---:|:---:|:---:|
|id|Yes|String|The Mtgo id of the card you want rulings for.|
Example usage:
rule = scrython.rulings.Mtgo(id="24811")
## *class* `rulings.Multiverse()`
Gets the ruling of a card by the Multiverse Id.
**Parameters:**
|Param|Required [y/n]|Input type|Description|
|:---:|:---:|:---:|:---:|
|id|Yes|String|The Multiverse Id of the card you want rulings for.|
Example usage:
rule = scrython.rulings.Multiverse(id="124451")
## *class* `rulings.Code()`
Gets the ruling of a card by the set code and collector number.
**Parameters:**
|Param|Required [y/n]|Input type|Description|
|:---:|:---:|:---:|:---:|
|code|Yes|String|The 3 letter set code of the card.|
|collector_number|Yes|String|The collector number of the card.|
Example usage:
rule = scrython.rulings.Code(code='CSP', collector_number='142')

View File

@ -1,66 +0,0 @@
# Rulings Classes
## `rulings.Id()`
Gets the ruling of a card by the Scryfall Id.
**Parameters:**
| Param |Required [y/n]| Input type | Description |
| :---: | :---: | :---: |:---: |
|id|Yes|String|The id of the card you want rulings for.|
**Attributes:**
The same listed in the `rulings` documentation.
Example usage:
rule = scrython.rulings.Id(id='31412335-110c-449a-9c2f-bff8763a6504')
## `rulings.Mtgo()`
Gets the ruling of a card by the Mtgo Id.
**Parameters:**
|Param|Required [y/n]|Input type|Description|
|:---:|:---:|:---:|:---:|
|id|Yes|String|The Mtgo id of the card you want rulings for.|
**Attributes:**
The same listed in the `rulings` documentation.
Example usage:
rule = scrython.rulings.Mtgo(id="24811")
## `rulings.Multiverse()`
Gets the ruling of a card by the Multiverse Id.
**Parameters:**
|Param|Required [y/n]|Input type|Description|
|:---:|:---:|:---:|:---:|
|id|Yes|String|The Multiverse Id of the card you want rulings for.|
**Attributes:**
The same listed in the `rulings` documentation.
Example usage:
rule = scrython.rulings.Multiverse(id="124451")
## `rulings.Code()`
Gets the ruling of a card by the set code and collector number.
**Parameters:**
|Param|Required [y/n]|Input type|Description|
|:---:|:---:|:---:|:---:|
|code|Yes|String|The 3 letter set code of the card.|
|collector_number|Yes|String|The collector number of the card.|
**Attributes:**
The same listed in the `rulings` documentation.
Example usage:
rule = scrython.rulings.Code(code='CSP', collector_number='142')

59
docs/Sets.md Normal file
View File

@ -0,0 +1,59 @@
# Sets
Documentation for a sets object. 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 (`card.scryfallJson`).
## *class* `Code()`
**Attributes**
All attributes are listed assuming the following
`card = scrython.sets.<Class>()` is the current usage.
|Name|Data type returned|Description|
|:---:|:---:|:---:|
|`object()`|String|Returns the type of object it is. (card, error, etc)|
|`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()`|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.|
## *class* `Sets()`
`Sets()` gets it's own special attributes that don't match with the normal set attributes.
**Parameters**
No parameters are required.
**Attributes**
|Name|Data type returned|Description|
|:---:|:---:|:---:|
|`object()`|String|Returns the type of object it is. (card, error, etc)|
|`has_more()`|Boolean| True if there are more pages available.|
|`data()`|List| List of all data returned.|
|`data_length()`|Integer|The length of the data returned.|
|`set_object(num)`|String| The set object. Requires an integer as a parameter.|
|`set_code(num)`|String|The three letter set code of the set Requires an integer as a parameter.|
|`set_mtgo_code(num)`|String|The mtgo equivalent of `code()` Requires an integer as a parameter.|
|`set_name(num)`|String|The full name of the set. Requires an integer as a parameter.|
|`set_set_type(num)`|String|The type of the set (expansion, commander, etc) Requires an integer as a parameter.|
|`set_released_at(num)`|String|The date the set was launched. Requires an integer as a parameter.|
|`set_block_code(num)`|String|The the letter code for the block the set was in. Requires an integer as a parameter.|
|`set_block(num)`|String|The full name of the block a set was in. Requires an integer as a parameter.|
|`set_parent_set_code(num)`|String| The set code for the parent set. Requires an integer as a parameter.|
|`set_card_count(num)`|Integer| The number of cards in the set. Requires an integer as a parameter.|
|`set_digital(num)`|Boolean| True if this set is only featured on MTGO. Requires an integer as a parameter.|
|`set_foil(num)`|Boolean|True if this set only has foils. Requires an integer as a parameter.|
|`set_icon_svg_uri(num)`|String| A URI to the SVG of the set symbol. Requires an integer as a parameter.|
|`set_search_uri(num)`|String|The scryfall API url for the search. Requires an integer as a parameter.|

48
docs/Symbology.md Normal file
View File

@ -0,0 +1,48 @@
# Symbology
Documentation for a sets object. 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 (`card.scryfallJson`).
## *class* `Symbology()`
**Parameters**
There are no parameters needed to call this class.
**Attributes**
|Name|Data type returned|Description|
|:---:|:---:|:---:|
|`object()`|String|Returns the type of object it is. (card, error, etc)|
|`has_more()`|Boolean|True if there are more pages to the object.|
|`data()`|List|A list of all data returned.|
|`data_length()`|Integer|The length of the data returned.|
|`symbol_symbol(num)`|String|The plaintext symbol, usually written with curly braces. Requires an integer as a parameter, which acts as a tuple.|
|`symbol_loose_variant(num)`|String|The alternate version of the symbol, without curly braces. Requires an integer as a parameter, which acts as a tuple.|
|`symbol_transposable(num)`|Boolean|True if it's possibly to write the symbol backwards. Requires an integer as a parameter, which acts as a tuple.|
|`symbol_represents_mana(num)`|Boolean|True if this is a mana symbol. Requires an integer as a parameter, which acts as a tuple.|
|`symbol_cmc(num)`|Float|The total converted mana cost of the symbol. Requires an integer as a parameter, which acts as a tuple.|
|`symbol_appears_in_mana_costs(num)`|Boolean|True if the symbol appears on the mana cost of any card.Requires an integer as a parameter, which acts as a tuple.|
|`symbol_funny(num)`|Boolean|True if the symbol is featured on any funny cards. Requires an integer as a parameter, which acts as a tuple.|
|`symbol_colors(num)`|List|An array of all colors in the given symbol. Requires an integer as a parameter, which acts as a tuple.|
## *class* `ParseMana()`
**Parameters**
| Param |Required [y/n]| Input type | Function |
|:---:|:---:|:---:|:---:|
|`cost`|Yes|String|The given mana cost you want. (`RUG`)|
**Attributes**
|Name|Data type returned|Description|
|:---:|:---:|:---:|
|`object()`|String|Returns the type of object it is. (card, error, etc)|
|`mana_cost()`|String|The formatted mana cost.|
|`cmc()`|Float|The converted mana cost of the card.|
|`colors()`|List|A list of all colors in the mana cost.|
|`colorless()`|Boolean|True if the mana cost is colorless.|
|`monocolored()`|Boolean|True if the mana cost is mono colored.|
|`multicolored()`|Boolean|True if the mana cost is a multicolored cost.|

View File

@ -3,7 +3,7 @@ import urllib.parse
class Autocomplete(CardsObject): class Autocomplete(CardsObject):
def __init__(self, **kwargs): def __init__(self, **kwargs):
if kwargs.get('q') is None: if kwargs.get('query') is None:
raise TypeError('No query provided to search by') raise TypeError('No query provided to search by')
self.dict = { self.dict = {

View File

@ -53,24 +53,3 @@ class ParseMana(SymbologyObject):
raise KeyError('This object has no key \'multicolored\'') raise KeyError('This object has no key \'multicolored\'')
return self.scryfallJson['multicolored'] return self.scryfallJson['multicolored']
#The following attributes are only to override the inherited class attributes.
#This class has no matching attributes but we still need the getRequest from SymbologyObject
def appears_in_mana_costs(self):
raise AttributeError('This object has no attribute \'appears_in_mana_costs\'')
def funny(self):
raise AttributeError('This object has no attribute \'funny\'')
def loose_variant(self):
raise AttributeError('This object has no attribute \'loose_variant\'')
def represents_mana(self):
raise AttributeError('This object has no attribute \'represents_mana\'')
def symbol(self):
raise AttributeError('This object has no attribute \'symbol\'')
def transposable(self):
raise AttributeError('This object has no attribute \'transposable\'')

View File

@ -88,30 +88,3 @@ class Symbology(SymbologyObject):
raise KeyError('This object has no key \'colors\'') raise KeyError('This object has no key \'colors\'')
return self.scryfallJson['data'][num]['colors'] return self.scryfallJson['data'][num]['colors']
#The following attributes are only to override the inherited class attributes.
#This class has no matching attributes but we still need the getRequest from SymbologyObject
def symbol(self):
raise AttributeError('This object has no key \'symbol\'')
def loose_variant(self):
raise AttributeError('This object has no key \'loose_variant\'')
def transposable(self):
raise AttributeError('This object has no key \'transposable\'')
def represents_mana(self):
raise AttributeError('This object has no key \'represents_mana\'')
def cmc(self):
raise AttributeError('This object has no key \'cmc\'')
def appears_in_mana_costs(self):
raise AttributeError('This object has no key \'appears_in_mana_costs\'')
def funny(self):
raise AttributeError('This object has no key \'funny\'')
def colors(self):
raise AttributeError('This object has no key \'colors\'')

View File

@ -22,63 +22,3 @@ class SymbologyObject(object):
if self.scryfallJson['object'] == 'error': if self.scryfallJson['object'] == 'error':
raise Exception(self.scryfallJson['details']) raise Exception(self.scryfallJson['details'])
def __checkForKey(self, key):
try:
return self.scryfallJson[key]
except KeyError:
return None
def object(self):
if self.__checkForKey('object') is None:
raise KeyError('This object has no key \'object\'')
return self.scryfallJson['object']
def symbol(self):
if self.__checkForKey('symbol') is None:
raise KeyError('This object has no key \'symbol\'')
return self.scryfallJson['symbol']
def loose_variant(self):
if self.__checkForKey('loose_variant') is None:
raise KeyError('This object has no key \'loose_variant\'')
return self.scryfallJson['loose_variant']
def transposable(self):
if self.__checkForKey('transposable') is None:
raise KeyError('This object has no key \'transposable\'')
return self.scryfallJson['transposable']
def represents_mana(self):
if self.__checkForKey('represents_mana') is None:
raise KeyError('This object has no key \'represents_mana\'')
return self.scryfallJson['represents_mana']
def cmc(self):
if self.__checkForKey('cmc') is None:
raise KeyError('This object has no key \'cmc\'')
return self.scryfallJson['cmc']
def appears_in_mana_costs(self):
if self.__checkForKey('appears_in_mana_costs') is None:
raise KeyError('This object has no key \'appears_in_mana_costs\'')
return self.scryfallJson['appears_in_mana_costs']
def funny(self):
if self.__checkForKey('funny') is None:
raise KeyError('This object has no key \'funny\'')
return self.scryfallJson['funny']
def colors(self):
if self.__checkForKey('colors') is None:
raise KeyError('This object has no key \'colors\'')
return self.scryfallJson['colors']