Esempio n. 1
0
    def export(self):
        # Create ItemDefintion object
        if "wiki_name" in self.item_dict:
            del self.item_dict["wiki_name"]
        if "store_price" in self.item_dict:
            del self.item_dict["store_price"]
        if "seller" in self.item_dict:
            del self.item_dict["seller"]
        if "equipable_weapon" not in self.item_dict:
            self.item_dict["equipable_weapon"] = False

        for prop in self.properties:
            try:
                self.item_dict[prop]
            except KeyError:
                self.item_dict[prop] = None

        if self.item_dict["url"] == "https://oldschool.runescape.wiki/w/None":
            self.item_dict["url"] = None

        self.item_definition = ItemDefinition(**self.item_dict)
        self.compare_json_files(self.item_definition)
        json_out = self.item_definition.construct_json()
        # Actually output a JSON file, comment out for testing
        output_dir = os.path.join("..", "docs", "items-json")
        self.item_definition.export_json(True, output_dir)
        self.logger.debug(json_out)
        return
Esempio n. 2
0
    def _load_item(self, item_json: Dict) -> None:
        """Convert the `item_json` into a :class:`ItemDefinition` and store it."""
        # Load the item using the ItemDefinition class
        item_def = ItemDefinition(**item_json)

        # Add item to list
        self.all_items.append(item_def)
        self.all_items_dict[item_def.id] = item_def
Esempio n. 3
0
 def export(self):
     # Create ItemDefintion object
     if "wiki_name" in self.item_dict:
         del self.item_dict["wiki_name"]
     if "store_price" in self.item_dict:
         del self.item_dict["store_price"]
     if "seller" in self.item_dict:
         del self.item_dict["seller"]
     self.itemDefinition = ItemDefinition(**self.item_dict)
     self.compare_json_files(self.itemDefinition)
     json_out = self.itemDefinition.construct_json()
     # Actually output a JSON file, comment out for testing
     output_dir = os.path.join("..", "docs", "items-json")
     self.itemDefinition.export_json(True, output_dir)
     self.logger.debug(json_out)
     return
Esempio n. 4
0
    def check_duplicate_item(self) -> ItemDefinition:
        """Determine if this is a duplicate item.

        :return: An ItemDeinition object.
        """
        # Start by setting the duplicate property to False
        self.item_dict["duplicate"] = False
        # Create an ItemDefinition object
        item_definition = ItemDefinition(**self.item_dict)

        # Set the item properties that we want to compare
        correlation_properties = {
            "wiki_name": False,
            "noted": False,
            "placeholder": False,
            "equipable": False,
            "equipable_by_player": False,
            "equipable_weapon": False
        }

        # Loop the list of currently (already processed) items
        for known_item in self.known_item_names:
            # Do a quick name check before deeper inspection
            if item_definition.name != known_item.name:
                continue

            # If the cache names are equal, do further inspection
            for cprop in correlation_properties:
                if getattr(item_definition,
                           cprop) == getattr(known_item, cprop):
                    correlation_properties[cprop] = True

            # Check is all values in correlation properties are True
            correlation_result = all(
                value is True for value in correlation_properties.values())
            if correlation_result:
                self.item_dict["duplicate"] = True

        return item_definition
Esempio n. 5
0
 def generate_item_object(self):
     """Generate the `ItemDefinition` object from the item_dict dictionary."""
     self.item_definition = ItemDefinition(**self.item_dict)