()
| 130 | forgeCards.append(name) |
| 131 | |
| 132 | def 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 | |
| 171 | def writeToFiles(text, files): |
| 172 | for f in files: |
no test coverage detected