TextFormat
TextFormat is a lightweight Python module for ANSI text formatting, customizable word art, and table rendering in CLI applications.
Features
- ANSI Colors & Styles – Easily format text using intuitive color mappings.
- Customizable Word Art – Generate banners with adjustable characters and widths.
- Table Formatting – Display structured data in a clean, readable format.
Installation
Install via PyPI:
pip install textfmt
Usage
Basic Text Formatting
from textformat import TextFormat
print(TextFormat.style("Hello, World!", TextFormat.BOLD, TextFormat.COLORS["blue"]))
Custom Word Art Banner
from textformat.word_art import WordArt
print(WordArt.banner("TEXTFORMAT", char="*", width=40))
Table Rendering
from textformat.table import TableFormatter
headers = ["Feature", "Color", "Effect"]
data = [
["Bold", "White", "Strong emphasis"],
["Underline", "Blue", "Text decoration"],
["Warning", "Yellow", "Cautionary message"],
]
print(TableFormatter.generate(headers, data))
File Download Progress Bars
from textformat.progress import Color, DownloadProgressBar
from pathlib import Path
def download_with_progress(url: str, output_path: Path, download_color, complete_color):
response = requests.get(url, stream=True)
total = int(response.headers.get('content-length', 0))
if response.status_code != 200:
raise Exception(f"Failed to download from {url}. HTTP status: {response.status_code}")
progress = DownloadProgressBar(total, prefix=output_path.name,
download_color=download_color, complete_color=complete_color)
with open(output_path, "wb") as f:
for chunk in response.iter_content(chunk_size=8192):
if chunk:
f.write(chunk)
progress.update(progress.downloaded + len(chunk))
print()
download_with_progress('https://huggingface.co/sharktide/recyclebot0/resolve/main/tf_model.h5', Path("tf_model.h5"), Colors.CYAN, Colors.GREEN)
License
MIT License – Free to use and modify.
Metadata
Release files for textfmt 0.2.1
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 |
|---|---|---|---|---|
| textfmt-0.2.1.tar.gz | 5.2 kB | Without provenance | Details for textfmt-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| textfmt-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for textfmt-0.2.1-py3-none-any.whl |
Total release size: 11.6 kB
Release files / textfmt-0.2.1.tar.gz
| Download URL | textfmt-0.2.1.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
69cb9b32257e8dad487cb971dca825f90ead954382575808b429a05ae68b5247
|
|
BLAKE2b-256 checksum How to use checksums |
bf9b1e7bec956944e569c79b7f55d72689b7f57b1541513beaf74c6c82e79b9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.5
|
Release files / textfmt-0.2.1-py3-none-any.whl
| Download URL | textfmt-0.2.1-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e2d68a089a8d9b9d34423a93702efe38ff2c3113673e652d270fefaf5140b34a
|
|
BLAKE2b-256 checksum How to use checksums |
5ad199584a76ae8a0f169612be0f491d3b0a6366be4227aa9123c4001ef826a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.5
|
Security for textfmt 0.2.1
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.