Skip to main content

Enable wrapping text with color and attributes.

Project description

SwaANSI

  • Tested on: os: [ubuntu-16.04, ubuntu-latest, macos-latest, windows-latest]
  • Tested on: python-version: [2.7, 3.5, 3.6, 3.7, 3.8, pypy2, pypy3]

Python package

Enable wrapping text with color and attributes per ANSI escape sequences.

ANSI wrapper for text strings

This class allows the user to wrap strings with ansi color escape sequences without the user having to know how they work.

Examples follow:

Note that not all styles work on all terminals. Also note that some styles do not mix well with colors.

To see colors available, view SwaANSI.colors

from swajime import SwaANSI
print(SwaANSI.colors)
for color in sorted(SwaANSI.colors): print(SwaANSI.wrap(color, color))

To see styles available, view SwaANSI.styles

from swajime import SwaANSI
print(SwaANSI.styles)
for style in sorted(SwaANSI.styles): print(SwaANSI.wrap(style, None, None, style))

The class can be accessed without instances:

from swajime import SwaANSI
print(SwaANSI.wrap('This is red text', 'Red', 'Yellow', 'Bold', 'Underline', 'Strikethrough'))

Or you can create different objects with different attributes:

from swajime import SwaANSI
greenSuccess = SwaANSI('Green', None, 'Bold')
yellowWarning = SwaANSI('Yellow', None, 'Underline')
redError = SwaANSI('Red', None, 'Double Underline')

print(greenSuccess.wrap('This is a green success'))
print(yellowWarning.wrap('This is a yellow warning'))
print(redError.wrap('This is a red error'))

Please report any bugs or issues to john@swajime.com

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

SwaANSI-pkg-swajime-0.1.1.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

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

SwaANSI_pkg_swajime-0.1.1-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file SwaANSI-pkg-swajime-0.1.1.tar.gz.

File metadata

  • Download URL: SwaANSI-pkg-swajime-0.1.1.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for SwaANSI-pkg-swajime-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0e73d82927c104a249e5474dec0b3d2ccae6383059e75b7e8ae80fa2656b8b9f
MD5 63c51222530dd273ac03f3be199d253e
BLAKE2b-256 f6754843314127b5a6d74c5f321e31004b376f78846a4d4a1d2ef006adb035ba

See more details on using hashes here.

File details

Details for the file SwaANSI_pkg_swajime-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: SwaANSI_pkg_swajime-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for SwaANSI_pkg_swajime-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f492ff3ca822ccc14ff3bd633af52f4e42c07b52a8b2e77e3ab12c03c7df9a37
MD5 530ccb1cdb8e977187e31de8f46a22ba
BLAKE2b-256 adc2ec5ee9d43ea6596af1e32bebcd9641c5121054e47622a9b1d611aa2d5675

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