Skip to main content

A package for formatting text in terminal using ANSI in Python

Project description

ANSI Formatter - Python Package

Description: A lightweight Python package for text formatting using ANSI escape codes. Provides colored text, text styles, and basic terminal control.

Installation: pip install ansiformatter

Basic Usage: from ansiformatter import ANSIFormatter, RED, BOLD

f = ANSIFormatter() print(f.format("Error", RED, BOLD)) print(f.red("Red text")) print(f.bold("Bold text"))

Available Styles: Text styles: BOLD, DIM, ITALIC, UNDERLINE, BLINK, REVERSE, HIDDEN, RESET Text colors: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE Background colors: BG_BLACK, BG_RED, BG_GREEN, BG_YELLOW, BG_BLUE, BG_MAGENTA, BG_CYAN, BG_WHITE

Examples:

Colorful output

print(f.red("Error: ") + f.yellow("Warning"))

Status message

status = f.green("✓ Success") if success else f.red("✗ Failed")

Combined styles

print(f.format("Important", BOLD, UNDERLINE))

Utilities: from ansiformatter import is_ansi_supported, strip_ansi_codes

Check ANSI support

if is_ansi_supported(): print(f.green("Terminal supports ANSI"))

Remove ANSI codes

clean_text = strip_ansi_codes(formatted_text)

Notes:

  1. Not all terminals support all ANSI features
  2. For Windows, may need to enable ANSI support
  3. Basic 8-color system only

License: MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ansiformatter-0.1.0.tar.gz (183.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ansiformatter-0.1.0-cp312-cp312-manylinux2014_aarch64.whl (196.8 kB view details)

Uploaded CPython 3.12

File details

Details for the file ansiformatter-0.1.0.tar.gz.

File metadata

  • Download URL: ansiformatter-0.1.0.tar.gz
  • Upload date:
  • Size: 183.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for ansiformatter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6c4d04f48aff14866b61667e615d3c64d94fb9132ac7bff294a2a2626d0456c7
MD5 d046615184a28f92b3ff850b3d9ca238
BLAKE2b-256 8b61784aa507cf11ca2afa8a9ca420fd3a77840baa21d1ba610b69b742ea9fd3

See more details on using hashes here.

File details

Details for the file ansiformatter-0.1.0-cp312-cp312-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ansiformatter-0.1.0-cp312-cp312-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 af4258c0c0a4ccc35a2749b67484c3ed212c42bd2914dfcd2a9eaf6b09c42d30
MD5 a5a73ff4b0519b06b47897fae91b0ae8
BLAKE2b-256 a6904d777a3329c7c90828986365edd4d306e9959ff92b383f3a1db6f25090b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page