VividHues: Super light Python string formatter!
Project description
VividHues :rainbow: :package:
VividHues: Super light Python string formatter! 🌈 📦
:hammer_and_wrench: Official Installation
:zap: Instant Installer + Updater
:page_with_curl: 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)
:memo: Note!
This requires Bash to be installed on your OS. Git Bash or WSL are two of many to pick from!
:cyclone: Replit Installation
👉 Replit installation instructions in here! 👈
- Upload the installer script to your project's file system
- Run
bash install_vividhues.sh
in the shell
:shell: Manual Shell Installation
👉 Manual installation instructions in here! 👈
Pop this command in your CLI/shell/terminal to install VividHues.
$ pip install VividHues
:bulb: Tip
Use this command to update
pip install --upgrade VividHues
:ship: Importing
Stick this wherever you need VividHues!
from VividHues import Clr
:bricks: 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
:whale: (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
:snake: 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))
:warning: Preventing Color Leakage!
What is color leakage??? :thinking:
:point_right: Color leakage is when you have forgotten to use Clr.RS
/Clr.RESET
:point_left: 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
:memo: 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? :tada:
:a: End print() with Clr.RS/Clr.RESET — Short 'n' Sweet! :candy:
print(... + Clr.RS) # recommended!
print(..., Clr.RS)
print(..., end=Clr.RS+"\n")
:b: Format chunks of code — Highly Recommended! :thumbsup:
# 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="")
:bulb: Tip!
These solutions also prevent the leakage of other formatting
(e.g.
Clr.BO
,Clr.BOLD
,Clr.UL
,Clr.UNDERLINE
)
:rainbow: 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
:memo: Note!
In order to make your life easy, when reading the documentation,
Your import statement should be the following... :point_down:
from VividHues import Clr
so that you can useClr.___
:wastebasket: 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_wand: Magic Functions!!!
:bulb: TIP!
Magic Functions do not leak color (as of
VividHues>=5.3.0
)
:game_die: Clr.random()
print( Clr.random(string) )Paints your string in a random Clr code.
:saxophone: Clr.jazzy()
print( Clr.jazzy(string) )Paints each letter in jazzy random colors! It's a total gamble, that's guaranteed to be ugly! :)
:rainbow: Clr.rainbow()
print( Clr.rainbow(string) )Paints your string in a rainbow pattern.
:test_tube: Clr.pattern()
print( Clr.pattern(string, *color) )Paint your letters in a repeating pattern, by specifying an unlimited amount of Clr codes!
:muscle: How VividHues stacks up...
Feature | VividHues | Colorama | termcolor |
---|---|---|---|
Simplicity/Abstraction | :star: | :star: | :star: |
Font Colors | :star: | :star: | :star: |
Background/Highlight | :crossed_fingers: | :star: | :star: |
Bold/Underline | :star: | :star: | |
Most Lightweight | :star: | ||
Auto-Reset | :star: | :star: | :star: |
Cursor Positioning | :star: | ||
Special/Unique Features | :star: | :star: | |
Total | 6/8 | 5/8 | 6/8 |
Potentially, VividHues will have more features than the alternatives if they are implemented.
:mag_right: Getting Package Info
import VividHues # different import this time!
print(VividHues.__author__)
# Kenneth Oliver ©2022
print(VividHues.__desc__)
# Super lite package for colored strings in Python! 🌈 📦
print(VividHues.__homepage__)
# https://github.com/KennyOliver/VividHues
print(VividHues.__package__)
# VividHues
print(VividHues.__pypi__)
# https://pypi.org/project/VividHues/
print(VividHues.__name__)
# VividHues
Kenny Oliver ©2021
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
File details
Details for the file VividHues-5.6.18.tar.gz
.
File metadata
- Download URL: VividHues-5.6.18.tar.gz
- Upload date:
- Size: 19.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 080dd900ad14012590a0f61893cb2c3dcc2710875c4b96749226e2e672916d7f |
|
MD5 | 658c23d80bb202bd72e1367a93bffc0d |
|
BLAKE2b-256 | 8f5681ee2129ffdfe47170ffdf3769278978aaeeb55d93bf41a88b1fb0dfd173 |
File details
Details for the file VividHues-5.6.18-py3-none-any.whl
.
File metadata
- Download URL: VividHues-5.6.18-py3-none-any.whl
- Upload date:
- Size: 18.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | adafa10d9e695982a1b6efc0a982b16ce1aca640a539be3ec29f19a21794307b |
|
MD5 | 4a66b5cc0683f87da01938f48696b5d4 |
|
BLAKE2b-256 | acd010437cbe4bd7aec0b7535b59161822ad726ca2d3060d48e66dac8556838e |