MCPcopy Index your code
hub / github.com/masterking32/MasterHttpRelayVPN / print_banner

Function print_banner

src/core/logging_utils.py:276–316  ·  view source on GitHub ↗

Print an ASCII startup banner with color fallbacks.

(version: str, *, stream=None)

Source from the content-addressed store, hash-verified

274
275
276def print_banner(version: str, *, stream=None) -> None:
277 """Print an ASCII startup banner with color fallbacks."""
278 stream = stream or sys.stderr
279 color = _supports_color(stream)
280
281 def c(code: str) -> str:
282 return code if color else ""
283
284 art = [
285 " __ __ _ ____ _____ _____ ____ ",
286 "| \\/ | / \\ / ___|_ _| ____| _ \\ ",
287 "| |\\/| | / _ \\ \\___ \\ | | | _| | |_) |",
288 "| | | |/ ___ \\ ___) || | | |___| _ < ",
289 "|_| |_/_/ \\_\\____/ |_| |_____|_| \\_\\",
290 " _ _ _____ _____ ____ ____ _____ _ _ __ __",
291 " | | | |_ _|_ _| _ \\ | _ \\| ____| | / \\\\ \\ / /",
292 " | |_| | | | | | | |_) | | |_) | _| | | / _ \\\\ V / ",
293 " | _ | | | | | | __/ | _ <| |___| |___ / ___ \\| | ",
294 " |_| |_| |_| |_| |_| |_| \\_\\_____|_____/_/ \\_\\_| ",
295 ]
296 version_line = f"Version {version}"
297 link = "https://github.com/masterking32/MasterHttpRelayVPN"
298 width = max(max(len(line) for line in art), len(version_line), len(link))
299 rule = "=" * width
300
301 if color:
302 print(f"{DIM}{FG_GRAY}{rule}{RESET}", file=stream)
303 for line in art:
304 print(f"{BOLD}{FG_CYAN}{line.center(width)}{RESET}", file=stream)
305 print(f"{FG_GRAY}{version_line.center(width)}{RESET}", file=stream)
306 print(f"{FG_TEAL}{link.center(width)}{RESET}", file=stream)
307 print(f"{DIM}{FG_GRAY}{rule}{RESET}", file=stream)
308 else:
309 print(rule, file=stream)
310 for line in art:
311 print(line.center(width), file=stream)
312 print(version_line.center(width), file=stream)
313 print(link.center(width), file=stream)
314 print(rule, file=stream)
315
316 stream.flush()

Callers 1

mainFunction · 0.90

Calls 1

_supports_colorFunction · 0.85

Tested by

no test coverage detected