### Navigation

- index
- modules |
- next |
- previous |
- home|
- search|
- documentation »
- The IPython API »

# utils.coloransi

## Module: `utils.coloransi`

Inheritance diagram for `IPython.utils.coloransi`:

Tools for coloring text in ANSI terminals.

## Classes

### `ColorScheme`

class `IPython.utils.coloransi.``ColorScheme`(_ColorScheme__scheme_name_, colordict=None, **colormap)

  Generic color scheme class. Just a name and a Struct.

  `__init__`(_ColorScheme__scheme_name_, colordict=None, **colormap)
  `copy`(name=None)

    Return a full copy of the object, optionally renaming it.

### `ColorSchemeTable`

class `IPython.utils.coloransi.``ColorSchemeTable`(scheme_list=None, default_scheme='')

  Bases: `dict`

  General class to handle tables of color schemes.

  It’s basically a dict of color schemes with a couple of shorthand attributes and some convenient methods.

  active_scheme_name -> obvious active_colors -> actual color table of the active scheme

  `__init__`(scheme_list=None, default_scheme='')

    Create a table of color schemes.

    The table can be created empty and manually filled or it can be created with a list of valid color schemes AND the specification for the default active scheme.

  `add_scheme`(new_scheme)

    Add a new color scheme to the table.

  `clear`

    D.clear() -> None. Remove all items from D.

  `copy`()

    Return full copy of object

  static `fromkeys`()

    dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v. v defaults to None.

  `get`

    D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.

  `has_key`

    D.has_key(k) -> True if D has a key k, else False

  `items`

    D.items() -> list of D’s (key, value) pairs, as 2-tuples

  `iteritems`

    D.iteritems() -> an iterator over the (key, value) items of D

  `iterkeys`

    D.iterkeys() -> an iterator over the keys of D

  `itervalues`

    D.itervalues() -> an iterator over the values of D

  `keys`

    D.keys() -> list of D’s keys

  `pop`

    D.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised

  `popitem`

    D.popitem() -> (k, v), remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty.

  `set_active_scheme`(scheme, case_sensitive=0)

    Set the currently active scheme.

    Names are by default compared in a case-insensitive way, but this can be changed by setting the parameter case_sensitive to true.

  `setdefault`

    D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D

  `update`

    D.update(E, **F) -> None. Update D from dict/iterable E and F. If E has a .keys() method, does: for k in E: D[k] = E[k] If E lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

  `values`

    D.values() -> list of D’s values

  `viewitems`

    D.viewitems() -> a set-like object providing a view on D’s items

  `viewkeys`

    D.viewkeys() -> a set-like object providing a view on D’s keys

  `viewvalues`

    D.viewvalues() -> an object providing a view on D’s values

### `InputTermColors`

class `IPython.utils.coloransi.``InputTermColors`

  Color escape sequences for input prompts.

  This class is similar to TermColors, but the escapes are wrapped in and so that readline can properly know the length of each line and can wrap lines accordingly. Use this class for any colored text which needs to be used in input prompts, such as in calls to raw_input().

  This class defines the escape sequences for all the standard (ANSI?) colors in terminals. Also defines a NoColor escape which is just the null string, suitable for defining ‘dummy’ color schemes in terminals which get confused by color escapes.

  This class should be used as a mixin for building color schemes.

### `NoColors`

class `IPython.utils.coloransi.``NoColors`

  This defines all the same names as the colour classes, but maps them to empty strings, so it can easily be substituted to turn off colours.

### `TermColors`

class `IPython.utils.coloransi.``TermColors`

  Color escape sequences.

  This class defines the escape sequences for all the standard (ANSI?) colors in terminals. Also defines a NoColor escape which is just the null string, suitable for defining ‘dummy’ color schemes in terminals which get confused by color escapes.

  This class should be used as a mixin for building color schemes.

## Function

`IPython.utils.coloransi.``make_color_table`(in_class)

  Build a set of color attributes in a class.

  Helper function for building the *TermColors classes.

### Navigation

- index
- modules |
- next |
- previous |
- home|
- search|
- documentation »
- The IPython API »