Simple fix for EditionTracking with new format style

This commit is contained in:
Chris H
2018-04-20 21:10:21 -04:00
parent 13b058ed1b
commit 2196551126

View File

@@ -110,30 +110,40 @@ def initializeForgeCards():
def initializeFormats(): def initializeFormats():
formats = {} formats = {}
formatLocation = os.path.join(resDir, 'blockdata', 'formats.txt') formatLocation = os.path.join(resDir, 'formats')
print "Looking for formats in ", formatLocation print "Looking for formats in ", formatLocation
with open(formatLocation) as formatFile: for root, dirnames, filenames in os.walk(formatLocation):
while formatFile: for fileName in fnmatch.filter(filenames, '*.txt'):
try: if fileName not in ['standard.txt', 'Modern.txt']:
line = formatFile.readline().strip() continue
if not line:
# this should only happen when the file is done processing if we did things correctly?
break
format = line[1:-1] with open(os.path.join(root, fileName)) as formatFile:
formats[format] = {} while formatFile:
except: try:
break line = formatFile.readline().strip()
if not line:
# this should only happen when the file is done processing if we did things correctly?
break
if line == '[format]':
line = formatFile.readline().strip()
# Pull valid sets if line.startswith('Name:'):
while line != '': format = line.split(':')[1]
line = formatFile.readline().strip() formats[format] = {}
if line.startswith('Sets:'): else:
sets = line.split(':')[1] break
formats[format]['sets'] = sets.split(', ') except:
elif line.startswith('Banned'): break
banned = line.split(':')[1]
formats[format]['banned'] = banned.split('; ') # Pull valid sets
while line != '':
line = formatFile.readline().strip()
if line.startswith('Sets:'):
sets = line.split(':')[1]
formats[format]['sets'] = sets.split(', ')
elif line.startswith('Banned'):
banned = line.split(':')[1]
formats[format]['banned'] = banned.split('; ')
return formats return formats