]> git.tdb.fi Git - poefilter.git/commitdiff
Store item data in a list instead of a dict
authorMikko Rasa <tdb@tdb.fi>
Thu, 16 Aug 2018 14:34:33 +0000 (17:34 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 16 Aug 2018 14:34:33 +0000 (17:34 +0300)
scrape-item-data.py

index 3174a270c903491d7adbf6362c1d64cf9647a0e3..0334898ac4aff96637146b474470860b0eca319d 100755 (executable)
@@ -109,7 +109,7 @@ class ItemDataParser(html.parser.HTMLParser):
                self.in_items_table = False
                self.column = 0
                self.in_cell = False
-               self.items = {}
+               self.items = []
                self.current_item = None
                self.in_heading = False
                self.headings = []
@@ -145,7 +145,7 @@ class ItemDataParser(html.parser.HTMLParser):
                        self.in_cell = False
                elif tag=="tr":
                        if self.current_item and self.mod_row:
-                               for it in self.items.values():
+                               for it in self.items:
                                        self.current_item.check_upgrade(it)
                elif tag=="h1":
                        self.in_heading = False
@@ -175,7 +175,7 @@ class ItemDataParser(html.parser.HTMLParser):
                        else:
                                if self.column==2:
                                        self.current_item = self.create_item(data, self.current_heading)
-                                       self.items[data] = self.current_item
+                                       self.items.append(self.current_item)
                                elif self.column==3:
                                        self.current_item.droplevel = int(data)
                                elif self.column>=4:
@@ -252,7 +252,7 @@ def main():
        out = open("armor.txt", "w")
 
        for t, f in types.items():
-               items = [i for i in p.items.values() if f(i)]
+               items = [i for i in p.items if f(i)]
 
                for i in range(1, 3):
                        write_best_category(out, "armor.{}".format(t), items, i)
@@ -292,7 +292,7 @@ def main():
        out = open("weapons.txt", "w")
 
        for h in p.headings:
-               items = [i for i in p.items.values() if i.kind==h]
+               items = [i for i in p.items if i.kind==h]
 
                for i in range(1, 3):
                        write_best_category(out, "weapon.{}".format(h.lower().replace(' ', '_')), items, i)