AQIT 0.1.0
Loading...
Searching...
No Matches
license_display.py
Go to the documentation of this file.
1# Copyright (c) 2025-present Aquin Labs Private Limited. All Rights Reserved.
2"""ASCII terminal layout for the AQIT license."""
3
4from __future__ import annotations
5
6import sys
7
8from aquin.ascii_layout import (
9 BANNER,
10 ascii_safe,
11 box_bottom,
12 box_line,
13 box_lines,
14 box_top,
15 center,
16 center_block,
17 print_banner,
18 rule,
19 width,
20)
21from aquin.license_text import LICENSE_URL, read_license_text
22
23# Compatibility aliases for callers that import private helpers from this module.
24_BANNER = BANNER
25_width = width
26_rule = rule
27_center = center
28_center_block = center_block
29_box_line = box_line
30_box_lines = box_lines
31_box_top = box_top
32_box_bottom = box_bottom
33_ascii_safe = ascii_safe
37 *,
38 context: str = "view",
39 show_acceptance_footer: bool = False,
40) -> None:
41 """Print the full license in a consistent ASCII frame."""
42 w = width()
43 license_text = ascii_safe(read_license_text().rstrip())
44
45 print_banner(subtitle="ENGINE | PROPRIETARY SOFTWARE LICENSE", w=w)
46 print(center(f"canonical: {LICENSE_URL}", w))
47 print()
48
49 if context == "login":
50 print(box_top(w))
51 print(box_line("LOGGED IN - review the license below, then accept at the end", w))
52 print(box_bottom(w))
53 print()
54 elif context == "first_use":
55 print(box_top(w))
56 print(box_line("REVIEW REQUIRED - accept at the end to continue", w))
57 print(box_bottom(w))
58 print()
59
60 print(box_top(w))
61 for line in license_text.splitlines():
62 for boxed in box_lines(line, w):
63 print(boxed)
64 print(box_bottom(w))
65 print()
66
67 if show_acceptance_footer:
68 print(rule("=", w))
69 print(center("ACCEPTANCE", w))
70 print(rule("-", w))
71 print()
72 print(" You must accept this license to use Aquin.")
73 print()
74 print(" y / yes accept and continue")
75 print(" n / no decline")
76 print()
77 print(rule("=", w))
78
79
80def prompt_license_acceptance(*, context: str = "first_use") -> bool:
81 """Show the full license and ask the user to accept."""
82 if not sys.stdin.isatty():
83 return False
85 render_license_document(context=context, show_acceptance_footer=True)
86
87 try:
88 answer = input(" accept? (y/n): ").strip().lower()
89 except (EOFError, KeyboardInterrupt):
90 print()
91 return False
92
93 return answer in {"y", "yes"}
None render_license_document(*, str context="view", bool show_acceptance_footer=False)
bool prompt_license_acceptance(*, str context="first_use")