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

Function initializeEditions

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

Source from the content-addressed store, hash-verified

13allJsonUrl = 'http://mtgjson.com/json/AllCards.json'
14
15def initializeEditions():
16 ignoredTypes = [ "From_the_Vault", "Duel_Decks", "Online", "Premium_Deck_Series" , "Funny" , "Promos"]
17 ignoredBorders = [ "Silver" ]
18 editionSections = [ "[cards]", "[precon product]", "[borderless]", "[showcase]", "[extended art]", "[buy a box]", "[promo]", "[jumpstart]", "[rebalanced]" ]
19
20 print("Parsing Editions folder")
21 for root, dirnames, filenames in os.walk(editionsDir):
22 for fileName in fnmatch.filter(filenames, '*.txt'):
23 #print "Parsing...", fileName
24 hasSetNumbers = None
25 with open(os.path.join(root, fileName)) as currentEdition:
26 # Check all names for this card
27 metadata = True
28 setcode = setname = settype = border = None
29 for line in currentEdition.readlines():
30 line = line.strip()
31 if metadata:
32 if line in editionSections:
33 metadata = False
34 if setcode and setcode not in setCodes:
35 setCodes.append(setcode)
36 setCodeToName[setcode] = setname
37 if settype in ignoredTypes or border in ignoredBorders:
38 ignoredSet.append(setcode)
39
40 elif line.startswith("Code="):
41 setcode = line.split("=")[1].rstrip()
42
43 elif line.startswith("Name="):
44 setname = line.split("=")[1].rstrip()
45
46 elif line.startswith("Type="):
47 settype = line.split("=")[1].rstrip()
48
49 elif line.startswith("Border="):
50 border = line.split("=")[1].rstrip()
51
52 else:
53 if not line:
54 continue
55
56 if line.startswith("["):
57 if line not in editionSections:
58 metadata = True
59 continue
60
61 if line.startswith("#"):
62 continue
63
64 hasSetNumbers = line[0].isdigit()
65 card = line.split(" ", 2 if hasSetNumbers else 1)[-1].rstrip().split('|')[0]
66
67 if card.endswith('+'):
68 card = card[:-1]
69
70 if card not in mtgDataCards:
71 #print card
72 mtgDataCards[card] = [setcode]

Callers 1

EditionTracking.pyFile · 0.85

Calls 5

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

Tested by

no test coverage detected