Fix executable permissions. reprintSetInfo now takes a parameter for the set instead of it being hardcoded

This commit is contained in:
jendave
2011-08-07 01:56:01 +00:00
parent 41c299909e
commit ab8e166520
5 changed files with 504 additions and 499 deletions

6
.gitattributes vendored
View File

@@ -20,7 +20,7 @@ build/support/template.applescript -text
/forge.properties svneol=native#text/plain /forge.properties svneol=native#text/plain
/pom.xml svneol=native#text/xml /pom.xml svneol=native#text/xml
res/AllTokens.txt -text svneol=native#text/plain res/AllTokens.txt -text svneol=native#text/plain
res/PerSetTracking.py -text svneol=native#text/x-python res/PerSetTracking.py svneol=native#text/x-python
res/blockdata/blocks.txt svneol=native#text/plain res/blockdata/blocks.txt svneol=native#text/plain
res/blockdata/setdata.txt svneol=native#text/plain res/blockdata/setdata.txt svneol=native#text/plain
res/booster-decks -text svneol=unset#unset res/booster-decks -text svneol=unset#unset
@@ -8919,8 +8919,8 @@ res/quest/themes/White.thm -text
res/quest/themes/Wolves[!!-~]WG.thm -text res/quest/themes/Wolves[!!-~]WG.thm -text
res/quest/themes/Zombies[!!-~]B.thm -text res/quest/themes/Zombies[!!-~]B.thm -text
res/quest/veryhard.txt -text svneol=native#text/plain res/quest/veryhard.txt -text svneol=native#text/plain
res/reprintSetInfo.py -text svneol=native#text/x-python res/reprintSetInfo.py svneol=native#text/x-python
res/setInfoScript.py -text svneol=native#text/x-python res/setInfoScript.py svneol=native#text/x-python
res/sound/tap.mp3 -text svneol=unset#audio/mpeg res/sound/tap.mp3 -text svneol=unset#audio/mpeg
src/arcane/ui/CardArea.java svneol=native#text/plain src/arcane/ui/CardArea.java svneol=native#text/plain
src/arcane/ui/CardPanel.java svneol=native#text/plain src/arcane/ui/CardPanel.java svneol=native#text/plain

8
res/PerSetTracking.py Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
pathToMtgData = "mtg-data.txt" pathToMtgData = "mtg-data.txt"
############IMPLEMENTATION FOLLOWS############ ############IMPLEMENTATION FOLLOWS############
@@ -60,7 +62,6 @@ for file in forgeFolderFiles :
tmpname = tmpname.rstrip() tmpname = tmpname.rstrip()
forgeCards.append(tmpname) forgeCards.append(tmpname)
#Compare datasets and output results #Compare datasets and output results
print("Comparing datasets and outputting results.") print("Comparing datasets and outputting results.")
totalData = {} totalData = {}
@@ -89,9 +90,8 @@ for currentSet in setCodes :
percentage = 0 percentage = 0
if total > 0 : if total > 0 :
percentage = (float(len(currentImplemented))/float(total))*100 percentage = (float(len(currentImplemented))/float(total))*100
currentMissing.sort()
currentMissing.sort() currentImplemented.sort()
currentImplemented.sort()
with open(sys.path[0] + os.sep + "PerSetTracking Results" + os.sep + "set_" + currentSet + ".txt", "w") as output : with open(sys.path[0] + os.sep + "PerSetTracking Results" + os.sep + "set_" + currentSet + ".txt", "w") as output :
output.write("Implemented (" + str(len(currentImplemented)) + "):\n") output.write("Implemented (" + str(len(currentImplemented)) + "):\n")

0
res/mtg-data.txt Executable file → Normal file
View File

