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]
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file SwaANSI-pkg-swajime-0.1.0.tar.gz.
File metadata
- Download URL: SwaANSI-pkg-swajime-0.1.0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d8401d64505fe2192dea1d6a0bbc08aac85198bfbfae2357af5e854349ba322
|
|
| MD5 |
72a7eb3faa6e655224065318882fe8b5
|
|
| BLAKE2b-256 |
4356c9bd94ff631fb4bb2d7777a6b485a5a39d31479a43e66efd4c50cbf5cdf0
|
File details
Details for the file SwaANSI_pkg_swajime-0.1.0-py3-none-any.whl.
File metadata
- Download URL: SwaANSI_pkg_swajime-0.1.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6f29b3ecbe89a3774abb96d62ff007781fc6550faa33ba3f98c784db8f6e449
|
|
| MD5 |
030f16180ee63c314c35869c3f12cf9a
|
|
| BLAKE2b-256 |
90305cd9484b699517cf94be0df74aabec2d6e1928228128728479505d186faf
|