Last active
August 29, 2015 14:20
-
-
Save taycaldwell/1cf02ff2effed7970005 to your computer and use it in GitHub Desktop.
print enum => name dict for hearthstone card XML data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import glob | |
enum_id_dict = {} | |
for f in glob.glob('cardxml0/TextAsset/*txt'): | |
with open(f) as cardfile: | |
cardsoup = BeautifulSoup(cardfile.read(), features="xml") | |
card = cardsoup.find('Entity') | |
tags = card.find_all('Tag') | |
for tag in tags: | |
enum_id = int(tag.get('enumID')) | |
name = tag.get('name') | |
enum_id_dict[enum_id] = name | |
print enum_id_dict.items() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script assumes card entities are in their own text files.