How to use the osrsbox.items_api.all_items 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 / test / test_items_api.py View on Github external
def test_all_items_load_items_json(path_to_docs_dir: Path):
    path_to_items_json_dir_no_slash = path_to_docs_dir / "items-json"
    path_to_items_json_dir_slash = os.path.join(path_to_docs_dir, "items-json", "")

    for path in (path_to_items_json_dir_slash, path_to_items_json_dir_no_slash):
        all_db_items = all_items.AllItems(str(path))
        assert len(all_db_items.all_items) == NUMBER_OF_ITEMS
github osrsbox / osrsbox-db / test / test_items_api.py View on Github external
def test_all_items_load_items_complete(path_to_docs_dir: Path):
    path_to_items_complete = path_to_docs_dir / "items-complete.json"

    all_db_items = all_items.AllItems(str(path_to_items_complete))
    assert len(all_db_items.all_items) == NUMBER_OF_ITEMS
github osrsbox / osrsbox-db / scripts / update_items / generate_items_complete.py View on Github external
def main():
    """The main function for generating the `docs/items-complete.json` file"""
    # Read in the item database content
    path_to_items_json = Path(config.DOCS_PATH / "items-json")
    all_db_items = items_api.all_items.AllItems(path_to_items_json)

    items = {}

    for item in all_db_items:
        json_out = item.construct_json()
        items[item.id] = json_out

    # Save all items to docs/items_complete.json
    out_fi = Path(config.DOCS_PATH / "items-complete.json")
    with open(out_fi, "w") as f:
        json.dump(items, f)

    # Save all items to osrsbox/docs/items_complete.json
    out_fi = Path(config.PACKAGE_ROOT_PATH / "docs" / "items-complete.json")
    with open(out_fi, "w") as f:
        json.dump(items, f)
github osrsbox / osrsbox-db / scripts / update / update_json_files.py View on Github external
def generate_items_complete():
    """Generate the `docs/items-complete.json` file."""
    # Read in the item database content
    path_to_items_json = Path(config.DOCS_PATH / "items-json")
    all_db_items = items_api.all_items.AllItems(path_to_items_json)

    items = {}

    for item in all_db_items:
        json_out = item.construct_json()
        items[item.id] = json_out

    # Save all items to docs/items_complete.json
    out_fi = Path(config.DOCS_PATH / "items-complete.json")
    with open(out_fi, "w") as f:
        json.dump(items, f)

    # Save all items to osrsbox/docs/items_complete.json
    out_fi = Path(config.PACKAGE_PATH / "docs" / "items-complete.json")
    with open(out_fi, "w") as f:
        json.dump(items, f)
github osrsbox / osrsbox-db / osrsbox / items_api / __init__.py View on Github external
def load() -> all_items.AllItems:
    """Load the item database.

    :return all_db_items: An AllItems object containing the entire item database.
    """
    return all_items.AllItems()