https://github.com/fgimian/painter
Your own expressive painter who colors text in your terminal.
https://github.com/fgimian/painter
ansi-colors string-formatter
Last synced: 5 months ago
JSON representation
Your own expressive painter who colors text in your terminal.
- Host: GitHub
- URL: https://github.com/fgimian/painter
- Owner: fgimian
- License: mit
- Archived: true
- Created: 2014-04-25T12:49:50.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2018-07-22T11:37:22.000Z (about 7 years ago)
- Last Synced: 2025-05-03T08:00:07.517Z (5 months ago)
- Topics: ansi-colors, string-formatter
- Language: Python
- Homepage:
- Size: 803 KB
- Stars: 28
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- License: LICENSE
Awesome Lists containing this project
README
Painter
=======|Build Status| |Coverage Status| |License| |Latest Version|
.. |Build Status| image:: https://travis-ci.org/fgimian/painter.svg?branch=master
:target: https://travis-ci.org/fgimian/painter
.. |Coverage Status| image:: https://codecov.io/gh/fgimian/painter/branch/master/graph/badge.svg
:target: https://codecov.io/gh/fgimian/painter
.. |License| image:: https://img.shields.io/badge/license-MIT-blue.svg
:target: https://github.com/fgimian/painter/blob/master/LICENSE
.. |Latest Version| image:: https://img.shields.io/pypi/v/painter.svg
:target: https://pypi.python.org/pypi/painter/.. image:: https://raw.githubusercontent.com/fgimian/painter/master/images/painter-logo.png
:alt: Painter LogoArtwork courtesy of `Open Clip Art
Library `_Introduction
------------Painter is an ANSI coloring library based on the excellent
`chalk `_ and
`colors.js `_ libraries for
Node.js. However, painter attempts to provide an even more expressive
API which reads like English.Painter is fully tested with 100% coverage and also completely Flake8
compliant too!Quick Start
-----------Install Painter in your virtualenv as follows:
.. code:: bash
pip install painter
And now, go ahead and use it to output colors to your terminal:
.. code:: python
from __future__ import print_function
from painter import paint
# Simple printing of colors
print('Welcome to Painter!', paint.red('I can paint things red'),
paint.blue('and blue'))# Chaining colors and styles
print(paint.blue.on_red.bold.underline('and far more complex combos too'))
print()# Using color patterns
print(paint.rainbow('Awww look, a pretty rainbow :)'))
print(paint.zebra('and a scary looking zebra!'))
print()# Nested painting
print(paint.on_red('I can also use a background color across',
paint.blue('multiple'),
paint.yellow('foreground colors')))# Custom separator
print(paint('and', 'allow', 'you to use', paint.red('custom separators'),
sep='-'))
print()# Creating themes
cool_theme = paint.green.on_red.underline.bold
print('Creating', cool_theme('your own theme'), 'is easy')# Easily disable painting of colors
paint.enabled = False
print('and I allow you to easily', paint.red('disable'), paint.blue('me'))
print()paint.enabled = True
print('Hope you have a', paint.blue('lovely day!'), paint.green(':)'))The output of the script above looks something like this:
.. image:: https://raw.githubusercontent.com/fgimian/painter/master/images/painter-demo.png
:alt: Painter DemoDocumentation
-------------Please check out the `Painter Usage documentation
`_.Running Tests
-------------You may run the unit tests as follows:
.. code:: bash
git clone https://github.com/fgimian/painter.git
cd painter
python setup.py testYou may validate Flake8 compatibility as follows:
.. code:: bash
python setup.py flake8
License
-------Painter is released under the **MIT** license. Please see the
`LICENSE `_
file for more details.