119
res/reprintSetInfo.py Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
# This script grabs the list of all cards in a set and clears out the setInfo # This script grabs the list of all cards in a set and clears out the setInfo
# After running this script, re-run setInfoScript to fill in the slots # After running this script, re-run setInfoScript to fill in the slots
# MAKE SURE THE setAbbr VARIABLE IS UPDATED TO THE SET YOU WANT TO CLEAR OUT # MAKE SURE THE setAbbr VARIABLE IS UPDATED TO THE SET YOU WANT TO CLEAR OUT
@@ -5,54 +7,56 @@
from httplib import HTTP from httplib import HTTP
from urlparse import urlparse from urlparse import urlparse
from urllib import urlopen from urllib import urlopen
import sys
import os import os
class SetInfo: class SetInfo:
def __init__(self, set, rarity, image): def __init__(self, set, rarity, image):
self.set = set self.set = set
self.rarity = rarity self.rarity = rarity
self.image = image self.image = image
class Card: class Card:
def __init__(self, name, cleanName): def __init__(self, name, cleanName):
self.name = name self.name = name
self.cleanName = cleanName self.cleanName = cleanName
self.hasSet = False self.hasSet = False
self.sets = {} self.sets = {}
def clean(name): def clean(name):
return name.replace(' ','_').replace('\'','').replace('-','_').replace('"','').replace(',','').lower() return name.replace(' ','_').replace('\'','').replace('-','_').replace('"','').replace(',','').lower()
def getCardsInSet(): def getCardsInSet():
html = urlopen('http://magiccards.info/query?q=e:'+setAbbr+'&v=olist').read() html = urlopen('http://magiccards.info/query?q=e:'+setAbbr+'&v=olist').read()
start = html.find('<th><b>Card name</b></th>') start = html.find('<th><b>Card name</b></th>')
end = html.find('</table>', start) end = html.find('</table>', start)
block = html[start:end] block = html[start:end]
while True: while True:
nameIndex = block.find('.html">') nameIndex = block.find('.html">')
if nameIndex == -1: if nameIndex == -1:
break break
nameEnd = block.find('<',nameIndex) nameEnd = block.find('<',nameIndex)
name = block[nameIndex+7:nameEnd] name = block[nameIndex+7:nameEnd]
# Add name to array # Add name to array
nameList.append(clean(name)+'.txt') nameList.append(clean(name)+'.txt')
block = block[nameEnd:] block = block[nameEnd:]
return return
folder = "cardsfolder" folder = "cardsfolder"
err = open('reprintSetInfo.log','w') err = open('reprintSetInfo.log','w')
# THIS NEEDS TO BE UPDATED TO THE SET YOU WANT TO UPDATE # THIS NEEDS TO BE UPDATED TO THE SET YOU WANT TO UPDATE
# SOME ARE THREE LETTER ABBR. BUT SOME ARE JUST TWO. CHECK BEFORE YOU RUN! # SOME ARE THREE LETTER ABBR. BUT SOME ARE JUST TWO. CHECK BEFORE YOU RUN!
setAbbr = 'mbs' print "Using Set: " + sys.argv[1]
setAbbr = sys.argv[1]
cardDict = {} cardDict = {}
setStr = 'SetInfo:' setStr = 'SetInfo:'
@@ -60,49 +64,48 @@ nameList = []
getCardsInSet() getCardsInSet()
for fileName in nameList: for fileName in nameList:
# if file doesn't exist continue # if file doesn't exist continue
filePath = os.path.join(folder, fileName) filePath = os.path.join(folder, fileName)
print filePath
print filePath if os.path.isfile(filePath) == False:
continue
if os.path.isfile(filePath) == False: file = open(filePath)
continue cleanName = fileName.replace('.txt', '')
file = open(filePath) line = file.readline().strip()
cleanName = fileName.replace('.txt', '') # Handle name and creation
name = line.replace('Name:','')
line = file.readline().strip() card = Card(name, cleanName)
# Handle name and creation cardDict[cleanName] = card
name = line.replace('Name:','') card.lines = line + '\n'
card = Card(name, cleanName) # Start parsing the rest of the data file
cardDict[cleanName] = card line = file.readline().strip()
card.lines = line + '\n'
# Start parsing the rest of the data file while line != 'End':
line = file.readline().strip() # Skip empty lines
if line == '':
line = file.readline().strip()
continue
while line != 'End': # We really shouldn
# Skip empty lines if line == 'End':
if line == '': break
line = file.readline().strip()
continue
# We really shouldn # Skip SetInfo lines
if line == 'End': if line.find(setStr) == -1:
break card.lines += line +'\n'
# Skip SetInfo lines line = file.readline().strip()
if line.find(setStr) == -1:
card.lines += line +'\n'
line = file.readline().strip() file = open(os.path.join(folder, fileName), 'w')
file.write(card.lines)
file = open(os.path.join(folder, fileName), 'w') file.write('End')
file.write(card.lines) file.close()
err.write(card.name + '... Updated\n')
file.write('End')
file.close()
err.write(card.name + '... Updated\n')
err.close() err.close()

