VividHues: Super light Python string formatter!


Keywords
color-formatting, colorama, foss, maintained, module, open-source, oss, package, pypi-package, python, python-console, python3, replit, simple, termcolor, vividhues
License
AGPL-3.0
Install
pip install VividHues==5.9.2

Documentation

VividHues ๐ŸŒˆ ๐Ÿ“ฆ

Build Passing Status CodeFactor License
Latest SemVer Total Lines Repo Size Code Size
Downloads Downloads Downloads

VividHues: ย ย ย  Super light Python string formatter! ย  ๐ŸŒˆ ๐Ÿ“ฆ

ย  ๐Ÿ‘‰ ย  ย  ๐Ÿ‘ˆ


๐Ÿ› ๏ธ Official Installation

โšก Instant Installer + Updater

ย  ๐Ÿ‘‰ ย  ย  ๐Ÿ‘ˆ

๐Ÿ“ƒ Instant Installer ย  โ€” ย  Instructions

Once you've downloaded install_vividhues.sh...
Run the command bash install_vividhues.sh in your shell/CLI
(Or... double click the install_vividhues.sh file)

๐Ÿ“ Note!

This requires Bash to be installed on your OS. Git Bash or WSL are two of many to pick from!

๐ŸŒ€ Replit Installation

๐Ÿ‘‰ Replit installation instructions in here! ๐Ÿ‘ˆ
  1. Upload the installer script to your project's file system
  1. Run bash install_vividhues.sh in the shell

๐Ÿš Manual Shell Installation

๐Ÿ‘‰ Manual installation instructions in here! ๐Ÿ‘ˆ
Pop this command in your CLI/shell/terminal to install VividHues.
$ pip install VividHues

๐Ÿ’ก Tip

Use this command to update
pip install --upgrade VividHues

๐Ÿšข Importing

Stick this wherever you need VividHues!
from VividHues import Clr

๐Ÿงฑ Dependency

requirements.txt (Highly Recommended!)

Append the following to your Python packages requirements.txt...
VividHues>=5.3.0
Changelog:
VividHues>=3.0.0    #  basics: only has Clr codes
VividHues>=4.1.0    #  new: abbreviations & "Magic Functions"
VividHues>=5.2.0    #  Magic Function: Clr.pattern()
VividHues>=5.3.0    #  all Magic Functions no longer leak color
VividHues>=5.4.0    #  Clr.delPrevLine()

.github/Dependabot.yml (optional, but needs requirements.txt)

First, if you don't already have a .github directory, create one.
Then, add a Dependabot.yml file to it.
version: 2
updates:
  - package-ecosystem: "pip"
    directory: "/"
    schedule:
      interval: "daily"

Dockerfile ๐Ÿณ (optional)

You can use this if you have a Docker container.
# recommended
COPY requirements.txt .
RUN pip install -r requirements.txt
# alternatively...
RUN pip install VividHues

๐Ÿ Python Example

print(Clr.BO + Clr.UL + Clr.rainbow('I love VividHues!'))
print(Clr.RED + "It's got my fave color!" + Clr.RS)
print(f"Soooo {Clr.jazzy('jazzy')}")
#                          ^^^
# you'll get an error using "" in f-string interpolations
print(Clr.pattern("Kenny Oliver", Clr.PURPLE, Clr.CYAN, Clr.LIME))

โš ๏ธ Preventing Color Leakage!

What is color leakage??? ๐Ÿค”

๐Ÿ‘‰ Color leakage is when you have forgotten to use Clr.RS/Clr.RESET ๐Ÿ‘ˆ to reset the formatting after the last character printed to the standard output!

It results in any trailing characters, in the output stream, to continue to have the same formatting.

This is an intentional feature, because it allows for the formatting of entire chunks of code in one go. See the example

๐Ÿ“ Note!

As of VividHues>=5.3.0, ALL magic functions do not leak color.

