Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.

Commit f865a7f

Browse files
committed
modified: .gitignore
modified: Data/CLI_main.py
1 parent e6331cb commit f865a7f

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/Data/PrintColor/__pycache__
22
/backup
3-
/Data/modules/__pycache__
3+
/Data/modules/__pycache__
4+
/build

Data/CLI_main.py

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,47 @@ def IEH(id: str = 'Unknown', stop: bool = True, DEV: bool = True):
6868
traceback.print_exc()
6969
if stop: sys.exit('SYS EXIT|ERROR: Internal|by Internal Error Handler')
7070
#Debug
71-
def Debug(ID, DEBUG_IF, SFL: bool = True):
72-
if Debug_m:
73-
frame_info = inspect.currentframe()
74-
location = f'{inspect.stack()[1].filename}:{frame_info.f_back.f_lineno}' if SFL else f'L:{frame_info.f_back.f_lineno}'
75-
print_Color(f'\n~*--> ~*DEBUG INFO id: ~*[{str(ID)}]~*, Location: ~*[{location}]~*, time: ~*[{datetime.now().strftime("%Y/%m/%d | %H:%M:%S")}]\n~*--> ~*Data: ~*{str(DEBUG_IF)}\n', ['red', 'magenta', 'yellow', 'magenta', 'yellow', 'magenta', 'yellow', 'red', 'magenta', 'yellow'], advanced_mode=True)
71+
def Debug(ID, DEBUG_IF, SFL: bool = True, Force: bool = False, SFCS: bool = True):
72+
"""
73+
This function is used for debugging purposes. It prints out various information about the data passed to it.
74+
75+
Args:
76+
ID (Any): The identifier for the data. This could be any type, but is typically a string.
77+
DEBUG_IF (Any): The data that needs to be debugged. This could be any type.
78+
SFL (bool, optional): A flag to determine if the stack frame location should be included in the debug information. Defaults to True.
79+
Force (bool, optional): A flag to force the debug information to be printed even if the global Debug_m is set to False. Defaults to False.
80+
SFCS (bool, optional): A flag to determine if the function call stack should be included in the debug information. Defaults to True.
81+
82+
Returns:
83+
None
84+
"""
85+
try:
86+
if Debug_m or Force:
87+
frame_info = inspect.currentframe()
88+
stack_trace = traceback.format_stack()
89+
stack_trace_formated = ''
90+
for line in stack_trace[:-1]:
91+
stack_trace_formated += '--> [!>>>' + line
92+
location = f'{inspect.stack()[1].filename}:{frame_info.f_back.f_lineno}' if SFL else f'L:{frame_info.f_back.f_lineno}'
93+
Debug_data = \
94+
f'\n~*--> ~*DEBUG INFO id: ~*[{str(ID)}]~*, ' \
95+
f'Location: ~*[{location}]~*, ' \
96+
f'time: ~*[{datetime.now().strftime("%Y/%m/%d | %H:%M:%S")}]\n~*--> ~*' \
97+
f'Data: ~*{str(DEBUG_IF)}\n~*--> ~*' \
98+
f'Data Type: ~*{type(DEBUG_IF)}\n~*--> ~*' \
99+
f'Memory Address: ~*DEC>>>~*{id(DEBUG_IF)}~* | HEX>>>~*{hex(id(DEBUG_IF))}~* | BIN>>>~*{bin(id(DEBUG_IF))}\n'
100+
if SFCS:
101+
Debug_data += f'~*--> ~*Function Call Stack: ~*↓\n~*{stack_trace_formated}\n'
102+
print_Color(Debug_data,
103+
['red', 'magenta', 'green', 'magenta', 'yellow', 'magenta', 'yellow',
104+
'red', 'magenta', 'yellow', 'red', 'magenta', 'yellow', 'red', 'magenta',
105+
'cyan', 'yellow', 'cyan', 'yellow', 'cyan', 'yellow', 'red', 'magenta', 'green', 'yellow'] if SFCS else \
106+
['red', 'magenta', 'green', 'magenta', 'yellow', 'magenta', 'yellow',
107+
'red', 'magenta', 'yellow', 'red', 'magenta', 'yellow', 'red', 'magenta',
108+
'cyan', 'yellow', 'cyan', 'yellow', 'cyan', 'yellow'],
109+
advanced_mode=True)
110+
except NameError:
111+
print_Color('~*[`Debug` func] --> ERROR: ~*carate a global var named `Debug_m` for turning on and off the Debug func.', ['red', 'yellow'], advanced_mode=True)
76112
#load modules
77113
def LCM():
78114
#Get Import List

0 commit comments

Comments
 (0)