2# +==== BEGIN display_tty =================+
4# ..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
5# .@...........................#@
6# @############################.@
7# @...........................@.@
8# @..#######################..@.@
9# @.#########################.@.@
10# @.##>_#####################.@.@
11# @.#########################.@.@
12# @.#########################.@.@
13# @.#########################.@.@
14# @.#########################.@.@
15# @..#######################..@.@
16# @...........................@.@
17# @..+----+______________.....@.@
18# @..+....+______________+....@.@
19# @..+----+...................@.@
20# @...........................@.#
21# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@#.
25# CREATION DATE: 06-11-2025
26# LAST Modified: 13:6:20 06-11-2025
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.
30# COPYRIGHT: (c) Henry Letellier
31# PURPOSE: File in charge of containing shorter names of the variables to ease the call.
33# +==== END display_tty =================+
35from typing
import Dict, Any, Optional, Union
37from .my_disp
import Logging
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
41from .initialiser
import initialise_logger
49@brief Alias for OUT_STRING constant.
55@brief Alias for OUT_DEFAULT constant.
61@brief Alias for OUT_FILE constant.
67@brief Alias for OUT_TTY constant.
74@brief Alias for KEY_OUTPUT_MODE constant.
76KOUTPUT_MODE = KEY_OUTPUT_MODE
80@brief Alias for KEY_PRETTIFY_OUTPUT constant.
82KPRETTIFY_OUTPUT = KEY_PRETTIFY_OUTPUT
86@brief Alias for KEY_ANIMATION_DELAY constant.
88KANIMATION_DELAY = KEY_ANIMATION_DELAY
91@var KANIMATION_DELAY_BLOCKY
92@brief Alias for KEY_ANIMATION_DELAY_BLOCKY constant.
94KANIMATION_DELAY_BLOCKY = KEY_ANIMATION_DELAY_BLOCKY
97@var KPRETTIFY_OUTPUT_IN_BLOCKS
98@brief Alias for KEY_PRETTIFY_OUTPUT_IN_BLOCKS constant.
100KPRETTIFY_OUTPUT_IN_BLOCKS = KEY_PRETTIFY_OUTPUT_IN_BLOCKS
104 class_name: Union[Logging, str],
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.
117 Original documentation:
118 @brief Initialise and return a configured Disp instance for a given class or module.
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.
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).
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.
149 A configured `Disp` instance ready to use.
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.
156 return initialise_logger(
157 class_name=class_name,
159 toml_content=toml_content,
160 save_to_file=save_to_file,
162 file_descriptor=file_descriptor,
165 log_warning_when_present=log_warning_when_present,
166 log_errors_when_present=log_errors_when_present
172 class_name: Union[Logging, str],
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`).
185 Original documentation:
186 @brief Initialise and return a configured Disp instance for a given class or module.
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.
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).
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.
217 A configured `Disp` instance ready to use.
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.
225 class_name=class_name,
227 toml_content=toml_content,
228 save_to_file=save_to_file,
230 file_descriptor=file_descriptor,
233 log_warning_when_present=log_warning_when_present,
234 log_errors_when_present=log_errors_when_present
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)
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)