Previously, it was only Clr.random()!

How do I prevent/solve this? ๐ŸŽ‰

๐Ÿ…ฐ๏ธ End print() with Clr.RS/Clr.RESET ย  โ€” ย  Short 'n' Sweet! ๐Ÿฌ

print(... + Clr.RS)  # recommended!

print(..., Clr.RS)

print(..., end=Clr.RS+"\n")

๐Ÿ…ฑ๏ธ Format chunks of code ย  โ€” ย  Highly Recommended! ๐Ÿ‘

# start formatting here
print(Clr.BOLD + Clr.RED, end="")


if something:
  print(Clr.BLUE + "blah blah blah" + Clr.RS)
else:
  for x in range(100):
    # lots of print statements


# end formatting here
print(Clr.RS, end="")

๐Ÿ’ก Tip!

These solutions also prevent the leakage of other formatting

(e.g. Clr.BO, Clr.BOLD, Clr.UL, Clr.UNDERLINE)


๐ŸŒˆ Available Clr codes:

Just put a code in the gap Clr.___

Clr: ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  RED, ORANGE, YELLOW, LIME, GREEN, BLUE, CYAN, PURPLE, PINK, BLACK, WHITE
Formatter: ย ย ย ย  UNDERLINE, UL, BOLD, BO
Reset: ย ย ย ย ย ย ย ย ย ย ย  RESET, RS
๐Ÿ“ Note!
In order to make your life easy, when reading the documentation,
Your import statement should be the following... ๐Ÿ‘‡

from VividHues import Clr so that you can use Clr.___


๐Ÿ—‘๏ธ Erasing the previous line

VividHues provides you with a quick way to erase the last line of the CLI!

# Delete the last printed line of the CLI
Clr.delPrevLine()
# Delete the last  5  printed lines
Clr.delPrevLine(5)

๐Ÿช„ Magic Functions!!!

๐Ÿ’ก TIP!
Magic Functions do not leak color (as of VividHues>=5.3.0)

๐ŸŽฒ Clr.random()

print(  Clr.random(string)  )
Paints your string in a random Clr code.

๐ŸŽท Clr.jazzy()

print(  Clr.jazzy(string)  )
Paints each letter in jazzy random colors! It's a total gamble, that's guaranteed to be ugly! :)

๐ŸŒˆ Clr.rainbow()

print(  Clr.rainbow(string)  )
Paints your string in a rainbow pattern.

๐Ÿงช Clr.pattern()

print(  Clr.pattern(string, *color)  )
Paint your letters in a repeating pattern, by specifying an unlimited amount of Clr codes!

๐Ÿ’ช How VividHues stacks up...

Feature VividHues Colorama termcolor
Simplicity/Abstraction โญ โญ โญ
Font Colors โญ โญ โญ
Background/Highlight ๐Ÿคž โญ โญ
Bold/Underline โญ โญ
Most Lightweight โญ
Auto-Reset โญ โญ โญ
Cursor Positioning โญ
Special/Unique Features โญ โญ
Total 6/8 5/8 6/8

Potentially, VividHues will have more features than the alternatives if they are implemented.


๐Ÿ”Ž Getting Package Info

VividHues comes with a variety of 'dunder' values that you can check out.

An important example is checking out the current version: VividHues.__version__

๐Ÿ“ Note!
The import is different this time!
import VividHues

Dunders Command

You can use this command to find out all the possible dunders.

VividHues.dunders()

Dunder Values

dunder what it does expected output
__author__ author "Kenneth Oliver ยฉ2022"
__desc__ description "Super light Python string formatter! ๐ŸŒˆ ๐Ÿ“ฆ"
__homepage__ GitHub URL "https://github.com/KennyOliver/VividHues"
__package__ package name "VividHues"
__pypi__ Pypi URL "https://pypi.org/project/VividHues/"
__version__ current version (whatever the current version is!)

Kenny Oliver ยฉ2022