57def load_item_db(db_dir, flat, files):
58 if not os.path.isdir(db_dir):
59 return {}
if flat
else {}
65 for stem, cat
in files.items():
66 path = os.path.join(db_dir, stem +
".json")
67 if os.path.exists(path):
68 for hx, name
in json.load(open(path, encoding=
"utf-8")).items():
70 int.from_bytes(bytes.fromhex(hx),
"little"), (name, cat)
74 for stem, cat
in files.items():
75 path = os.path.join(db_dir, stem +
".json")
76 if os.path.exists(path):
77 table = db.setdefault(cat, {})
78 for name, value
in json.load(open(path, encoding=
"utf-8")).items():
79 for iid
in _ids(value):
107def load_scan_db(db_dir, files, refine=None):
108 if not os.path.isdir(db_dir):
111 for stem, cat
in files.items():
112 path = os.path.join(db_dir, stem +
".json")
113 if os.path.exists(path):
114 for name, value
in json.load(open(path, encoding=
"utf-8")).items():
115 for iid
in _ids(value):
116 db.setdefault(iid, (name, refine(iid, cat)
if refine
else cat))