A Python library that automatically beautifies terminal output by adding colors based on message content.
Project description
BeautifulTerminal
BeautifulTerminal is a Python library that automatically beautifies terminal output by adding colors based on the content of the messages. This library improves the readability of your console applications and makes it easier to understand log outputs and messages. No additional setup is required after importing!
Features
-
Automatic Colors:
- Errors are displayed in red.
- Warnings are displayed in yellow.
- Success messages are displayed in green.
- Regular messages use the terminal's default color (no color override).
-
Easy Integration:
- Simply import the library, and it works immediately.
-
Customizable:
- You can easily change the color codes to suit your preferences.
Installation
To install the library, use pip:
pip install beautiful-terminal
Optional Version Check
BeautifulTerminal optionally checks if you are running the latest version by contacting PyPI when you import the library or run it as a script.
- This feature requires the external libraries
requestsandsetuptools. - These dependencies are optional and the library works perfectly without them.
- If these libraries are installed, BeautifulTerminal will notify you in the terminal if your installed version is outdated or up to date.
- If not installed, the version check silently skips without affecting normal usage.
To enable the version check dependencies, install with:
pip install beautiful-terminal[version_check]
If you want to disable the version check completely, simply uninstall or avoid installing these optional dependencies.
Getting Started
After installation, you can quickly use the library in your Python scripts. Follow these simple steps:
- Import the library:
import beautiful_terminal
- Print messages:
Use the print function as usual. The library automatically applies the appropriate colors based on the content of your messages.
Usage
Here are some examples of how to use the library:
import beautiful_terminal
# Examples of using the library
print("This is a regular message.") # Default terminal color
print("Error: Something went wrong!") # Error in Red
print("Warning: Be careful!") # Warning in Yellow
print("Success: Operation completed!") # Success in Green
Example Outputs
| Type | Description |
|---|---|
| Regular message | Uses terminal default color |
| Warning | 🟡 Yellow |
| Error | 🔴 Red |
| Success | 🟢 Green |
Using the color Option
The print function in BeautifulTerminal supports an optional color parameter that lets you specify the color of the printed text directly. Example:
import beautiful_terminal
print("This text is normal.") # Default terminal color
print("This text is red!", color="red") # Red text
print("This text is yellow!", color="yellow") # Yellow text
print("This text is green!", color="green") # Green text
If you specify an invalid color, the default terminal color is used. This gives you flexibility to customize the text to your liking.
Customization
You can change the color codes in the library to modify the appearance of the outputs. This allows you to tailor the library to your preferred terminal design or personal preferences. Simply modify the COLORS dictionary in the BeautifulTerminal class.
Disabling
If you need to temporarily disable color output, you can do so:
import beautiful_terminal as bt
bt.disable() # Disable color output
To re-enable color output:
bt.enable() # Re-enable color output
Compatibility
The BeautifulTerminal library is compatible with any terminal that supports ANSI escape codes, which includes most modern terminal emulators on Windows, macOS, and Linux. It automatically enables ANSI support on Windows terminals. However, it may not work correctly on older systems or environments that do not support ANSI codes.
Cross-Platform Support
BeautifulTerminal works seamlessly across multiple operating systems, including:
- Windows (enables ANSI escape code support automatically)
- macOS
- Linux
This makes it a reliable choice for terminal beautification in cross-platform Python projects.
Acknowledgments
- This library was inspired by the need for better readability of terminal outputs.
- Special thanks to the contributors and the open-source community for their continuous support and suggestions.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Contributions
Contributions are welcome! If you have suggestions for improvements or additional features, feel free to open an issue or submit a pull request.
Contact
For questions or feedback, please reach out to us through the GitHub repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file beautiful_terminal-1.0.1.tar.gz.
File metadata
- Download URL: beautiful_terminal-1.0.1.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed765bbed54ce4c990021dd0ff299e0da9f90fce0070d2f3b7b771bf8dab1280
|
|
| MD5 |
f8b935f3a56ce6b82cdcff4a44bdbb70
|
|
| BLAKE2b-256 |
fb927f1156349d6e4380cc69c02d0ec27afa975c1989dd9b3e5eb20f900c1cce
|
File details
Details for the file beautiful_terminal-1.0.1-py3-none-any.whl.
File metadata
- Download URL: beautiful_terminal-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aed0ccc7bedad01a56e3adec6f08a4f0d49c0928fad44a9cde505407cf743e30
|
|
| MD5 |
78e05b89b04958e6200e9d07daeb1b91
|
|
| BLAKE2b-256 |
b87c647035b0be657cb810c85e72ae7209b013c2406990c2e2f4a6eec20194e7
|