chroma
is a Python package for pretty printing various data with a built-in
support for colors and emojis. It is actually a wrapper around rich
[1], a
pretty printing library.
In particular, it allows you to:
- nicely format tables where individual rows can be emphasized;
- pretty print text messages with automatic highlighting of many data types such as number, strings and URLs;
- select a severity level to accentuate important information;
- use progress bars with automatic ETAs.
chroma
can be easily installed via conda
(or pipenv
).
If you want to create an environment for developing chroma
, just run the command:
conda env create --file environment.yml
And to remove this environment launch:
conda remove --name chroma --all
If, instead, you want to use chroma
in one of your projects, just add the following dependencies in your conda
's environment.yaml
:
- pip
- pip:
- "--editable=git+https://ACCESS_TOKEN@github.com/daniele-canavese/chroma.git#egg=chroma"
Where ACCESS_TOKEN
is you GitHub's access token.
Conversely, chroma
can be uninstalled with:
conda uninstall chroma
The most important function in chroma
is pprint
, which is used to pretty
print anything. The Table
instances
obviously represent tabular data and can be fed to pprint
as well. In
addition, the ProgressBar
class is an iterable
that automatically display a progress bar.
The examples
folder contains many commented usage examples of chroma
. In
particular:
examples/printing.py
shows how to pretty print various text messages;examples/progress.py
contains some progress bar instances;examples/table.py
presents different ways of printing tables.
[1] rich
, a Python library for rich text
and beautiful formatting in the terminal.