Merge branch 'develop' of github.com:NandaScott/Scrython into nanda/cards_search
This commit is contained in:
commit
bd74b96e4a
|
@ -1,24 +1,10 @@
|
||||||
import asyncio, aiohttp
|
import asyncio, aiohttp
|
||||||
|
|
||||||
class Autocomplete(object):
|
class Autocomplete(object):
|
||||||
""" cards/autocomplete
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
query: str The string to autocomplete.
|
|
||||||
format: str The data format to return. Currently only supports JSON.
|
|
||||||
pretty: bool If true, the returned JSON will be prettified. Avoid using for production code.
|
|
||||||
|
|
||||||
Attributes:
|
|
||||||
object: str Returns the type of object it is.
|
|
||||||
total_items: int Returns the number of items in data.
|
|
||||||
data: arr The full autocompleted list.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, query, **kwargs):
|
def __init__(self, query, **kwargs):
|
||||||
self.query = query
|
self.query = query
|
||||||
self.pretty = kwargs.get('pretty')
|
self.pretty = kwargs.get('pretty', 'None')
|
||||||
self.format = kwargs.get('format')
|
self.format = kwargs.get('format', 'None')
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
self.session = aiohttp.ClientSession(loop=loop)
|
self.session = aiohttp.ClientSession(loop=loop)
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
from .scryfall_object import ScryfallObject
|
from .cards_object import CardsObject
|
||||||
|
|
||||||
class Id(ScryfallObject):
|
|
||||||
""" cards/:id
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
id: str The Scryfall id of the card.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
class Id(CardsObject):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.id = kwargs.get('id')
|
self.id = kwargs.get('id')
|
||||||
self.url = 'cards/' + str(self.id)
|
self.url = 'cards/' + str(self.id)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
class ScryfallObject(object):
|
class CardsObject(object):
|
||||||
def __init__(self, _url, **kwargs):
|
def __init__(self, _url, **kwargs):
|
||||||
self._url = 'https://api.scryfall.com/' + _url
|
self._url = 'https://api.scryfall.com/' + _url
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
|
@ -14,10 +14,10 @@ class ScryfallObject(object):
|
||||||
self.scryfallJson = loop.run_until_complete(getRequest(
|
self.scryfallJson = loop.run_until_complete(getRequest(
|
||||||
url = self._url,
|
url = self._url,
|
||||||
params={
|
params={
|
||||||
'format': kwargs.get('format'),
|
'format': kwargs.get('format', 'None'),
|
||||||
'face': kwargs.get('face'),
|
'face': kwargs.get('face', 'None'),
|
||||||
'version': kwargs.get('version'),
|
'version': kwargs.get('version', 'None'),
|
||||||
'pretty': kwargs.get('pretty')
|
'pretty': kwargs.get('pretty', 'None')
|
||||||
}))
|
}))
|
||||||
|
|
||||||
if self.scryfallJson['object'] == 'error':
|
if self.scryfallJson['object'] == 'error':
|
|
@ -1,13 +1,6 @@
|
||||||
from .scryfall_object import ScryfallObject
|
from .cards_object import CardsObject
|
||||||
|
|
||||||
class Collector(ScryfallObject):
|
|
||||||
""" cards/:code/:collector_number
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
code: str The 3 or 4 letter set code.
|
|
||||||
collector_number: int The collector number of the card.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
class Collector(CardsObject):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.code = kwargs.get('code')
|
self.code = kwargs.get('code')
|
||||||
self.collector_number = kwargs.get('collector_number')
|
self.collector_number = kwargs.get('collector_number')
|
||||||
|
|
|
@ -1,14 +1,7 @@
|
||||||
from .scryfall_object import ScryfallObject
|
from .cards_object import CardsObject
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
class Mtgo(ScryfallObject):
|
class Mtgo(CardsObject):
|
||||||
""" cards/mtgo/:id
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
id: int The mtgo id of the card.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.mtgoid = kwargs.get('id')
|
self.mtgoid = kwargs.get('id')
|
||||||
self.url = 'cards/mtgo/' + str(self.mtgoid)
|
self.url = 'cards/mtgo/' + str(self.mtgoid)
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
from .scryfall_object import ScryfallObject
|
from .cards_object import CardsObject
|
||||||
|
|
||||||
class Multiverse(ScryfallObject):
|
|
||||||
"""
|
|
||||||
Parameters:
|
|
||||||
id: int The multiverse id of the card.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
class Multiverse(CardsObject):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.multiverseid = kwargs.get('id')
|
self.multiverseid = kwargs.get('id')
|
||||||
self.url = 'cards/multiverse/' + self.multiverseid
|
self.url = 'cards/multiverse/' + self.multiverseid
|
||||||
|
|
|
@ -1,18 +1,11 @@
|
||||||
from .scryfall_object import ScryfallObject
|
from .cards_object import CardsObject
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
class Named(ScryfallObject):
|
class Named(CardsObject):
|
||||||
"""
|
|
||||||
Parameters:
|
|
||||||
exact: str The exact card name to search for, case insenstive.
|
|
||||||
fuzzy: str A fuzzy card name to search for.
|
|
||||||
set: str A set code to limit the search to one set.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.exact = kwargs.get('exact')
|
self.exact = kwargs.get('exact')
|
||||||
self.fuzzy = kwargs.get('fuzzy')
|
self.fuzzy = kwargs.get('fuzzy')
|
||||||
self.set = kwargs.get('set')
|
self.set = kwargs.get('set', 'None')
|
||||||
self.dict = {}
|
self.dict = {}
|
||||||
|
|
||||||
if self.exact is not None:
|
if self.exact is not None:
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
from .scryfall_object import ScryfallObject
|
from .cards_object import CardsObject
|
||||||
|
|
||||||
|
|
||||||
class Random(ScryfallObject):
|
class Random(CardsObject):
|
||||||
"""This will return a random card. No parameters are passed while creating."""
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.url = 'cards/random'
|
self.url = 'cards/random'
|
||||||
super(Random, self).__init__(self.url)
|
super(Random, self).__init__(self.url)
|
||||||
|
|
|
@ -3,8 +3,8 @@ import aiohttp
|
||||||
|
|
||||||
class RulingsObject(object):
|
class RulingsObject(object):
|
||||||
def __init__(self, _url, **kwargs):
|
def __init__(self, _url, **kwargs):
|
||||||
self.pretty = kwargs.get('pretty')
|
self.pretty = kwargs.get('pretty', 'None')
|
||||||
self.format = kwargs.get('format')
|
self.format = kwargs.get('format', 'None')
|
||||||
self._url = 'https://api.scryfall.com/' + _url
|
self._url = 'https://api.scryfall.com/' + _url
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
self.session = aiohttp.ClientSession(loop=loop)
|
self.session = aiohttp.ClientSession(loop=loop)
|
||||||
|
|
Loading…
Reference in New Issue