Download app/utils/utlis.py from bg5/zai: direct link, hf CLI and curl.
- Browser
- Download file 579 Bytes
-
https://huggingface.co/spaces/bg5/zai/resolve/main/app/utils/utlis.py
- Command line
-
hf download hf://spaces/bg5/zai/app/utils/utlis.py
-
curl -L -o utlis.py https://huggingface.co/spaces/bg5/zai/resolve/main/app/utils/utlis.py
579 Bytes
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| """Shared utility helpers.""" | |
| from __future__ import annotations | |
| from typing import Optional | |
| def mask_token( | |
| token: Optional[str], *, keep_prefix: int = 6, keep_suffix: int = 4 | |
| ) -> str: | |
| """Return a short recognizable token fragment for logs and UI.""" | |
| value = str(token or "").strip() | |
| if not value: | |
| return "" | |
| if len(value) <= keep_prefix + keep_suffix + 3: | |
| return value[: min(len(value), keep_prefix)] + "..." | |
| return f"{value[:keep_prefix]}...{value[-keep_suffix:]}" | |