Skip to main content

A library for handling ANSI codes

Project description

AnsiLib

AnsiLib is a Python module for handling text style and color shortcuts from ANSI escape codes.

Author: Bora Boyacıoğlu

Installation

To install AnsiLib, use pip:

pip install ansilib

If you are running Python 3.7 or below, you also need to install typing_extensions, which comes as a dependency.

Usage

import AnsiLib as al

You can use the quick styles and colors to simply format your text.

print(al.s("This text is bold."))
print(al.r("This text is red."))
print(al.u(al.b("This text is underlined and blue.")))

Also you can reach all of the colors using al.c class.

print(al.c.t.r("This text is red."))
print(al.c.b.c("This text has cyan background."))
print(al.c.t.g_("This text is bright green."))

To define styles, use al.style() function.

sty1 = al.style('bold', 'r', 'kb1')
print(sty1("This text is bold, red and has a background color of bright black."))

Get the complete list of styles and colors with al.available().

print(al.available())

Create an RGB color using al.color() function.

my_color = al.color(56, 12, 74)
sty2 = al.style('x', 'italic', my_color)
print(sty2("This text is italic, crossed and has an RGB color of (56, 12, 74)."))

Finally, you can use the AnsiLib's prints() function to print a styled text.

al.prints("This text is bold, red and has a background color of bright black.", s=['bold', 'r', 'kb1'])

Contributions

I welcome contributions and suggestions to the AnsiLib Python library! Contact me about the details.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

ansilib-1.0.3.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

ansilib-1.0.3-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file ansilib-1.0.3.tar.gz.

File metadata

  • Download URL: ansilib-1.0.3.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for ansilib-1.0.3.tar.gz
Algorithm Hash digest
SHA256 a8e82b0b2ba2c101da18eacf387ffaf11be3b6b147e507cac0cd4a9cef090478
MD5 d119832a2f4bc1c73c2453803887692d
BLAKE2b-256 4221b0ede2801aec965af793f66e056235a1efb13e331af657b538ba4a23ba25

See more details on using hashes here.

File details

Details for the file ansilib-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: ansilib-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for ansilib-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ab683eaa61f0f2285238cece25c404aaf78584c58747a89abf8dfb6bc1ec11a1
MD5 61b36228842205f5cbed23573abc4c8a
BLAKE2b-256 7cb43af4556083380db76598d26cca1f07c001c6a3a036e2fa0858d58f26725c

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