Skip to main content

A lightweight pure python library for applying color and HTML text styles to the strings

Project description

https://api.codacy.com/project/badge/Grade/5384da344156447daa23f588fc8fbae6

Python colorizing strings library

A lightweight library for applying color and HTML text styles to the strings that uses the builder pattern for configuration. The ezcolor lets you have nice colorized output with extra HTML text styles like bold/italic/underline. compatible with bash/sh/zsh.

Features

  • A simple to use API

  • lightweight and written in pure python

  • Tested on python 3.6+ (not compatible with python2.x)

  • Not compatible with windows OS (command prompt, powershell)

Usage

$ pip install ezcolor
from ezcolor import Style
style = Style()
cp = style.add.foreground('green').apply()
cp('hello world')
https://github.com/0x0ptim0us/images/raw/master/ezcolor_simple_output.png

Adding more attributes

cp = style.add.foreground('green').background('dark_gray').bold.italic.underline.apply()
cp('hello world')
https://github.com/0x0ptim0us/images/raw/master/ezcolor_more_attribute.png

Adding prefix for beautiful logging

cp = style.add.foreground('green').prefix('done').bold.italic.apply()
cp('Job is done!')
cp_error = style.add.foreground('red').prefix('error').bold.italic.apply()
cp_error('Error occurred!')
https://github.com/0x0ptim0us/images/raw/master/ezcolor_prefix_done.png https://github.com/0x0ptim0us/images/raw/master/ezcolor_prefix_error.png

Use as decorator

@cp.decorate
def my_name(name, lastname):
    return f"my name is {name} {lastname}"

print(my_name('Fardin', 'Allahverdinazhand'))
Supported colors and prefix (log level)

Color

prefix

black

done

red

info

green

warning

yellow

error

blue

magenta

cyan

light_gray

dark_gray

light_red

light_green

light_yellow

light_blue

light_magenta

light_cyan

white

Meta

Fardin Allahverdinazhand - @0x0ptim0us - 0x0ptim0us@gmail.com Distributed under the MIT license. see LICENSE.txt for more information.

https://github.com/0x0ptim0us/ezcolor

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

ezcolor-0.7.tar.gz (3.4 kB view details)

Uploaded Source

File details

Details for the file ezcolor-0.7.tar.gz.

File metadata

  • Download URL: ezcolor-0.7.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.6

File hashes

Hashes for ezcolor-0.7.tar.gz
Algorithm Hash digest
SHA256 f7a5d26ff8d75b765bf4622385f0d287541edf1c490eefbd1631f0b9e801253f
MD5 16248f574efc970a14e2a868915004d3
BLAKE2b-256 46112f1cae292c09df309c5cb18bbb9751758507f20b384121bd562863b0f614

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