Skip to main content

Color printing in python

Project description

CircleCI

codecov

A Light-weight python package for terminal output in color

Overview

Chalk allows you to print to your terminal in color. It also provides a simple logging handler and formatter for a more informative logging experience. Why print in black and white?

Installation

pip install pychalk

Usage

from __future__ import print_function
import chalk

print(chalk.red('foo'))
import chalk

white = chalk.Chalk('white')
white('foo', bold=True, underline=True)
# returns '\x1b[37;1;4mfoo\x1b[0m'

bold_white = white + chalk.utils.FontFormat('bold')
bold_white('foo')
# returns '\x1b[37;1mfoo\x1b[0m'

bold_white + 'foo'
# returns '\x1b[37;1mfoo'

bold_white + 'foo' + chalk.RESET
# returns '\x1b[37;1mfoo/x1b[0m'

Testing

Install pyenv

curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
pyenv install -s -v 2.7.14 \
&& pyenv install -s -v 3.5.4 \
&& pyenv install -s -v 3.6.3

Then install the development requirements… To help with this please use:

./bin/install

Then run the tests using tox.

source venv/bin/activate
tox
py27 develop-inst-noop: /home/anthony/git/chalk

...

Ran 37 tests in 0.009s

OK
py36 runtests: commands[1] | coverage report -m
Name                Stmts   Miss  Cover   Missing
-------------------------------------------------
chalk/__init__.py      18      0   100%
chalk/logging.py       28      0   100%
chalk/utils.py        124      0   100%
-------------------------------------------------
TOTAL                 170      0   100%
_________________________________________________________________________________________ summary _________________________________________________________________________________________
  py27: commands succeeded
  py35: commands succeeded
  py36: commands succeeded
  congratulations :)

Using Docker

Alternatively use a docker image with pyenv installed. This project uses anthonyalmarza/alpine-pyenv:cable which has pyenv setup with the latest versions of python 2.7, 3.5 and 3.6 (as of Dec 19th 2017).

First build the image and tag it as chalk

./bin/local/build

Then run the tests

./bin/local/test

Thank you

  • @billjohnston

  • @livibetter

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

nucypher_pychalk-2.0.2.dev50.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

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

nucypher_pychalk-2.0.2.dev50-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file nucypher_pychalk-2.0.2.dev50.tar.gz.

File metadata

  • Download URL: nucypher_pychalk-2.0.2.dev50.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for nucypher_pychalk-2.0.2.dev50.tar.gz
Algorithm Hash digest
SHA256 66f666faca6c5972dbef614b5271e345b39b8249095fac1bd39e0994bfab2f4b
MD5 fbb9d6c5a0cb0a958328f032b1337046
BLAKE2b-256 5032cd88ea6ee98444e43f333a37a5dc827ade87a0d1710fe8cfb25cd2846d60

See more details on using hashes here.

File details

Details for the file nucypher_pychalk-2.0.2.dev50-py3-none-any.whl.

File metadata

File hashes

Hashes for nucypher_pychalk-2.0.2.dev50-py3-none-any.whl
Algorithm Hash digest
SHA256 9071245b05d97d398ae3c229938f5323a7580faafb2dd675f34724d77b6ddc4c
MD5 fbc23748467f1f2179ab8c807d5ea345
BLAKE2b-256 c19c786883c0857b3cb9d4a7907c564d9fdaf31589b9a765be2585f011ea7337

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