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:
- 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
Example - 02: Message with Custom Foreground Color
Input
log.message(
text="Message with custom foreground color.", color_type="hex", fg="#2a9d8f"
)
Output
Example - 03: Message with Custom Background Color
Input
log.message(
text="\nMessage with custom background color.", color_type="hex", bg="#d9ed92"
)
Output
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
Example - 06: Message with Prefix and Custom Tag
Input
log.message(text="Message with Prefix and custom-tag.", prefix=True, tag="custom-tag")
Output
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;
log.message()- You can put any string inside the curly brackets to display your text on the terminal. Default color isput color.log.error()- You can use this method to outputERRORon your terminal.log.warning()- You can use this method to outputWARNINGon your terminal.log.success()- You can use this method to outputSUCCESSstatus on your terminal.log.info()- You can use this method to output any kind of importantINFOon your terminal.log.highlight()- If you want to highlight any specific part in your print statement then, you can use this method inside thef-stringor.formatoption of print statement.
Common Options:
-
text- Can provide any string value. Default:None. -
color_type- Can provide any color type fromxterm,rgbandhexa. Default:xterm -
fg- Can provide any foreground color with respect to its color type. For Example:- For
xterm- you can provide any integer between1 and 255 - For
rgb- You can providergbtuple(r, g, b). - For
hexa- You can provide HEX color code#000000
- For
-
bg- Same as foreground color you can provide any value with respective tocolor_typeargument. -
prefix- Can be used in special method likelog.error()- Prefix =Truewill display[ ERROR ]prefix at start of your output text. Default:False. -
tag- Can customize prefix tag as well. Default:None. -
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
rgb_to_hex(rgb:tuple=(0, 0, 0))hex_to_rgb(hex:str = "#000000")rgb_to_xterm(rgb:tuple=(0, 0, 0), val = False)hexa_to_xterm(hex:str = "#000000" val_ = False)custom_color_from_rgb(fg=None, bg=None)custom_color_from_hex(fg=None, bg=None)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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72152bf6bbc111146192b1c98d2b06d8a335c5103bdfa16922063c1254199800
|
|
| MD5 |
61834de63d51ae63ff389a021497b53d
|
|
| BLAKE2b-256 |
6e7be2196ddb29a88685b2c0705933427a2aa1698057ebb2bcf079bc2eb74dac
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f0998dd4dfee6d50ad766f7055e3254f57f7166f3d065e18a53e86eade11af0
|
|
| MD5 |
a1f33d86bb0acbe50f38fd462ddcac1a
|
|
| BLAKE2b-256 |
bcc55cd798ff91b4b1406c35ffdc27eff202a961780506d256a21c46fa253f4d
|