Skip to main content

ANSI escape code formatter

Project description

afmt

This module provides an easy way to format text in CLI environment. It is designed for use in f-strings but regular string formatting with format method is also supported.

The module takes care of stripping ANSI escape sequences from piped output and puts the sequences only if they're supported by the output device.

Setup

$ pip install afmt

Usage and examples

from afmt import Formatter

f = Formatter()
warning = 'bold bg(yellow) fg(black) italic'
error = 'bold bg(red) fg(white) underline'
print(f'{f:{warning}}Warning: you shouldn\'t do it{f:e}')
print(f'{f:{error}}Error: you can\'t do it{f:e}')


# Move cursor to 4th row and 6th column and print text in reverse video mode 
print(f'{f:reverse goto(4,6)}hello, world{f:e}')

asciicast

Development status

This module is in the early stage of development. More features are coming hopefully soon.

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

afmt-0.0.2.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

afmt-0.0.2-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file afmt-0.0.2.tar.gz.

File metadata

  • Download URL: afmt-0.0.2.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for afmt-0.0.2.tar.gz
Algorithm Hash digest
SHA256 3958aaae9d01ac1bbbddfd3a02587c5583fddf95d8c65bc2bd22275f1f77efd0
MD5 cfee9a2686c781e0763f4b7de3849b51
BLAKE2b-256 73c87eed48b124124bd9723beed08eec103fc15078641e414ca04549dbfe5dcf

See more details on using hashes here.

File details

Details for the file afmt-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: afmt-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for afmt-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 848ac8b4cf000cfb1a8089a7a4a0cee2ce03d04f9cf8ed5ae4065bb7bdd9cc74
MD5 2b1588fa0a0ba635da62c5715b9e47ef
BLAKE2b-256 3575741187eb2d144f10df1b798a8c2e4b9be330f3032cd7fc97e0e604fb9fa6

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