366
res/setInfoScript.py Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
# This python script is designed to handle the following: individual cards located in /res/cardsfolder # This python script is designed to handle the following: individual cards located in /res/cardsfolder
# Insert of SetInfo data into data files from magiccards.info # Insert of SetInfo data into data files from magiccards.info
@@ -7,189 +9,189 @@ from urllib import urlopen
import os import os
def getURL(url): def getURL(url):
return urlopen(url).read() return urlopen(url).read()
class SetInfo: class SetInfo:
def __init__(self, set, rarity, image): def __init__(self, set, rarity, image):
self.set = set self.set = set
self.rarity = rarity self.rarity = rarity
self.image = image self.image = image
class Card: class Card:
def __init__(self, name, cleanName): def __init__(self, name, cleanName):
self.name = name self.name = name
self.cleanName = cleanName self.cleanName = cleanName
self.hasSet = False self.hasSet = False
self.sets = {} self.sets = {}
def initSets(): def initSets():
# Base Sets # Base Sets
allSets['Limited Edition Alpha'] = 'LEA' allSets['Limited Edition Alpha'] = 'LEA'
allSets['Limited Edition Beta'] = 'LEB' allSets['Limited Edition Beta'] = 'LEB'
allSets['Unlimited Edition'] = '2ED' allSets['Unlimited Edition'] = '2ED'
allSets['Revised Edition'] = '3ED' allSets['Revised Edition'] = '3ED'
allSets['Fourth Edition'] = '4ED' allSets['Fourth Edition'] = '4ED'
allSets['Fifth Edition'] = '5ED' allSets['Fifth Edition'] = '5ED'
allSets['Classic Sixth Edition'] = '6ED' allSets['Classic Sixth Edition'] = '6ED'
allSets['Seventh Edition'] = '7ED' allSets['Seventh Edition'] = '7ED'
allSets['Eighth Edition'] = '8ED' allSets['Eighth Edition'] = '8ED'
allSets['Ninth Edition'] = '9ED' allSets['Ninth Edition'] = '9ED'
allSets['Tenth Edition'] = '10E' allSets['Tenth Edition'] = '10E'
allSets['Magic 2010'] = 'M10' allSets['Magic 2010'] = 'M10'
allSets['Magic 2011'] = 'M11' allSets['Magic 2011'] = 'M11'
#allSets['Magic 2012'] = 'M12' #allSets['Magic 2012'] = 'M12'
# Portal # Portal
allSets['Portal'] = 'POR' allSets['Portal'] = 'POR'
allSets['Portal Second Age'] = 'PO2' allSets['Portal Second Age'] = 'PO2'
allSets['Portal Three Kingdoms'] = 'PTK' allSets['Portal Three Kingdoms'] = 'PTK'
# Starter # Starter
allSets['Starter 1999'] = 'S99' allSets['Starter 1999'] = 'S99'
allSets['Starter 2000'] = 'S00' allSets['Starter 2000'] = 'S00'
# Early Sets # Early Sets
allSets['Arabian Nights'] = 'ARN' allSets['Arabian Nights'] = 'ARN'
allSets['Antiquities'] = 'ATQ' allSets['Antiquities'] = 'ATQ'
allSets['Legends'] = 'LEG' allSets['Legends'] = 'LEG'
allSets['The Dark'] = 'DRK' allSets['The Dark'] = 'DRK'
allSets['Fallen Empires'] = 'FEM' allSets['Fallen Empires'] = 'FEM'
allSets['Homelands'] = 'HML' allSets['Homelands'] = 'HML'
# Ice Age # Ice Age
allSets['Ice Age'] = 'ICE' allSets['Ice Age'] = 'ICE'
allSets['Alliances'] = 'ALL' allSets['Alliances'] = 'ALL'
allSets['Coldsnap'] = 'CSP' allSets['Coldsnap'] = 'CSP'
# Mirage # Mirage
allSets['Mirage'] = 'MIR' allSets['Mirage'] = 'MIR'
allSets['Visions'] = 'VIS' allSets['Visions'] = 'VIS'
allSets['Weatherlight'] = 'WTH' allSets['Weatherlight'] = 'WTH'
# Rath Cycle # Rath Cycle
allSets['Tempest'] = 'TMP' allSets['Tempest'] = 'TMP'
allSets['Stronghold'] = 'STH' allSets['Stronghold'] = 'STH'
allSets['Exodus'] = 'EXO' allSets['Exodus'] = 'EXO'
# Artifacts Cycle # Artifacts Cycle
allSets['Urza\'s Saga'] = 'USG' allSets['Urza\'s Saga'] = 'USG'
allSets['Urza\'s Legacy'] = 'ULG' allSets['Urza\'s Legacy'] = 'ULG'
allSets['Urza\'s Destiny'] = 'UDS' allSets['Urza\'s Destiny'] = 'UDS'
# Masques # Masques
allSets['Mercadian Masques'] = 'MMQ' allSets['Mercadian Masques'] = 'MMQ'
allSets['Nemesis'] = 'NMS' allSets['Nemesis'] = 'NMS'
allSets['Prophecy'] = 'PCY' allSets['Prophecy'] = 'PCY'
# Invasion # Invasion
allSets['Invasion'] = 'INV' allSets['Invasion'] = 'INV'
allSets['Planeshift'] = 'PLS' allSets['Planeshift'] = 'PLS'
allSets['Apocalypse'] = 'APC' allSets['Apocalypse'] = 'APC'
# Odyssey # Odyssey
allSets['Odyssey'] = 'ODY' allSets['Odyssey'] = 'ODY'
allSets['Torment'] = 'TOR' allSets['Torment'] = 'TOR'
allSets['Judgment'] = 'JUD' allSets['Judgment'] = 'JUD'
# Onslaught # Onslaught
allSets['Onslaught'] = 'ONS' allSets['Onslaught'] = 'ONS'
allSets['Legions'] = 'LGN' allSets['Legions'] = 'LGN'
allSets['Scourge'] = 'SCG' allSets['Scourge'] = 'SCG'
# Mirrodin # Mirrodin
allSets['Mirrodin'] = 'MRD' allSets['Mirrodin'] = 'MRD'
allSets['Darksteel'] = 'DST' allSets['Darksteel'] = 'DST'
allSets['Fifth Dawn'] = '5DN' allSets['Fifth Dawn'] = '5DN'
# Kamigawa # Kamigawa
allSets['Champions of Kamigawa'] = 'CHK' allSets['Champions of Kamigawa'] = 'CHK'
allSets['Betrayers of Kamigawa'] = 'BOK' allSets['Betrayers of Kamigawa'] = 'BOK'
allSets['Saviors of Kamigawa'] = 'SOK' allSets['Saviors of Kamigawa'] = 'SOK'
# Ravnica # Ravnica
allSets['Ravnica: City of Guilds'] = 'RAV' allSets['Ravnica: City of Guilds'] = 'RAV'
allSets['Guildpact'] = 'GPT' allSets['Guildpact'] = 'GPT'
allSets['Dissension'] = 'DIS' allSets['Dissension'] = 'DIS'
# Time Spiral # Time Spiral
allSets['Time Spiral'] = 'TSP' allSets['Time Spiral'] = 'TSP'
allSets['Time Spiral "Timeshifted"'] = 'TSB' allSets['Time Spiral "Timeshifted"'] = 'TSB'
allSets['Planar Chaos'] = 'PLC' allSets['Planar Chaos'] = 'PLC'
allSets['Future Sight'] = 'FUT' allSets['Future Sight'] = 'FUT'
# Lorwyn # Lorwyn
allSets['Lorwyn'] = 'LRW' allSets['Lorwyn'] = 'LRW'
allSets['Morningtide'] = 'MOR' allSets['Morningtide'] = 'MOR'
# Shadowmoor # Shadowmoor
allSets['Shadowmoor'] = 'SHM' allSets['Shadowmoor'] = 'SHM'
allSets['Eventide'] = 'EVE' allSets['Eventide'] = 'EVE'
# Alara # Alara
allSets['Shards of Alara'] = 'ALA' allSets['Shards of Alara'] = 'ALA'
allSets['Conflux'] = 'CFX' allSets['Conflux'] = 'CFX'
allSets['Alara Reborn'] = 'ARB' allSets['Alara Reborn'] = 'ARB'
# Zendikar # Zendikar
allSets['Zendikar'] = 'ZEN' allSets['Zendikar'] = 'ZEN'
allSets['Worldwake'] = 'WWK' allSets['Worldwake'] = 'WWK'
allSets['Rise of the Eldrazi'] = 'ROE' allSets['Rise of the Eldrazi'] = 'ROE'
# Scars of Mirrodin # Scars of Mirrodin
allSets['Scars of Mirrodin'] = 'SOM' allSets['Scars of Mirrodin'] = 'SOM'
allSets['Mirrodin Besieged'] = 'MBS' allSets['Mirrodin Besieged'] = 'MBS'
allSets['New Phyrexia'] = 'NPH' allSets['New Phyrexia'] = 'NPH'
def addSets(card): def addSets(card):
html = getURL('http://magiccards.info/query?q=!'+card.name) html = getURL('http://magiccards.info/query?q=!'+card.name)
start = html.find('<br><u><b>Editions:</b></u><br>') start = html.find('<br><u><b>Editions:</b></u><br>')
end = html.find('<br><u><b>Languages:</b></u><br>', start) end = html.find('<br><u><b>Languages:</b></u><br>', start)
block = html[start:end] block = html[start:end]
print card.name print card.name
for edition in allSets.keys(): for edition in allSets.keys():
edIndex = block.find('>'+edition+'<') # Portal/Mirrodin issue edIndex = block.find('>'+edition+'<') # Portal/Mirrodin issue
if edIndex == -1: if edIndex == -1:
edIndex = block.find('>'+edition+' (') # Single set issue edIndex = block.find('>'+edition+' (') # Single set issue
if edIndex == -1: if edIndex == -1:
continue continue
# Scrape rarity # Scrape rarity
rarityIndex = block.find('(',edIndex) rarityIndex = block.find('(',edIndex)
rarity = block[rarityIndex+1:block.find(')',rarityIndex)] rarity = block[rarityIndex+1:block.find(')',rarityIndex)]
raritySpace = rarity.find(' ') raritySpace = rarity.find(' ')
if raritySpace != -1: if raritySpace != -1:
rarity = rarity[0:raritySpace] # For older cards rarity = rarity[0:raritySpace] # For older cards
# What to do with TimeShifted cards? # What to do with TimeShifted cards?
if rarity == 'Special' and edition != 'Time Spiral "Timeshifted"': if rarity == 'Special' and edition != 'Time Spiral "Timeshifted"':
continue continue
# Get setAbbreviation and setNumber # Get setAbbreviation and setNumber
dataIndex = block.rfind('"/',0,edIndex) dataIndex = block.rfind('"/',0,edIndex)
data = block[dataIndex+2:edIndex-1] # 1 instead of 2 because of Portal/Mirrodin Issue data = block[dataIndex+2:edIndex-1] # 1 instead of 2 because of Portal/Mirrodin Issue
splitData = data.split('/') splitData = data.split('/')
setAbbr = splitData[0] setAbbr = splitData[0]
setNum = splitData[2].replace('.html', '') setNum = splitData[2].replace('.html', '')
if len(setNum) > 4: if len(setNum) > 4:
# Setnum not available here for most recent set. Switch to the .jpg used on page # Setnum not available here for most recent set. Switch to the .jpg used on page
jpgIndex = html.find('.jpg') jpgIndex = html.find('.jpg')
data = html[html.rfind('scans/en/', 0, jpgIndex):jpgIndex] data = html[html.rfind('scans/en/', 0, jpgIndex):jpgIndex]
# data = scans/en/[set]/[num] # data = scans/en/[set]/[num]
splitData = data.split('/') splitData = data.split('/')
setAbbr = splitData[2] setAbbr = splitData[2]
setNum = splitData[3] setNum = splitData[3]
image = 'http://magiccards.info/scans/en/' + setAbbr + '/' + setNum + '.jpg' image = 'http://magiccards.info/scans/en/' + setAbbr + '/' + setNum + '.jpg'
card.sets[allSets[edition]] = SetInfo(allSets[edition], rarity, image) card.sets[allSets[edition]] = SetInfo(allSets[edition], rarity, image)
return return
#get master card list and drop into a dictionary #get master card list and drop into a dictionary
@@ -201,57 +203,57 @@ cardDict = {}
setStr = 'SetInfo:' setStr = 'SetInfo:'
for fileName in os.listdir(folder): for fileName in os.listdir(folder):
if fileName.startswith('.'): if fileName.startswith('.'):
continue continue
# parse cardsfolder for Card Lines and Rarity/Picture SVars. Filling in any gaps # parse cardsfolder for Card Lines and Rarity/Picture SVars. Filling in any gaps
file = open(folder + os.sep + fileName) file = open(folder + os.sep + fileName)
cleanName = fileName.replace('.txt', '') cleanName = fileName.replace('.txt', '')
line = file.readline().strip() line = file.readline().strip()
# Handle name and creation # Handle name and creation
name = line.replace('Name:','') name = line.replace('Name:','')
card = Card(name.replace(' ','+'), cleanName) #This makes it work on Mac OS X. Will test Windows and FreeBSD when I can. card = Card(name.replace(' ','+'), cleanName) #This makes it work on Mac OS X. Will test Windows and FreeBSD when I can.
cardDict[cleanName] = card cardDict[cleanName] = card
card.lines = line + '\n' card.lines = line + '\n'
# Start parsing the rest of the data file # Start parsing the rest of the data file
line = file.readline().strip() line = file.readline().strip()
while line != 'End': while line != 'End':
# Skip empty lines # Skip empty lines
if line == '': if line == '':
line = file.readline().strip() line = file.readline().strip()
continue continue
# We really shouldn't # We really shouldn't
if line == 'End': if line == 'End':
break break
if line.find(setStr) != -1: if line.find(setStr) != -1:
info = line.replace('SetInfo:','') info = line.replace('SetInfo:','')
parts = info.split('|') parts = info.split('|')
card.hasSet = True card.hasSet = True
card.sets[parts[0]] = SetInfo(parts[0], parts[1], parts[2]) card.sets[parts[0]] = SetInfo(parts[0], parts[1], parts[2])
else: else:
card.lines += line +'\n' card.lines += line +'\n'
line = file.readline().strip() line = file.readline().strip()
if not card.hasSet: if not card.hasSet:
addSets(card) addSets(card)
card.hasSet = True card.hasSet = True
file = open(folder + os.sep + fileName, 'w') file = open(folder + os.sep + fileName, 'w')
file.write(card.lines) file.write(card.lines)
if card.hasSet: if card.hasSet:
for s in card.sets.values(): for s in card.sets.values():
file.write('SetInfo:'+ s.set + '|' + s.rarity + '|' + s.image + '\n') file.write('SetInfo:'+ s.set + '|' + s.rarity + '|' + s.image + '\n')
file.write('End') file.write('End')
file.close() file.close()
err.write(card.name + '... Updated\n') err.write(card.name + '... Updated\n')
err.close() err.close()