Skip to content

Commit

Permalink
Use built-in tomllib
Browse files Browse the repository at this point in the history
  • Loading branch information
bash committed Mar 13, 2024
1 parent 0a2aacf commit 470e7c5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions client/scripts/build-items-json.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
#!/usr/bin/env python3

import json
import toml
import tomllib as toml
from glob import glob
from os import path
import os


def load_items(path):
with open(path, "rb") as fp:
return toml.load(fp)["items"]


items_directory = path.join(path.dirname(__file__), "..", "..", "items")
build_dir = path.join(path.dirname(__file__), "..", "build")

items = [
item
for p in glob("**/*.toml", root_dir=items_directory, recursive=True)
for item in toml.load(path.join(items_directory, p))["items"]
for item in load_items(path.join(items_directory, p))
if "e_number" in item
]
sorted_items = sorted(items, key=lambda item: (len(item["e_number"]), item["e_number"]))
Expand Down

0 comments on commit 470e7c5

Please sign in to comment.