From 46302456fbb953cd0c9f3269b9c26ab2e4e513ec Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 16 Aug 2018 17:34:33 +0300 Subject: [PATCH] Store item data in a list instead of a dict --- scrape-item-data.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scrape-item-data.py b/scrape-item-data.py index 3174a27..0334898 100755 --- a/scrape-item-data.py +++ b/scrape-item-data.py @@ -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) -- 2.45.2