Did I find the right examples for you? yes no

All Samples(1)  |  Call(0)  |  Derive(0)  |  Import(1)
An efficient and simple ANSI colours module (and also a powerfull script), with functions to print text using colours.

About the convention for the names of the colours :
 * for the eight colours black, red, green, yellow, blue, magenta, cyan, white:
  * the name in minuscule is for colour **with bold** (example 'yellow'),
  * the name starting with 'B' is for colour **without bold** (example 'Byellow'),
  * the name starting with a capital letter is for the background colour (example 'Yellow').
 * for the special effects (blink, italic, bold, underline, negative), **not always supported** :
  * the name in minuscule is for **activate** the effect,
  * the name starting in capital letter is for **desactivate** the effect.
 * for the other special effects (nocolours, default, Default, clear, el), the effect is **immediate** (and seems to be well supported).

List of functions:
==================

To print a string
-----------------

 * sprint: give a string,
 * printc: like __builtin__.print, but with interpreting balises to put colours,
 * writec: like printc, but using any file object (and no new line added at the end of the string),

To clean the terminal or the line
---------------------------------

 * erase: erase all ANSI colours balises in the string (like sprint, but erasing and not interpreting colour balises)
 * clearLine, clearScreen: to clear the current line or screen,
 * Reset: to return to default foreground and background, and stopping all *fancy* effects (like blinking or reverse video).
 
Others functions
----------------

 * notify: try to display a *system* notification. **Only on *linux*.**
 * xtitle: try to set the *title* of the terminal. **Not always supported**.

Example of use (module) :
=========================

 To store a string, use *sprint* (*i.e.* print to a string, sprint), like here ::

   >>> example=sprint("France flag is <blue>blue<white>white<red>red<white>, Italy flag have <green>green on it<white>.")
 The string *example* can then be printed, with colours, with ::

   >>> print example # Sorry, but in the documentation it is hard to show colours :)
   France flag is bluewhitered, Italy flag have green on it.
 
 
 To directly print a string colored by balises, use *printc* ::

   >>> printc("Batman's costum is <black>black<white>, Aquaman's costum is <blue>blue<white> and <green>green<white>.")

 .. seealso::
    This is the most usefull function. To do the same, but on any file, use *writec*
 
 Moreover, the function *erase* can also be usefull to simply delete all *valid* colour balises ::

   >>> print erase("Batman's costum is <black>black<white>, Aquaman's costum is <blue>blue<white> and <green>green<white>, and this is a non-valid <balise>, so it is kept like this.")
   Batman's costum is black, Aquaman's costum is blue and green, and this is a non-valid <balise>, so it is kept like this
 
 
 In this last example, *<el>* balise is used to erase the current content of the line, usefull to make a *dynamical* print ::

   >>> writec("<red>Computing <u>2**(2**(2**4))<reset>...."); tmp=2**(2**(2**4)); writec("<el><green> Done !<reset>")
   Done !
 The first 'Computing 2**(2**(2**4))....' have disappeared after the computation !

Example of use (script):
========================

 * To show the help :code:`$ ANSIColors.py --help`;

 * To run a test :code:`$ ANSIColors.py --test`;

 * To produce a GNU Bash colour aliases file 
   :code:`$ ANSIColors.py --generate --file ~/.colour_aliases.sh`

Auto detection
==============

Now, this script can detect if ANSI codes are supported :
  1. ``$ ANSIColors.py --help`` : will print with colours if colours seems to be supported;
  2. ``$ ANSIColors.py --help --noANSI`` : will print without any colours, even if it is possible;
  3. ``$ ANSIColors.py --help --ANSI`` : will force the use of colours, even they seems to be not supported.

And, the module part behaves exactly like the script part.

**This functionality is still experimental**, and work only on Ubuntu 11.10,
as far as I know.

------------------------------------------------------------------------------

About:
======

This module is **still in development**.
Last version of this project can be found on-line :

 * `here on BitBucket <https://bitbucket.org/lbesson/ansi-colors>`_;
 * `here on PyPi <https://pypi.python.org/pypi/ANSIColors-balises>`_.


The reference page for ANSI code is : `here on Wikipedia <http://en.wikipedia.org/wiki/ANSI_escape_code>`_.
The reference page for XTitle escape code is : `here <http://www.faqs.org/docs/Linux-mini/Xterm-Title.html>`_.

Documentation
=============

The doc is available on-line :

 * on `pythonhosted.org/ANSIColors-balises/ <http://pythonhosted.org/ANSIColors-balises/index.html>`_;
 * on one of my own pages :

   * on the cr@ns network `besson/publis/ansi-colors/ <http://perso.crans.org/besson/publis/ansi-colors/index.html>`_,
   * on the CS department at ENS de Cachan `~lbesson/publis/ansi-colors/ <http://www.dptinfo.ens-cachan.fr/~lbesson/publis/ansi-colors/index.html>`_,

Or some explanations (and an OCaml version of this module) 
are available on my Google Site `tools/ansi-colors <https://sites.google.com/site/naereencorp/tools/ansicolors>`_.

Copyrigths:
===========

 (c) October 2012 - Mars 2013
 By Lilian BESSON,
 ENS de Cachan (M1 Mathematics & M1 Computer Science MPRI)
 mailto:lbesson@ens-cachan.fr
    
 For Naereen Corp.
 mailto:naereen-corporation@laposte.net
 https://sites.google.com/site/naereencorp/tools/ansicolors

src/a/n/ANSIColors-balises-1.9.9.public/setup.py   ANSIColors-balises(Download)
from distutils.core import setup
 
import ANSIColors
 
setup(name='ANSIColors-balises',