From: Mikko Rasa Date: Mon, 3 Sep 2018 15:14:22 +0000 (+0300) Subject: Output divination card categories in a fixed order X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=ea5b219d29fabbe0ff9dea0d1ab4ca918cefb6ec;p=poefilter.git Output divination card categories in a fixed order --- 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")