Spaces:
Running
Running
Download src/safe_logging.py from toecm/PureVersation: direct link, hf CLI and curl.
- Browser
- Download file 682 Bytes
-
https://huggingface.co/spaces/toecm/PureVersation/resolve/main/src/safe_logging.py
- Command line
-
hf download hf://spaces/toecm/PureVersation/src/safe_logging.py
-
curl -L -o safe_logging.py https://huggingface.co/spaces/toecm/PureVersation/resolve/main/src/safe_logging.py
682 Bytes
| """Small helpers for operational logs that must not expose credentials.""" | |
| from urllib.parse import urlsplit | |
| def redacted_endpoint(value) -> str: | |
| raw = str(value or "").strip() | |
| if not raw: | |
| return "missing" | |
| try: | |
| parsed = urlsplit(raw) | |
| if not parsed.scheme or not parsed.hostname: | |
| return "configured (details redacted)" | |
| host = parsed.hostname | |
| if ":" in host and not host.startswith("["): | |
| host = f"[{host}]" | |
| port = f":{parsed.port}" if parsed.port is not None else "" | |
| return f"{parsed.scheme}://{host}{port}" | |
| except (TypeError, ValueError): | |
| return "configured (details redacted)" | |