Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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
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)
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)
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()