MCPcopy Create free account
hub / github.com/Card-Forge/forge / initializeFormats

Function initializeFormats

forge-gui/tools/EditionTracking.py:132–169  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

130 forgeCards.append(name)
131
132def initializeFormats():
133 formats = {}
134 formatLocation = os.path.join(resDir, 'formats', 'Sanctioned')
135 print("Looking for formats in ", formatLocation)
136 for root, dirnames, filenames in os.walk(formatLocation):
137 for fileName in fnmatch.filter(filenames, '*.txt'):
138 if fileName not in ['Standard.txt', 'Modern.txt']:
139 continue
140
141 with open(os.path.join(root, fileName)) as formatFile:
142 while formatFile:
143 try:
144 line = formatFile.readline().strip()
145 if not line:
146 # this should only happen when the file is done processing if we did things correctly?
147 break
148 if line == '[format]':
149 line = formatFile.readline().strip()
150
151 if line.startswith('Name:'):
152 format = line.split(':')[1]
153 formats[format] = {}
154 else:
155 break
156 except:
157 break
158
159 # Pull valid sets
160 while line != '':
161 line = formatFile.readline().strip()
162 if line.startswith('Sets:'):
163 sets = line.split(':')[1]
164 formats[format]['sets'] = sets.split(', ')
165 elif line.startswith('Banned'):
166 banned = line.split(':')[1]
167 formats[format]['banned'] = banned.split('; ')
168
169 return formats
170
171def writeToFiles(text, files):
172 for f in files:

Callers 1

EditionTracking.pyFile · 0.70

Calls 4

walkMethod · 0.80
splitMethod · 0.80
joinMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected