Display TTY  1
Customise your terminal's output
Loading...
Searching...
No Matches
constants.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: constants.py
25# CREATION DATE: 06-11-2025
26# LAST Modified: 12:29:5 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# @file constants.py
30# @brief This is the file in charge of containing the constants used in the display_tty library.
31# @details This module defines constants and configuration settings used throughout the display_tty project. It includes error codes, output modes, animation delays,TOML configuration defaults, and forbidden log levels.
32# /STOP
33# COPYRIGHT: (c) Henry Letellier
34# PURPOSE: File in charge of containing the constants of the program.
35# // AR
36# +==== END display_tty =================+
37"""
38
39# Error codes
40ERR = 1 # General error code
41ERROR = ERR # Alias for ERR
42SUCCESS = 0 # Success code
43
44# Output modes
45OUT_TTY = "tty" # Output to terminal (TTY)
46OUT_STRING = "string" # Output as a string
47OUT_FILE = "file" # Output to a file
48OUT_DEFAULT = '' # Default output mode
49
50# OUTPUT modes keys
51KEY_OUTPUT_MODE = "OUTPUT_MODE" # Key for selecting output mode
52KEY_PRETTIFY_OUTPUT = "PRETTIFY_OUTPUT" # Key for enabling prettified output
53# Key for block-based prettified output
54KEY_PRETTIFY_OUTPUT_IN_BLOCKS = "PRETTY_OUTPUT_IN_BLOCS"
55
56# Animation delays
57# Key for animation delay in messages
58KEY_ANIMATION_DELAY = 'MESSAGE_ANIMATION_DELAY'
59# Key for blocky animation delay
60KEY_ANIMATION_DELAY_BLOCKY = 'MESSAGE_ANIMATION_DELAY_BLOCKY'
61
62# TOML configuration defaults
63TOML_CONF = {
64 KEY_OUTPUT_MODE: OUT_TTY, # Default output mode
65 KEY_PRETTIFY_OUTPUT: True, # Enable prettified output by default
66 # Enable block-based prettified output by default
67 KEY_PRETTIFY_OUTPUT_IN_BLOCKS: True,
68 KEY_ANIMATION_DELAY: 0.01, # Default animation delay
69 KEY_ANIMATION_DELAY_BLOCKY: 0.01, # Default blocky animation delay
70 'MESSAGE_CHARACTER': '@', # Default character for messages
71 'MESSAGE_ERROR_CHARACTER': '#', # Character for error messages
72 'MESSAGE_INFORM_CHARACTER': 'i', # Character for informational messages
73 'MESSAGE_QUESTION_CHARACTER': '?', # Character for question messages
74 'MESSAGE_SUCCESS_CHARACTER': '/', # Character for success messages
75 'MESSAGE_WARNING_CHARACTER': '!', # Character for warning messages
76 'SUB_SUB_TITLE_WALL_CHARACTER': '*', # Character for sub-sub-title walls
77 'SUB_TITLE_WALL_CHARACTER': '@', # Character for sub-title walls
78 'TITLE_WALL_CHARACTER': '#', # Character for title walls
79 'TREE_COLUMN_SEPERATOR_CHAR': '│', # Column separator for tree structures
80 'TREE_LINE_SEPERATOR_CHAR': '─', # Line separator for tree structures
81 'TREE_NODE_CHAR': '├', # Node character for tree structures
82 'TREE_NODE_END_CHAR': '└', # End node character for tree structures
83 'BOX_NO_VERTICAL': '#', # Box character without vertical lines
84 'BOX_VERTICAL_NO_HORIZONTAL': '#', # Box character without horizontal lines
85 'ROUND_BOX_CORNER_LEFT': '╔', # Top-left corner of a rounded box
86 'ROUND_BOX_CORNER_RIGHT': '╗', # Top-right corner of a rounded box
87 'ROUND_BOX_CORNER_BOTTOM_LEFT': '╚', # Bottom-left corner of a rounded box
88 'ROUND_BOX_CORNER_BOTTOM_RIGHT': '╝', # Bottom-right corner of a rounded box
89 'ROUND_BOX_HORIZONTAL': '═', # Horizontal line for rounded boxes
90 'ROUND_BOX_VERTICAL': '║', # Vertical line for rounded boxes
91 'DIFF_BORDER_LINE_CHARACTER_BOX': '-', # Border line character for diff boxes
92 'DIFF_SIDE_LINE_CHARACTER_BOX': '|', # Side line character for diff boxes
93}
94
95# Forbidden log levels
96FORBIDDEN_NUMBER_LOG_LEVELS_CORRESPONDANCE = {
97 "INFO": 20, # Informational messages
98 "WARN": 30, # Warning messages
99 "DEBUG": 10, # Debugging messages
100 "FATAL": 50, # Fatal error messages
101 "ERROR": 40, # Error messages
102 "NOTSET": 0, # No specific log level
103 "WARNING": 40, # Alias for WARN
104 "CRITICAL": 50 # Alias for FATAL
105}
106
107FORBIDDEN_NUMBER_LOG_LEVELS = list(
108 FORBIDDEN_NUMBER_LOG_LEVELS_CORRESPONDANCE.values()
109) # List of forbidden log level numbers
110
111
112"""
113@var SAVE_TO_FILE
114@brief Boolean flag to indicate whether to save output to a file.
115"""
116SAVE_TO_FILE = False
117
118"""
119@var FILE_NAME
120@brief Name of the file where results will be saved if SAVE_TO_FILE is True.
121"""
122FILE_NAME = "run_results.txt"
123
124"""
125@var FILE_DESCRIPTOR
126@brief File descriptor for the output file.
127"""
128FILE_DESCRIPTOR = None