]> git.tdb.fi Git - poefilter.git/commitdiff
Output divination card categories in a fixed order
authorMikko Rasa <tdb@tdb.fi>
Mon, 3 Sep 2018 15:14:22 +0000 (18:14 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 3 Sep 2018 15:14:22 +0000 (18:14 +0300)
scrape-wiki-data.py

index 470d282e21876a6655c07a9429ba683f11daba0c..7f5d3da06d8c3494f3c62221cc0eecf2ce53c57a 100755 (executable)
@@ -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")