Skip to content

Instantly share code, notes, and snippets.

@taycaldwell
Last active August 29, 2015 14:20
Show Gist options
  • Save taycaldwell/1cf02ff2effed7970005 to your computer and use it in GitHub Desktop.
Save taycaldwell/1cf02ff2effed7970005 to your computer and use it in GitHub Desktop.
print enum => name dict for hearthstone card XML data
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()
@taycaldwell
Copy link
Author

This script assumes card entities are in their own text files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment