Skip to main content

Package for highlighting output text on terminal, and converting hex and rgb colors to xterm colors.

Project description

Termilighter

Support by giving stars :star: on github - Follow for more.

A small module that allows you to customize print statements or output text with different colors. You can use any color type from the following xterm, rgb, and hexa to select a color for your output text.

Requirements:

  1. Python version >= 3

Dependencies

This project has no dependencies till now and can be used with windows, and Linux operating system.

Installation

You can install it by running following command on your terminal.

pip install termilighter

Usage

To use this package, import log method from termilighter inside your required python script .

from termilighter import log

Now, you can use log to output colored text on terminal.

Example - 01: Default Message
Input
from termilighter import log
log.message(text="Message with custom foreground color.")
Output
default
Example - 02: Message with Custom Foreground Color
Input
log.message(
    text="Message with custom foreground color.", color_type="hex", fg="#2a9d8f"
)
Output
custom-fg
Example - 03: Message with Custom Background Color
Input
log.message(
    text="\nMessage with custom background color.", color_type="hex", bg="#d9ed92"
)
Output
custom-bg
Example - 05: Message with Custom Foreground & Background Color
Input
log.message(
    text="\nMessage with custom foreground and background color.",
    color_type="hex",
    fg="#dd6e42",
    bg="#eff7f6",
)
Output
custom-bg-fg
Example - 06: Message with Prefix and Custom Tag
Input
log.message(text="Message with Prefix and custom-tag.", prefix=True, tag="custom-tag")
Output
custom-tag
Example - 07: Message with Prefix, Custom Tag and Custom tag-color
Input
log.message(
    text="Message with Prefix, custom-tag and custom tag color.",
    prefix=True,
    tag="custom-tag",
    dc=49,
)
Output:

Available Features

I build this module with flexibility to select any color type between xterm bit integer, rgb color tuple and hexa color code. You can use any color type to customize the output text on your terminal. There are some default methods as well which you can directly use to output respective text. Those methods are as follow;

  1. log.message() - You can put any string inside the curly brackets to display your text on the terminal. Default color is put color.
  2. log.error() - You can use this method to output ERROR on your terminal.
  3. log.warning() - You can use this method to output WARNING on your terminal.
  4. log.success() - You can use this method to output SUCCESS status on your terminal.
  5. log.info() - You can use this method to output any kind of important INFO on your terminal.
  6. log.highlight() - If you want to highlight any specific part in your print statement then, you can use this method inside the f-string or .format option of print statement.

Common Options:

  1. text - Can provide any string value. Default: None.

  2. color_type - Can provide any color type from xterm , rgb and hexa . Default: xterm

  3. fg - Can provide any foreground color with respect to its color type. For Example:

    • For xterm - you can provide any integer between 1 and 255
    • For rgb - You can provide rgb tuple (r, g, b).
    • For hexa - You can provide HEX color code #000000
  4. bg - Same as foreground color you can provide any value with respective to color_type argument.

  5. prefix - Can be used in special method like log.error() - Prefix = True will display [ ERROR ] prefix at start of your output text. Default: False.

  6. tag - Can customize prefix tag as well. Default: None.

  7. dc - Default color to pass an argument to a method or it can be used to set the color for your prefix tag.


Other features

  1. rgb_to_hex(rgb:tuple=(0, 0, 0))
  2. hex_to_rgb(hex:str = "#000000")
  3. rgb_to_xterm(rgb:tuple=(0, 0, 0), val = False)
  4. hexa_to_xterm(hex:str = "#000000" val_ = False)
  5. custom_color_from_rgb(fg=None, bg=None)
  6. custom_color_from_hex(fg=None, bg=None)
  7. custom_color_from_xterm(fg=None, bg=None)

Contributing

If you any suggestion to improve this package, feel free to create issues on github. Just create PR

Support by giving stars :star: on github - Follow for more.

Credits

Build with Love :heart:.

Contributors

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

termilighter-0.0.2.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

termilighter-0.0.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: termilighter-0.0.2.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for termilighter-0.0.2.tar.gz
Algorithm Hash digest
SHA256 72152bf6bbc111146192b1c98d2b06d8a335c5103bdfa16922063c1254199800
MD5 61834de63d51ae63ff389a021497b53d
BLAKE2b-256 6e7be2196ddb29a88685b2c0705933427a2aa1698057ebb2bcf079bc2eb74dac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: termilighter-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for termilighter-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9f0998dd4dfee6d50ad766f7055e3254f57f7166f3d065e18a53e86eade11af0
MD5 a1f33d86bb0acbe50f38fd462ddcac1a
BLAKE2b-256 bcc55cd798ff91b4b1406c35ffdc27eff202a961780506d256a21c46fa253f4d

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