Download phase5/ui/patch_tabs.py from luispoveda93/sharky-workbench: direct link, hf CLI and curl.
- Browser
- Download file 851 Bytes
-
https://huggingface.co/datasets/luispoveda93/sharky-workbench/resolve/main/phase5/ui/patch_tabs.py
- Command line
-
hf download hf://datasets/luispoveda93/sharky-workbench/phase5/ui/patch_tabs.py
-
curl -L -o patch_tabs.py https://huggingface.co/datasets/luispoveda93/sharky-workbench/resolve/main/phase5/ui/patch_tabs.py
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}") |