A simple library for a beautiful output window written in curses and multiprocessing
Project description
CursesDebug
Does your print slow down the program? It doesn't give enough information, and if it does, then it's not really readable?
Use this library!
With it, you can make a beautiful-looking terminal for logs or\and debug!
And one of the main features! All messages are processed through a parallel process, so that no one will slow down your code!
For example, here is an example, the 1st time to output 10,000 messages using print, and the second, the same output, only using curses-debug
Print : 0.23720622062683105 s
dprint.send() : 0.05412912368774414 s
Just pass : 0.0009999275207519531 s
Also! You can add more. output in the form of a "description" to the conclusions!
Installation
pip install curses-debug
Description
This is a simple library that extends the work of a typical console through curses and multiprocessing (I was surprised that this bundle works 3 times faster than the usual print XD)
There are many functions, but I'll start in order:
To begin with, I declare the debug window class:
dprint = curses_debug()
Let's talk about the arguments right away:
colors- accepts a dict with a description of all colors{ "INFO" : (0, 153, 0), "WARN" : (204, 192, 0), "ERRO" : (153, 0, 0), "CRIT" : (255, 0, 0), "SELECTION" : (255, 255, 255), "UNSELECTION" : (0, 0, 0) }
default- the default code status value
block_end_of_program- If set to True, then when the program is disabled or crashes, it issues a message of the like this:DONE, after which it waits for the Enter inputThe next step is more complicated: by default, the system of monitors freezes (When the console freezes for a long time) have two mods: lite and burn. It is determined which type should be included by the number of elements in the buffer. The differences in the modes are only in the number of messages that will be processed.
min_buffer_size- number of messages to be processed at a time in lite mode
max_buffer_size- number of messages to be processed at a time in burn mode
max_buffer_size_threshold- the number of messages in the buffer needed to enable burn mode
time_function- A function for writing time. The default value is:lambda : time.strftime("%H:%M:%S", time.localtime()))
This is used to send messages:
dprint.send("Hello World")
Arguments:
1st positional - text for output, if you do not enter the text, then it will become
status- status code. If it is not assigned or is not correctly equal to the default value (see `default'). 0 - INFO; 1 - WARN; 2 - ERRO; 3 - CRIT
desc- description of the output.If you enter
str, it will simply output it (Use\nto split into several lines).If you enter
dictit will output in the format KEY : VALUEIf you enter
list, it will simply list all the values through Enter
replaceable- If set to True, then after the next message is output, it will be deleted (Similar toprint("", end="\r"))
This command sets a temporary timeout:
dprint.waitforend(1)
After you have entered this command, the console will ONLY receive messages (Without updates of the GUI), and as soon as there are no messages for the specified time (in seconds), the program will continue its execution as if nothing had happened.
To clear the console:
dprint.clear()
To get the buffer size, you can use one of the methods:
dprint.buffer_size()
len(dprint)
To generate "logs" in the form of json files, use this:
dprint.genJson()
To, let's say, prematurely close the console, use this:
dprint.close()
Accepts only
Nameas an argument in the form of astrstring (By default,Log.json)
The script also has a couple of Easter eggs that you can look for for fun (>o<)
Control
Up/down arrows - selection
Arrows to the side - enabling auto-scroll
After a message like [XX:XX:XX DONE] DONE! press Enter to exit
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file curses_debug-0.415.tar.gz.
File metadata
- Download URL: curses_debug-0.415.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d9a0b3b871570250bac72e142bd0fde6f3e310352e5ce0628bbaa00792c5287
|
|
| MD5 |
0df99d1ac1c154b203ac0fbb07659f8e
|
|
| BLAKE2b-256 |
5e51f6df6dc881e6e0116f03bfb65346ef72ed7383e6f1249e3a013bdf262102
|