sharky-workbench / phase5 /ui /patch_tabs.py
luispoveda93's picture
sharky ui: shorten Playground tab label for mobile fit
88c6356 verified
Raw History Blame Contribute Delete
851 Bytes
import hashlib, io, os
from huggingface_hub import HfApi, hf_hub_download
REPO = "luispoveda93/pcap-kev-triage"
api = HfApi()
p = hf_hub_download(REPO, "app.py", repo_type="space", force_download=True)
src = open(p, encoding="utf-8").read()
pairs = [
("\U0001F3AF Playground", "\U0001F3AF Try"), # tab label + panel heading, emoji kept for meaning
]
total = 0
for old, new in pairs:
n = src.count(old)
assert n >= 1, f"pattern not found: {old!r}"
src = src.replace(old, new)
total += n
buf = io.BytesIO(src.encode("utf-8"))
sha = hashlib.sha256(buf.getvalue()).hexdigest()
api.upload_file(
path_or_fileobj=buf,
path_in_repo="app.py",
repo_id=REPO,
repo_type="space",
commit_message="ui: shorten Playground tab label so all tabs fit 390px mobile",
)
print(f"PATCH_OK replacements={total} sha256={sha}")