Skip to main content

Lightweight package to print colorized messages using ASCI escape sequences to the terminal.

Project description

terminalcolorpy

A lightweight, dependency-free package to colorize your terminal text.

Overview

This is a package that utilizes ANSI escape sequences to colorize your stdout, terminal, printed messages and what not. The key-features include,

  • Fully tested with pytest
  • Fully documented & type-hinted
  • Dependency-free

Installation

The required Python version for this module is 3.10 or above

# Linux/MacOS
python3 -m pip install terminalcolorpy

# Windows
py -m pip install terminalcolorpy

Usage

The package consists of a few functions which are explained down below. In case your terminal (which is common with Windows) doesn't display the color at all, please run the following code,

import os

os.system('')

# your code onwards




flip_text(text: str) -> str:

->  Flip text to characters that are upsidedown version of that letter.



prainbow(text: str) -> str:

->  Returns text in colors of the rainbow (RGB 1-255, not CSPRNG).



blink(message: str, length: float = 1, new_message: str = " ") -> None:

->  Print the message then replace it with a new message.


    Beware, this function is **blocking** because of the print statement. If you need to run this function
    synchronously, please refer to the accepted answer of this S/O question,
    https://stackoverflow.com/questions/54685210/calling-sync-functions-from-async-function

    Args:
        message (str): message to be printed
        length (float): how long should the message stay
        new_message (str): message to be displayed after the timer expires (default is nothing)



printcolor(colored_kwargs: dict = None, **kwargs) -> None:

->  Implements a shortcut for using the builtin function print with this modules colored function.

    Args:
        colored_kwargs (dict): keyword arguments for this modules colored function
        **kwargs: keyword arguments for the builtin print function



def colored(
    text: str,
    color: list | tuple | str,
    highlight: list | tuple | str | None = None,
    markup: list | tuple | None = None,
) -> str:
->  Parse color arguments and return the applied version to the text.

    Args:
        text (str): text to parse
        color (Union[list, tuple, str]): color for the text, accepts RGB, hex (str) and English words
        highlight ([list, tuple, str]): highlight for the text, accepts RGB, hex (str) and English words
        markup ([list, tuple]): markup from _Colors.color_dict

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

terminalcolorpy-1.0.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

terminalcolorpy-1.0.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file terminalcolorpy-1.0.0.tar.gz.

File metadata

  • Download URL: terminalcolorpy-1.0.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for terminalcolorpy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 191848866bd05bf9c2b44a3c7cae6e947221c77e876f8c4656a9660a980a551f
MD5 141b12ed0e6c1f8daf3ea6ac5c1cb566
BLAKE2b-256 fb0c13f5e5ac58a94ab16efe6c9da71e81b5f5502a2ccc5387745b481e97dd47

See more details on using hashes here.

File details

Details for the file terminalcolorpy-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for terminalcolorpy-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9787a1506ea2894fd5f3510fb7b8c2a886a96d092f4745da570be30d42d456c7
MD5 86fbfaeeffc80af9e491b2e73ba6c185
BLAKE2b-256 ae720575482428a10fd9ef66c581fb40ebf3d29456796801a6a600dd306b9816

See more details on using hashes here.

Supported by

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