From ea5b219d29fabbe0ff9dea0d1ab4ca918cefb6ec Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 3 Sep 2018 18:14:22 +0300 Subject: [PATCH] Output divination card categories in a fixed order --- scrape-wiki-data.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scrape-wiki-data.py b/scrape-wiki-data.py index 470d282..7f5d3da 100755 --- a/scrape-wiki-data.py +++ b/scrape-wiki-data.py @@ -108,6 +108,8 @@ class WikiTableParser(WikiParser): pass class DivinationCardsParser(WikiTableParser): + reward_kinds = ("currency", "map", "unique", "links", "skillgem", "rare", "magic", "other") + def handle_starttag(self, tag, attrs): super(DivinationCardsParser, self).handle_starttag(tag, attrs) @@ -340,10 +342,10 @@ def main(): by_reward.setdefault(it.reward_kind, []).append(it) out = open("cards.txt", "w") - for r, il in by_reward.items(): + for r in DivinationCardsParser.reward_kinds: out.write('category "card.{}"\n'.format(r)) out.write('{\n\tclass "Card";\n\tor\n\t{\n') - for it in il: + for it in by_reward[r]: out.write('\t\tbase_type "{}";\n'.format(it.name)) out.write("\t};\n};\n") -- 2.45.2