mirror of
https://github.com/walkxcode/dashboard-icons.git
synced 2025-10-22 21:48:57 +02:00
feat: add metadata for icons (#923)
This commit is contained in:
33
scripts/generate_meta.py
Normal file
33
scripts/generate_meta.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from pathlib import Path
|
||||
import json
|
||||
|
||||
ROOT_DIR = Path(__file__).resolve().parent.parent
|
||||
META_DIR = ROOT_DIR / "meta"
|
||||
|
||||
# Ensure the output folders exist
|
||||
META_DIR.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
def get_icon_names():
|
||||
return [path.stem for path in META_DIR.glob("*.json")]
|
||||
|
||||
def read_meta_for(icon_name):
|
||||
meta_file = META_DIR / f"{icon_name}.json"
|
||||
if meta_file.exists():
|
||||
with open(meta_file, 'r', encoding='UTF-8') as f:
|
||||
return json.load(f)
|
||||
return None
|
||||
|
||||
def generate_meta_json():
|
||||
icon_names = get_icon_names()
|
||||
fullMeta = dict()
|
||||
for icon_name in icon_names:
|
||||
meta = read_meta_for(icon_name)
|
||||
if meta is None:
|
||||
print(f"Missing meta for {icon_name}")
|
||||
continue
|
||||
fullMeta[icon_name] = meta
|
||||
with open(ROOT_DIR / "meta.json", 'w', encoding='UTF-8') as f:
|
||||
json.dump(fullMeta, f, indent=4)
|
||||
|
||||
if (__name__ == "__main__"):
|
||||
generate_meta_json()
|
Reference in New Issue
Block a user