How to use the osrsbox.items_api.item_properties.ItemProperties.from_json function in osrsbox

To help you get started, we’ve selected a few osrsbox examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github osrsbox / osrsbox-db / osrsbox / items_api / all_items.py View on Github external
def _load_item(self, item_json: Dict) -> None:
        """Convert the `item_json` into a :class:`ItemProperties` and store it.

        :param item_json: A dict from an open and loaded JSON file.
        :raises ValueError: Cannot populate item.
        """
        # Load the item using the ItemProperties class
        try:
            item_def = ItemProperties.from_json(item_json)
        except TypeError as e:
            raise ValueError("Error: Invalid JSON structure found, check supplied input. Exiting") from e

        # Add item to list
        self.all_items.append(item_def)
        self.all_items_dict[item_def.id] = item_def