def db(request): if request.param == 'url': return CardDb.from_url() elif request.param == 'file': return CardDb.from_file(download_set_file(ALL_SETS_URL, 'AllSets.json')) elif request.param == 'file-x': return CardDb.from_file( download_set_file(ALL_SETS_X_URL, 'AllSets-x.json'))
def db(request): if request.param == 'url': return CardDb.from_url() elif request.param == 'file': return CardDb.from_file( download_set_file(ALL_SETS_URL, 'AllSets.json') ) elif request.param == 'file-x': return CardDb.from_file( download_set_file(ALL_SETS_X_URL, 'AllSets-x.json') )
# to be used with the tabletop simulator deck creator # requires mtgjson, beautifulsoup4, requests from mtgjson import CardDb from bs4 import BeautifulSoup import Tkinter, tkFileDialog, tkMessageBox, os, urllib, urllib2, re if not os.path.isdir('Decks'): os.mkdir('Decks') if os.path.isfile('AllSets.json'): print "Using cached JSON file..." db = CardDb.from_file('AllSets.json') else: print "Downloading JSON Card DB..." db = CardDb.from_url("http://mtgjson.com/json/AllSets.json") root = Tkinter.Tk() root.withdraw() tkMessageBox.showinfo(title="HEY", message="Point me to your txt file for the deck you made on TappedOut.") path_to_file = tkFileDialog.askopenfilename(filetypes=[("Text files","*.txt")]) deck_name = raw_input("Deck name: ") isSideboard = False if not os.path.isdir('Decks/'+deck_name): os.mkdir('Decks/'+deck_name) def alternateGetImage(card): page = BeautifulSoup(urllib2.urlopen('http://magiccards.info/query?q=!'+card[1].replace(' ', '+')+'&v=card&s=cname').read()) return page.find("img", src=re.compile(".info/scans/en"))["src"] def urlRetrieveWithException(card, sideboard): try: