stv_utils - Python Utility Library
stv_utils is a Python utility library containing commonly used functions, particularly useful for projects requiring terminal output beautification, system environment detection, and console operations.
Features
🎨 Terminal Colors & Styles
- Generate ANSI escape codes
- Control foreground, background colors and text styles
- Includes normal and bright versions of colors
🌈 Colorized Output
- Enhanced print function supports hex color codes
- Automatically converts hex colors to the closest 256-color ANSI codes
- Maintains all parameters of native print function
🎭 Output Control
- Colorize output based on specific string prefixes
- Suppress output of specific lines by prefix
- Decorators simplify output control
🖥️ System Utilities
- Detect Chinese language environment
- Identify operating system type
- Check if running in IDLE environment
- Cross-platform console clearing function
Installation
pip install stv_utils
Quick Start
Basic Color Control
from stv_utils import color
# Get color and style dictionaries
fg, bg, styles = color()
print(f"{fg['red']}Red text{styles['reset_all']}")
print(f"{bg['blue']}Blue background{styles['reset_all']}")
print(f"{styles['bold']}Bold text{styles['reset_all']}")
Colorized Output
from stv_utils import print
# Using hex color codes
print(";#ff0000;This is red text")
print(";#00ff00;This is green text")
print(";#0000ff;This is blue text")
Output Control
from stv_utils import colorize, suppress_print
@colorize(color_code="\033[93m") # Yellow
def my_function():
print("|> This line will be colored")
print("This line remains default color")
@suppress_print(start_str="|>")
def my_quiet_function():
print("|> This line will be suppressed")
print("This line will display normally")
System Utilities
from stv_utils import is_ch, system_check, system_clear
# Detect Chinese environment
if is_ch():
print("Chinese environment detected")
# Get OS information
print(f"Current system: {system_check(verbose=True)}")
# Clear screen
system_clear()
Module Overview
color.py
Provides ANSI escape sequence generation:
- 8 basic colors (black, red, green, yellow, blue, magenta, cyan, white) and their bright versions
- 9 text styles (bold, dim, italic, underline, blink, reverse, hidden, strikethrough, reset_all)
output.py
Extends Python's built-in print function to support hex color codes in ;#xxxxxx; format, automatically converting to the closest 256-color ANSI code.
output_control.py
Provides output control capabilities:
ColorizedOutput: Colorize text with specific prefixesSuppressedOutput: Suppress text output with specific prefixescolorizedecorator: Simplify function output coloringsuppress_printdecorator: Simplify function output suppression
system_utils.py
System utility functions:
is_ch(): Detect Chinese language environmentsystem_check(): Get operating system informationis_idle(): Check if running in IDLE environmentsystem_clear(): Cross-platform screen clearing function
Contributing
Contributions are welcome! Please submit issues or pull requests via GitHub: https://github.com/StarWindv/stv_utils
License
This project is licensed under the MIT License.
Metadata
Release files for stv-utils 0.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| stv_utils-0.0.9.tar.gz | 7.8 kB | Without provenance | Details for stv_utils-0.0.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| stv_utils-0.0.9-py3-none-any.whl | Python 3 | none | any | Details for stv_utils-0.0.9-py3-none-any.whl |
Total release size: 15.4 kB
Release files / stv_utils-0.0.9.tar.gz
| Download URL | stv_utils-0.0.9.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f80c28f3239b9b25f4cfcf390e26e53dbbed0de9acc560e52f4a88192e1ffb77
|
|
BLAKE2b-256 checksum How to use checksums |
bd42605b49b63046adfe71fae322f0b465cbbfaa1799038d8634ad652257bb89
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.9
|
Release files / stv_utils-0.0.9-py3-none-any.whl
| Download URL | stv_utils-0.0.9-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cafdecca581fef4b8f553105738a013cab384ebcdbbb7efddcf9fa1b5b8bace4
|
|
BLAKE2b-256 checksum How to use checksums |
8226290c4304d27ed72a0dfaea2bdf9ded6fff99df21c16ca55f8aac5a8409c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.9
|
Security for stv-utils 0.0.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.