mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-23 07:54:25 +01:00
* added utf8 fonts with multi lang charset * removed icon substring stuff * synced US-L version
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
import json
|
|
import os
|
|
|
|
__location__ = os.path.realpath(
|
|
os.path.join(os.getcwd(), os.path.dirname(__file__)))
|
|
|
|
with open(os.path.join(__location__, "icons.json"),'r') as f:
|
|
icon_metadata = json.load(f)
|
|
|
|
|
|
|
|
# write mapping lib for python
|
|
with open(os.path.join(__location__, "../../../apps/nspanel-lovelace-ui/luibackend", "icon_mapping.py"), 'w') as f:
|
|
f.write("icons = {\n")
|
|
for icon in icon_metadata:
|
|
iconchar = chr(int(icon['hex'], 16))
|
|
name = icon["name"]
|
|
f.write(f" '{name}': '{iconchar}',\n")
|
|
f.write("}\n")
|
|
f.write("""
|
|
def get_icon_id(ma_name):
|
|
ma_name = ma_name.replace("mdi:","")
|
|
if ma_name in icons:
|
|
return icons[ma_name]
|
|
else:
|
|
return icons["alert-circle-outline"]
|
|
""")
|
|
|
|
# write documentation file
|
|
with open(os.path.join(__location__, "../..","icons.md"), 'w') as f:
|
|
f.write("""
|
|
# Icons IDs
|
|
This file contains the Icons IDs included in the display firmware, addressable via serial.
|
|
|
|
MD Icon Name | Icon
|
|
------------ | ----
|
|
""")
|
|
for icon in icon_metadata:
|
|
val = icon["name"]
|
|
f.write(f"mdi:{val} | \n")
|