AQIT
0.1.0
Toggle main menu visibility
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
4
from
__future__
import
annotations
5
6
import
sys
7
8
from
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
)
21
from
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
34
35
36
def
render_license_document
(
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
80
def
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
84
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"
}
aquin.ascii_layout
Definition
ascii_layout.py:1
aquin.license_display.render_license_document
None render_license_document(*, str context="view", bool show_acceptance_footer=False)
Definition
license_display.py:44
aquin.license_display.prompt_license_acceptance
bool prompt_license_acceptance(*, str context="first_use")
Definition
license_display.py:84
aquin.license_text
Definition
license_text.py:1
aquin
license_display.py
AQIT · Aquin Labs Private Limited · Apache 2.0 · Generated by
1.18.0