Return a filesystem-safe label while preserving readable Unicode names.
(value: Any, *, max_len: int = 96)
| 13 | |
| 14 | |
| 15 | def slug(value: Any, *, max_len: int = 96) -> str: |
| 16 | """Return a filesystem-safe label while preserving readable Unicode names.""" |
| 17 | text = re.sub(r"[^\w.\-]+", "-", str(value or "").strip(), flags=re.UNICODE) |
| 18 | text = re.sub(r"-{2,}", "-", text).strip("-._") |
| 19 | return (text or "user")[:max_len] |
| 20 | |
| 21 | |
| 22 | def env_flag(name: str, default: bool = False) -> bool: |
no outgoing calls
no test coverage detected