Display TTY  1
Customise your terminal's output
Loading...
Searching...
No Matches
aliases.py
Go to the documentation of this file.
1"""
2# +==== BEGIN display_tty =================+
3# LOGO:
4# ..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
5# .@...........................#@
6# @############################.@
7# @...........................@.@
8# @..#######################..@.@
9# @.#########################.@.@
10# @.##>_#####################.@.@
11# @.#########################.@.@
12# @.#########################.@.@
13# @.#########################.@.@
14# @.#########################.@.@
15# @..#######################..@.@
16# @...........................@.@
17# @..+----+______________.....@.@
18# @..+....+______________+....@.@
19# @..+----+...................@.@
20# @...........................@.#
21# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@#.
22# /STOP
23# PROJECT: display_tty
24# FILE: aliases.py
25# CREATION DATE: 06-11-2025
26# LAST Modified: 13:6:20 06-11-2025
27# DESCRIPTION:
28# A module that allows you to display text with a few boilers (i.e. put your text in a square for titles). It also allows to log to the terminal by wrapping around the logging library.
29# /STOP
30# COPYRIGHT: (c) Henry Letellier
31# PURPOSE: File in charge of containing shorter names of the variables to ease the call.
32# // AR
33# +==== END display_tty =================+
34"""
35from typing import Dict, Any, Optional, Union
36
37from .my_disp import Logging
38
39from .constants import OUT_TTY, OUT_STRING, OUT_FILE, OUT_DEFAULT, KEY_OUTPUT_MODE, KEY_PRETTIFY_OUTPUT, KEY_PRETTIFY_OUTPUT_IN_BLOCKS, KEY_ANIMATION_DELAY, KEY_ANIMATION_DELAY_BLOCKY
40
41from .initialiser import initialise_logger
42
43TMP = None # linter bypass for a false positive of statement has no effect
44
45
46# Output Modes
47"""
48@var OSTRING
49@brief Alias for OUT_STRING constant.
50"""
51OSTRING = OUT_STRING
52
53"""
54@var ODEFAULT
55@brief Alias for OUT_DEFAULT constant.
56"""
57ODEFAULT = OUT_DEFAULT
58
59"""
60@var OFILE
61@brief Alias for OUT_FILE constant.
62"""
63OFILE = OUT_FILE
64
65"""
66@var OTTY
67@brief Alias for OUT_TTY constant.
68"""
69OTTY = OUT_TTY
70
71# Configuration Keys
72"""
73@var KOUTPUT_MODE
74@brief Alias for KEY_OUTPUT_MODE constant.
75"""
76KOUTPUT_MODE = KEY_OUTPUT_MODE
77
78"""
79@var KPRETTIFY_OUTPUT
80@brief Alias for KEY_PRETTIFY_OUTPUT constant.
81"""
82KPRETTIFY_OUTPUT = KEY_PRETTIFY_OUTPUT
83
84"""
85@var KANIMATION_DELAY
86@brief Alias for KEY_ANIMATION_DELAY constant.
87"""
88KANIMATION_DELAY = KEY_ANIMATION_DELAY
89
90"""
91@var KANIMATION_DELAY_BLOCKY
92@brief Alias for KEY_ANIMATION_DELAY_BLOCKY constant.
93"""
94KANIMATION_DELAY_BLOCKY = KEY_ANIMATION_DELAY_BLOCKY
95
96"""
97@var KPRETTIFY_OUTPUT_IN_BLOCKS
98@brief Alias for KEY_PRETTIFY_OUTPUT_IN_BLOCKS constant.
99"""
100KPRETTIFY_OUTPUT_IN_BLOCKS = KEY_PRETTIFY_OUTPUT_IN_BLOCKS
101
102
104 class_name: Union[Logging, str],
105 debug: bool = False,
106 *,
107 toml_content: Optional[Dict[str, Any]] = None,
108 save_to_file: Optional[bool] = None,
109 file_name: Optional[str] = None,
110 file_descriptor: Optional[Any] = None,
111 success: Optional[int] = None,
112 error: Optional[int] = None,
113 log_warning_when_present: Optional[bool] = None,
114 log_errors_when_present: Optional[bool] = None):
115 """Alias for initialise_logger kept for API compatibility.
116
117 Original documentation:
118 @brief Initialise and return a configured Disp instance for a given class or module.
119
120 This factory function creates and returns a configured `Disp` instance (the library's
121 display/logger wrapper) using defaults from `TOML_CONF`, `SAVE_TO_FILE` and `FILE_NAME`
122 unless overridden by the provided keyword arguments. The `class_name` may be a
123 `Logging`-compatible object (an object exposing logging-like methods) or a simple string
124 used as a label for the logger.
125
126 @param class_name Union[Logging, str]
127 The logging owner (class instance or name) to attach to the returned `Disp` instance.
128 @param debug bool, optional
129 If True the returned `Disp` instance will run in debug mode (enable debug-level output).
130 Defaults to False.
131 @param toml_content Optional[Dict[str, Any]]
132 Optional override for TOML configuration content (defaults to module-level TOML_CONF).
133 @param save_to_file Optional[bool]
134 Optional override to enable saving output to a file (defaults to module-level SAVE_TO_FILE).
135 @param file_name Optional[str]
136 Optional override for the file name used when saving to file (defaults to FILE_NAME).
137 @param file_descriptor Optional[Any]
138 Optional open file-like object to use for output (will be passed to `Disp`).
139 @param success Optional[int]
140 Optional custom success return code for the `Disp` instance.
141 @param error Optional[int]
142 Optional custom error return code for the `Disp` instance.
143 @param log_warning_when_present Optional[bool]
144 Optional flag to control whether warnings are logged when present.
145 @param log_errors_when_present Optional[bool]
146 Optional flag to control whether errors are logged when present.
147
148 @return Disp
149 A configured `Disp` instance ready to use.
150
151 @note
152 - Optional arguments are only applied when provided (truthy) except `save_to_file` which is explicitly converted to bool when passed.
153 - Use `file_descriptor` to reuse an open file handle instead of letting `Disp` open its own file.
154 - This function updates only configuration passed to `Disp` and does not change library global constants.
155 """
156 return initialise_logger(
157 class_name=class_name,
158 debug=debug,
159 toml_content=toml_content,
160 save_to_file=save_to_file,
161 file_name=file_name,
162 file_descriptor=file_descriptor,
163 success=success,
164 error=error,
165 log_warning_when_present=log_warning_when_present,
166 log_errors_when_present=log_errors_when_present
167 )
168
169
170# short alias
172 class_name: Union[Logging, str],
173 debug: bool = False,
174 *,
175 toml_content: Optional[Dict[str, Any]] = None,
176 save_to_file: Optional[bool] = None,
177 file_name: Optional[str] = None,
178 file_descriptor: Optional[Any] = None,
179 success: Optional[int] = None,
180 error: Optional[int] = None,
181 log_warning_when_present: Optional[bool] = None,
182 log_errors_when_present: Optional[bool] = None):
183 """Short alias for `initialise` (and therefore `initialise_logger`).
184
185 Original documentation:
186 @brief Initialise and return a configured Disp instance for a given class or module.
187
188 This factory function creates and returns a configured `Disp` instance (the library's
189 display/logger wrapper) using defaults from `TOML_CONF`, `SAVE_TO_FILE` and `FILE_NAME`
190 unless overridden by the provided keyword arguments. The `class_name` may be a
191 `Logging`-compatible object (an object exposing logging-like methods) or a simple string
192 used as a label for the logger.
193
194 @param class_name Union[Logging, str]
195 The logging owner (class instance or name) to attach to the returned `Disp` instance.
196 @param debug bool, optional
197 If True the returned `Disp` instance will run in debug mode (enable debug-level output).
198 Defaults to False.
199 @param toml_content Optional[Dict[str, Any]]
200 Optional override for TOML configuration content (defaults to module-level TOML_CONF).
201 @param save_to_file Optional[bool]
202 Optional override to enable saving output to a file (defaults to module-level SAVE_TO_FILE).
203 @param file_name Optional[str]
204 Optional override for the file name used when saving to file (defaults to FILE_NAME).
205 @param file_descriptor Optional[Any]
206 Optional open file-like object to use for output (will be passed to `Disp`).
207 @param success Optional[int]
208 Optional custom success return code for the `Disp` instance.
209 @param error Optional[int]
210 Optional custom error return code for the `Disp` instance.
211 @param log_warning_when_present Optional[bool]
212 Optional flag to control whether warnings are logged when present.
213 @param log_errors_when_present Optional[bool]
214 Optional flag to control whether errors are logged when present.
215
216 @return Disp
217 A configured `Disp` instance ready to use.
218
219 @note
220 - Optional arguments are only applied when provided (truthy) except `save_to_file` which is explicitly converted to bool when passed.
221 - Use `file_descriptor` to reuse an open file handle instead of letting `Disp` open its own file.
222 - This function updates only configuration passed to `Disp` and does not change library global constants.
223 """
224 return initialise(
225 class_name=class_name,
226 debug=debug,
227 toml_content=toml_content,
228 save_to_file=save_to_file,
229 file_name=file_name,
230 file_descriptor=file_descriptor,
231 success=success,
232 error=error,
233 log_warning_when_present=log_warning_when_present,
234 log_errors_when_present=log_errors_when_present
235 )
init(Union[Logging, str] class_name, bool debug=False, *, Optional[Dict[str, Any]] toml_content=None, Optional[bool] save_to_file=None, Optional[str] file_name=None, Optional[Any] file_descriptor=None, Optional[int] success=None, Optional[int] error=None, Optional[bool] log_warning_when_present=None, Optional[bool] log_errors_when_present=None)
Definition aliases.py:182
initialise(Union[Logging, str] class_name, bool debug=False, *, Optional[Dict[str, Any]] toml_content=None, Optional[bool] save_to_file=None, Optional[str] file_name=None, Optional[Any] file_descriptor=None, Optional[int] success=None, Optional[int] error=None, Optional[bool] log_warning_when_present=None, Optional[bool] log_errors_when_present=None)
Definition aliases.py:114