Rich Console Utilities
A small utility module built on top of Rich for producing colourful, prettified drop-in replacement of built-in print() function.
The main contens are:
- A drop-in replacement for
print - A decorator for running functions with a spinner/status indicator like
npm
Installation
This module depends on Rich:
pip install themed-print
Usage
Pretty Print (Drop-in Replacement)
themed_print.print can be used as a drop-in replacement for the built-in print() function
from themed_print import print
print({
"name": "Alice",
"values": [1, 2, 3],
"active": True,
})
With custom indentation:
print(data, indent=2, show_guideline=True)
Arguments:
| Parameter | Type | Description |
|---|---|---|
content |
Any | Objects to print |
indent |
int | Spaces per indent level |
show_guideline |
bool | Show indentation guides |
sep |
str | Separator between values |
end |
str | Line ending |
Status Spinner Decorator
Run a function with a live spinner:
from themed_print import show_status
import time
@show_status("Running task…", exit_message="Done ✔")
def task():
for i in range(3):
time.sleep(0.5)
print("step", i)
task()
Supported parameters:
| Parameter | Description |
|---|---|
status_message |
Message shown while running |
exit_message |
Message printed after completion |
exit_message_style |
Rich style for exit message |
spinner |
Spinner name (see python -m rich.spinner) |
**status_kwargs |
Passed to Console.status() |
Instance Method Behaviour
If the decorated function is an instance method, logging is skipped when:
self._show_status = False
This allows silent execution in batch or test modes.
Customisation
The colour schemed is implemented through rich.theme.Theme object with customised regex highlighter themed_print.DTypeRegexHighlighter.
Currently, colour schemes are defined in themed_print.config.DEFAULT_THEME Support for custom theming is planned for future releases.
Author
Yiheng Yu Created: Jan 1, 2025
Metadata
Release files for themed-print 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| themed_print-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Release files / themed_print-0.1.3-py3-none-any.whl
| Download URL | themed_print-0.1.3-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1857cef1949090f69b12e33c6b923527b26290dfe35bad7ede8c28ddbed4de65
|
|
BLAKE2b-256 checksum How to use checksums |
025ea9f2a1df22d484053c388629ea14a839e18d9b8158eec4709ef10a63f9cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for themed-print 0.1.3
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.