Playing with ANSI colors and python with Couleur
Last night I've just released the first version of Couleur, which is (or at least try to be) a simple and awesome tool for using ANSI colors with python.
Couleur indeed turns very easy to handle shell colors in python.
In action
1 import time
2 import couleur
3
4 sh = couleur.Shell(linebreak=True)
5 for mood in ["bad", "awful", "normal", "nice", "awesome"]:
6 sh.red_on_black(mood, replace=True)
7 time.sleep(1)
Couleur creates colored output dinamically, so that you can mix colors and modifiers at will:
1 import couleur
2 sh = couleur.Shell(linebreak=True)
3 sh.bold_black_and_bold_yellow_on_red("Gray | Yellow")
And even use "static" output, let's simulate the output of a "git clone":
1 import time
2 import couleur
3
4 sh = couleur.Shell(linebreak=True)
5 for x in range(101):
6 if x is 0:
7 print
8 sh.normal_and_bold_green(
9 "Counting objects: |%d%%" % x,
10 replace=True
11 )
12 time.sleep(0.08)
Installation
1 user@machine:~$ sudo pip install couleur
Full Documentation
Available here
Contributing
Fork me on github, write tests, write code, make it pass, send a pull request :)
blog comments powered by Disqus