b733e551a0
Add scripts/normalize_ambiguous_unicode.py; fix corrupted patch_instance_theme_templates.py. Preserves curly quotes in string literals; removes Git homoglyph warnings on .env.example. Co-authored-by: Cursor <cursoragent@cursor.com>
64 lines
1.7 KiB
Python
64 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
将 brand/icons 同步到中控与各所 static/icons(Chrome 快捷方式 / 标签页图标).
|
|
|
|
用法(仓库根目录):
|
|
python scripts/generate_brand_icons.py
|
|
python scripts/sync_brand_icons.py
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import shutil
|
|
|
|
REPO = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
SRC = os.path.join(REPO, "brand", "icons")
|
|
|
|
HUB_DEST = os.path.join(REPO, "manual_trading_hub", "static", "icons")
|
|
EXCHANGE_DIRS = (
|
|
"crypto_monitor_binance",
|
|
"crypto_monitor_okx",
|
|
"crypto_monitor_gate",
|
|
)
|
|
|
|
FILES = (
|
|
"icon.svg",
|
|
"favicon.ico",
|
|
"icon-16.png",
|
|
"icon-32.png",
|
|
"icon-192.png",
|
|
"icon-512.png",
|
|
"apple-touch-icon.png",
|
|
)
|
|
|
|
|
|
def sync_dir(dest: str, url_prefix: str, manifest_template: str) -> str:
|
|
if not os.path.isdir(SRC):
|
|
return f"SKIP {dest}: 请先运行 python scripts/generate_brand_icons.py"
|
|
os.makedirs(dest, exist_ok=True)
|
|
for name in FILES:
|
|
shutil.copy2(os.path.join(SRC, name), os.path.join(dest, name))
|
|
manifest_src = os.path.join(REPO, "brand", manifest_template)
|
|
if os.path.isfile(manifest_src):
|
|
with open(manifest_src, encoding="utf-8") as f:
|
|
text = f.read().replace("__ICON_PREFIX__", url_prefix)
|
|
with open(
|
|
os.path.join(dest, "manifest.webmanifest"),
|
|
"w",
|
|
encoding="utf-8",
|
|
newline="\n",
|
|
) as f:
|
|
f.write(text)
|
|
return f"DONE {dest}"
|
|
|
|
|
|
def main() -> None:
|
|
print(sync_dir(HUB_DEST, "/assets/icons", "manifest.webmanifest"))
|
|
for d in EXCHANGE_DIRS:
|
|
dest = os.path.join(REPO, d, "static", "icons")
|
|
print(sync_dir(dest, "/static/icons", "manifest.exchange.webmanifest"))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|