Skip to main content

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)

Source distribution for textfmt 0.2.1
File Size Uploaded
textfmt-0.2.1.tar.gz 5.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for textfmt 0.2.1
File Interpreter ABI Platform
textfmt-0.2.1-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page