Alexander Hesse avatar Alexander Hesse committed 81f81b2

Moved ansi modules and udir to rpython

Comments (0)

Files changed (147)

lib_pypy/ctypes_config_cache/rebuild.py

 
 _dirpath = os.path.dirname(__file__) or os.curdir
 
-from pypy.tool.ansi_print import ansi_log
+from rpython.tool.ansi_print import ansi_log
 log = py.log.Producer("ctypes_config_cache")
 py.log.setconsumer("ctypes_config_cache", ansi_log)
 

lib_pypy/ctypes_config_cache/test/test_cache.py

 import py
 import sys, os
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 
 dirpath = py.path.local(__file__).dirpath().dirpath()
 

lib_pypy/pypy_test/test_dbm_extra.py

 from __future__ import absolute_import
 import py
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 try:
     from lib_pypy import dbm
 except ImportError, e:

lib_pypy/pypy_test/test_marshal_extra.py

 import marshal as cpy_marshal
 from lib_pypy import _marshal as marshal
 
-from pypy.tool.udir import udir 
+from rpython.tool.udir import udir 
 
 hello = "he"
 hello += "llo"

pypy/interpreter/error.py

 # ____________________________________________________________
 
 # Utilities
-from pypy.tool.ansi_print import ansi_print
+from rpython.tool.ansi_print import ansi_print
 
 def debug_print(text, file=None, newline=True):
     # 31: ANSI color code "red"

pypy/interpreter/test/test_buffer.py

 import py
 from pypy.interpreter.buffer import Buffer
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 
 testdir = udir.ensure('test_buffer', dir=1)
 

pypy/interpreter/test/test_compiler.py

         assert space.float_w(w_result) == 0
 
     def test_dont_inherit_across_import(self):
-        from pypy.tool.udir import udir
+        from rpython.tool.udir import udir
         udir.join('test_dont_inherit_across_import.py').write('x = 1/2\n')
         space = self.space
         s1 = str(py.code.Source("""

pypy/interpreter/test/test_exec.py

 
 New for PyPy - Could be incorporated into CPython regression tests.
 """
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 
 
 def test_file(space):

pypy/interpreter/test/test_executioncontext.py

     def setup_method(self, meth):
         if not self.runappdirect:
             py.test.skip("test is meant for running with py.test -A")
-        from pypy.tool.udir import udir
+        from rpython.tool.udir import udir
         tmpfile = udir.join('test_execution_context')
         tmpfile.write("""
 import gc

pypy/interpreter/test/test_extmodules.py

 
 from pypy.config.pypyoption import get_pypy_config
 from pypy.objspace.std import StdObjSpace
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 
 mod_init = """
 from pypy.interpreter.mixedmodule import MixedModule

pypy/interpreter/test/test_main.py

 from cStringIO import StringIO
 
 import py
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from pypy.interpreter.baseobjspace import OperationError
 from pypy.interpreter import main
 

pypy/interpreter/test/test_pyframe.py

-from pypy.tool import udir
+from rpython.tool import udir
 from pypy.conftest import option
 
 

pypy/interpreter/test/test_typedef.py

 import gc
 from pypy.interpreter import typedef
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from pypy.interpreter.baseobjspace import Wrappable
 from pypy.interpreter.gateway import ObjSpace, interp2app
 

pypy/interpreter/test/test_zpy.py

 
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 import py
 import sys
 import pypy

pypy/module/__builtin__/test/test_builtin.py

 
 class TestInternal:
     def test_execfile(self, space):
-        from pypy.tool.udir import udir
+        from rpython.tool.udir import udir
         fn = str(udir.join('test_execfile'))
         f = open(fn, 'w')
         print >>f, "i=42"
         assert space.eq_w(w_value, space.wrap(42))
 
     def test_execfile_different_lineendings(self, space): 
-        from pypy.tool.udir import udir
+        from rpython.tool.udir import udir
         d = udir.ensure('lineending', dir=1)
         dos = d.join('dos.py') 
         f = dos.open('wb') 

pypy/module/_cffi_backend/test/test_c.py

 if sys.version_info < (2, 6):
     py.test.skip("requires the b'' literal syntax")
 
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from pypy.interpreter import gateway
 from pypy.module._cffi_backend import Module
 from rpython.translator.platform import host

pypy/module/_ffi/test/test_funcptr.py

 
     @classmethod
     def prepare_c_example(cls):
-        from pypy.tool.udir import udir
+        from rpython.tool.udir import udir
         from rpython.translator.tool.cbuild import ExternalCompilationInfo
         from rpython.translator.platform import platform
 

pypy/module/_file/test/test_file.py

 def test_flush_at_exit():
     from pypy import conftest
     from pypy.tool.option import make_config, make_objspace
-    from pypy.tool.udir import udir
+    from rpython.tool.udir import udir
 
     tmpfile = udir.join('test_flush_at_exit')
     config = make_config(conftest.option)

pypy/module/_file/test/test_file_extra.py

 import os, random, sys
-import pypy.tool.udir
+import rpython.tool.udir
 import py
 
-udir = pypy.tool.udir.udir.ensure('test_file_extra', dir=1)
+udir = rpython.tool.udir.udir.ensure('test_file_extra', dir=1)
 
 
 # XXX this file is a random test.  It may only fail occasionally

pypy/module/_io/test/test_bufferedio.py

 from __future__ import with_statement
 from pypy.interpreter.gateway import interp2app
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from pypy.module._io import interp_bufferedio
 from pypy.interpreter.error import OperationError
 import py.test

pypy/module/_io/test/test_fileio.py

-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 import os
 
 class AppTestFileIO:
 def test_flush_at_exit():
     from pypy import conftest
     from pypy.tool.option import make_config, make_objspace
-    from pypy.tool.udir import udir
+    from rpython.tool.udir import udir
 
     tmpfile = udir.join('test_flush_at_exit')
     config = make_config(conftest.option)

pypy/module/_io/test/test_io.py

 from __future__ import with_statement
 
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 
 
 class AppTestIoModule:

pypy/module/_minimal_curses/test/test_curses.py

 from pypy.tool.autopath import pypydir
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 import py
 import sys
 # tests here are run as snippets through a pexpected python subprocess

pypy/module/_rawffi/test/test__rawffi.py

     spaceconfig = dict(usemodules=['_rawffi', 'struct'])
 
     def prepare_c_example():
-        from pypy.tool.udir import udir
+        from rpython.tool.udir import udir
         c_file = udir.ensure("test__rawffi", dir=1).join("xlib.c")
         c_file.write(py.code.Source('''
         #include <stdlib.h>

pypy/module/_socket/test/test_sock_app.py

 import sys
 import py
 from pypy.tool.pytest.objspace import gettestobjspace
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from rpython.rlib import rsocket
 from rpython.rtyper.lltypesystem import lltype, rffi
 

pypy/module/_winreg/test/test_winreg.py

-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 
 import os, sys, py
 

pypy/module/cpyext/api.py

 from rpython.rlib.objectmodel import we_are_translated
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
 from rpython.translator.gensupp import NameManager
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from rpython.translator import platform
 from pypy.module.cpyext.state import State
 from pypy.interpreter.error import OperationError, operationerrfmt

pypy/module/cpyext/presetup.py

 dn = os.path.dirname
 rootdir = dn(dn(dn(dn(__file__))))
 sys.path.insert(0, rootdir)
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 pypydir = os.path.join(rootdir, 'pypy')
 f = open(os.path.join(str(udir), 'pyconfig.h'), "w")
 f.write("\n")

pypy/module/cpyext/test/test_cpyext.py

 from rpython.translator.tool.cbuild import ExternalCompilationInfo
 from rpython.translator import platform
 from rpython.translator.gensupp import uniquemodulename
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from pypy.module.cpyext import api
 from pypy.module.cpyext.state import State
 from pypy.module.cpyext.pyobject import RefcountState

pypy/module/cpyext/test/test_eval.py

 from pypy.module.cpyext.api import fopen, fclose, fileno, Py_ssize_tP
 from pypy.interpreter.gateway import interp2app
 from pypy.interpreter.astcompiler import consts
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 import sys, os
 
 class TestEval(BaseApiTest):

pypy/module/cpyext/test/test_pyfile.py

 from pypy.module.cpyext.test.test_api import BaseApiTest
 from pypy.module.cpyext.object import Py_PRINT_RAW
 from rpython.rtyper.lltypesystem import rffi, lltype
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 import pytest
 
 class TestFile(BaseApiTest):

pypy/module/fcntl/test/test_fcntl.py

 import os
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 
 if os.name == "nt":
     from py.test import skip

pypy/module/gc/test/test_app_referents.py

 import py, os
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 
 
 def test_interface_to_dump_rpy_heap_str(space):

pypy/module/gc/test/test_gc.py

 
     def setup_class(cls):
         import py
-        from pypy.tool.udir import udir
+        from rpython.tool.udir import udir
         from rpython.rlib import rgc
         class X(object):
             def __init__(self, count, size, links):

pypy/module/imp/test/test_import.py

 from pypy.interpreter import gateway
 from pypy.interpreter.error import OperationError
 import pypy.interpreter.pycode
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from rpython.rlib import streamio
 from pypy.tool.option import make_config
 from pypy.tool.pytest.objspace import maketestobjspace

pypy/module/marshal/test/test_marshal.py

-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 
 
 class AppTestMarshal:

pypy/module/mmap/test/test_mmap.py

 from __future__ import with_statement
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 import os
 
 class AppTestMMap:

pypy/module/posix/test/test_posix2.py

 
 from __future__ import with_statement
 from pypy.objspace.std import StdObjSpace
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from pypy.tool.pytest.objspace import gettestobjspace
 from pypy.tool.autopath import pypydir
 from rpython.rtyper.module.ll_os import RegisterOs

pypy/module/posix/test/test_posix_libfile.py

 import os
 
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 
 
 def setup_module(mod):

pypy/module/pypyjit/test_pypy_c/test_00_model.py

 import subprocess
 import py
 from lib_pypy import disassembler
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from pypy.tool import logparser
 from rpython.jit.tool.jitoutput import parse_prof
 from pypy.module.pypyjit.test_pypy_c.model import (Log, find_ids_range,

pypy/module/sys/state.py

 def pypy_getudir(space):
     """NOT_RPYTHON
     (should be removed from interpleveldefs before translation)"""
-    from pypy.tool.udir import udir
+    from rpython.tool.udir import udir
     return space.wrap(str(udir))
 

pypy/module/termios/test/test_termios.py

 import py
 import sys
 from pypy.tool.autopath import pypydir
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 
 class TestTermios(object):
     def setup_class(cls):

pypy/module/test_lib_pypy/test_msvcrt.py

-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 import py
 import sys
 

pypy/module/thread/test/test_import_lock.py

-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from pypy.module.thread.test.support import GenericTestThread
 
 

pypy/module/zipimport/test/test_zipimport.py

 from pypy.module.imp.importing import get_pyc_magic, _w_long
 from StringIO import StringIO
 
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from zipfile import ZIP_STORED, ZIP_DEFLATED
 
 

pypy/tool/ansi_mandelbrot.py

-import sys
-
-from py.io import ansi_print, get_terminal_width
-
-"""
-Black       0;30     Dark Gray     1;30
-Blue        0;34     Light Blue    1;34
-Green       0;32     Light Green   1;32
-Cyan        0;36     Light Cyan    1;36
-Red         0;31     Light Red     1;31
-Purple      0;35     Light Purple  1;35
-Brown       0;33     Yellow        1;33
-Light Gray  0;37     White         1;37
-"""
-
-
-palette = [39, 34, 35, 36, 31, 33, 32, 37]
-
-
-colour_range = None # used for debugging
-
-
-def print_pixel(colour, value_range, invert=1):
-    global colour_range
-    chars = [".", ".", "+", "*", "%", "#"]
-    idx = lambda chars: (colour+1) * (len(chars) - 1) / value_range
-    if invert:
-        idx = lambda chars, idx=idx:len(chars) - 1 - idx(chars)
-    char = chars[idx(chars)]
-    ansi_colour = palette[idx(palette)]
-    ansi_print(char, ansi_colour, newline=False, flush=True)
-    #if colour_range is None:
-    #    colour_range = [colour, colour]
-    #else:
-    #    colour_range = [min(colour_range[0], colour), max(colour_range[1], colour)]
-
-
-class Mandelbrot:
-    def __init__ (self, width=100, height=28, x_pos=-0.5, y_pos=0, distance=6.75):
-        self.xpos = x_pos
-        self.ypos = y_pos
-        aspect_ratio = 1/3.
-        factor = float(distance) / width # lowering the distance will zoom in
-        self.xscale = factor * aspect_ratio
-        self.yscale = factor
-        self.iterations = 170
-        self.x = width
-        self.y = height
-        self.z0 = complex(0, 0)
-
-    def init(self):
-        self.reset_lines = False
-        xmin = self.xpos - self.xscale * self.x / 2
-        ymin = self.ypos - self.yscale * self.y / 2
-        self.x_range = [xmin + self.xscale * ix for ix in range(self.x)]
-        self.y_range = [ymin + self.yscale * iy for iy in range(self.y)]
-        
-        #print "x", self.x_range[0], self.x_range[-1]
-        #print "y", self.y_range[0], self.y_range[-1]
-
-    def reset(self, cnt):
-        self.reset_lines = cnt
-
-    def generate(self):
-        self.reset_lines = False
-        iy = 0
-        while iy < self.y:
-            ix = 0
-            while ix < self.x:
-                c = complex(self.x_range[ix], self.y_range[iy])
-                z = self.z0
-                colour = 0
-                mind = 2
-
-                for i in range(self.iterations):
-                    z = z * z + c
-                    d = abs(z)
-                    if d >= 2:
-                        colour = min(int(mind / 0.007), 254) + 1
-                        break
-                    else:
-                        mind = min(d, mind)
-
-                yield ix, iy, colour
-                if self.reset_lines is not False: # jump to the beginning of the line
-                    iy += self.reset_lines
-                    do_break = bool(self.reset_lines)
-                    self.reset_lines = False
-                    if do_break:
-                        break
-                    ix = 0
-                else:
-                    ix += 1
-            iy += 1
-
-
-class Driver(object):
-    zoom_locations = [
-        # x, y, "distance", range
-        (0.37865401, 0.669227668, 0.04, 111),
-        (-1.15, -0.28, 0.9, 94),
-        (-1.15, -0.28, 0.3, 58),
-        (-1.15, -0.28, 0.05, 26),
-            ]
-    def __init__(self, **kwargs):
-        self.kwargs = kwargs
-        self.zoom_location = -1
-        self.colour_range = 256
-        self.invert = True
-        self.init()
-
-    def init(self):
-        self.width = get_terminal_width() or 80 # in some envs, the py lib doesnt default the width correctly
-        self.mandelbrot = Mandelbrot(width=(self.width or 1), **self.kwargs)
-        self.mandelbrot.init()
-        self.gen = self.mandelbrot.generate()
-
-    def reset(self, cnt=0):
-        """ Resets to the beginning of the line and drops cnt lines internally. """
-        self.mandelbrot.reset(cnt)
-
-    def catchup(self):
-        """ Fills the current line. """
-        x = 0
-        while x != self.width - 1:
-            x, y, c = self.gen.next()
-            print_pixel(c, self.colour_range, self.invert)
-        print >>sys.stderr
-
-    def restart(self):
-        """ Restarts the current generator. """
-        print >>sys.stderr
-        self.init()
-
-    def dot(self):
-        """ Emits a colourful character. """
-        x = c = 0
-        try:
-            x, y, c = self.gen.next()
-            if x == 0:
-                width = get_terminal_width()
-                if width != self.width:
-                    self.init()
-        except StopIteration:
-            kwargs = self.kwargs
-            self.zoom_location += 1
-            self.zoom_location %= len(self.zoom_locations)
-            loc = self.zoom_locations[self.zoom_location]
-            kwargs.update({"x_pos": loc[0], "y_pos": loc[1], "distance": loc[2]})
-            self.colour_range = loc[3]
-            #global colour_range
-            #print colour_range, loc[2]
-            #colour_range = None
-            return self.restart()
-        print_pixel(c, self.colour_range, self.invert)
-        if x == self.width - 1:
-            print >>sys.stderr
-
-
-if __name__ == '__main__':
-    import random
-    from time import sleep
-
-    d = Driver()
-    for x in xrange(15000):
-        sleep(random.random() / 300)
-        d.dot()
-        if 0 and random.random() < 0.01:
-            d.catchup()
-            print "WARNING! " * 3
-            d.reset(1)
-        #    print "R",
-        if 0 and random.random() < 0.01:
-            string = "WARNING! " * 3
-            d.jump(len(string))
-            print string,
-

pypy/tool/ansi_print.py

-"""
-A color print.
-"""
-
-import sys
-from py.io import ansi_print
-from pypy.tool.ansi_mandelbrot import Driver
-
-class AnsiLog:
-    wrote_dot = False # XXX sharing state with all instances
-
-    KW_TO_COLOR = {
-        # color supress
-        'red': ((31,), True),
-        'bold': ((1,), True),
-        'WARNING': ((31,), False),
-        'event': ((1,), True),
-        'ERROR': ((1, 31), False),
-        'Error': ((1, 31), False),
-        'info': ((35,), False),
-        'stub': ((34,), False),
-    }
-
-    def __init__(self, kw_to_color={}, file=None):
-        self.kw_to_color = self.KW_TO_COLOR.copy()
-        self.kw_to_color.update(kw_to_color)
-        self.file = file
-        self.fancy = True
-        self.isatty = getattr(sys.stderr, 'isatty', lambda: False)
-        if self.fancy and self.isatty(): 
-            self.mandelbrot_driver = Driver()
-        else:
-            self.mandelbrot_driver = None
-
-    def __call__(self, msg):
-        tty = self.isatty()
-        flush = False
-        newline = True
-        keywords = []
-        esc = []
-        for kw in msg.keywords:
-            color, supress = self.kw_to_color.get(kw, (None, False))
-            if color:
-                esc.extend(color)
-            if not supress:
-                keywords.append(kw)
-        if 'start' in keywords:
-            if tty:
-                newline = False
-                flush = True
-                keywords.remove('start')
-        elif 'done' in keywords:
-            if tty:
-                print >> sys.stderr
-                return
-        elif 'dot' in keywords:
-            if tty:
-                if self.fancy:
-                    if not AnsiLog.wrote_dot:
-                        self.mandelbrot_driver.reset()
-                    self.mandelbrot_driver.dot()
-                else:
-                    ansi_print(".", tuple(esc), file=self.file, newline=False, flush=flush)
-                AnsiLog.wrote_dot = True
-                return
-        if AnsiLog.wrote_dot:
-            AnsiLog.wrote_dot = False
-            sys.stderr.write("\n")
-        esc = tuple(esc)
-        for line in msg.content().splitlines():
-            ansi_print("[%s] %s" %(":".join(keywords), line), esc, 
-                       file=self.file, newline=newline, flush=flush)
-
-ansi_log = AnsiLog()

pypy/tool/ansicolor.py

-class colors:
-    black = '30'
-    darkred = '31'
-    darkgreen = '32'    
-    brown = '33'
-    darkblue = '34'
-    purple = '35'
-    teal = '36'
-    lightgray = '37'
-    darkgray = '30;01'
-    red = '31;01'
-    green = '32;01'
-    yellow = '33;01'
-    blue = '34;01'
-    fuchsia = '35;01'
-    turquoise = '36;01'
-    white = '37;01'
-
-def setcolor(s, color):
-    return '\x1b[%sm%s\x1b[00m' % (color, s)
-
-for name in colors.__dict__:
-    if name.startswith('_'):
-        continue
-    exec """
-def %s(s):
-    return setcolor(s, colors.%s)
-""" % (name, name)

pypy/tool/error.py

 """ error handling features, just a way of displaying errors
 """
 
-from pypy.tool.ansi_print import ansi_log
+from rpython.tool.ansi_print import ansi_log
 from rpython.flowspace.model import Variable
 import sys
 

pypy/tool/pytest/expecttest.py

 
 import py
 import os, sys
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from pypy.tool.autopath import pypydir
 
 

pypy/tool/pytest/test/test_pytestsupport.py

 from pypy.tool.pytest.appsupport import (AppFrame, build_pytest_assertion,
     AppExceptionInfo, interpret)
 import py
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 import os
 import sys
 import pypy

pypy/tool/release/make_release.py

 from xml.dom import minidom
 import re
 import py
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from pypy.tool.release.package import package
 import tarfile
 import os

pypy/tool/release/package.py

 import py
 import os
 import fnmatch
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 
 if sys.version_info < (2,6): py.test.skip("requires 2.6 so far")
 

pypy/tool/test/test_gcc_cache.py

 import sys
 from pypy.tool.gcc_cache import *
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 import md5, cStringIO
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
 

pypy/tool/test/test_logparser.py

-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from pypy.tool.logparser import *
 
 

pypy/tool/test/test_udir.py

 
-from pypy.tool import udir
+from rpython.tool import udir
 
 def test_make_udir():
     root = str(udir.udir.ensure('make_udir1', dir=1))

pypy/tool/udir.py

-#
-# Common entry point to access a temporary directory (for testing, etc.)
-# This uses the py lib's logic to create numbered directories.  The last
-# three temporary directories are kept.
-#
-# The udir is created with the following name:
-#
-#    $PYPY_USESSION_DIR/usession-$PYPY_USESSION_BASENAME-N
-#
-# where N is a small number.  If supported, a symlink is created for
-# convenience too, pointing to (the most recent) udir:
-#
-#    $PYPY_USESSION_DIR/usession-$PYPY_USESSION_BASENAME-$USER
-#
-# The default value for $PYPY_USESSION_DIR is the system tmp.
-# The default value for $PYPY_USESSION_BASENAME is the name
-# of the current Mercurial branch.
-#
-
-import autopath
-import os, sys
-import py
-
-from pypy.tool.version import get_repo_version_info
-from py.path import local 
-
-PYPY_KEEP = int(os.environ.get('PYPY_USESSION_KEEP', '3'))
-
-def make_udir(dir=None, basename=None):
-    if dir is not None:
-        dir = local(dir)
-    if basename is None:
-        info = get_repo_version_info()
-        if info:
-            project, hgtag, hgid = info
-            basename = hgtag
-            if basename == '?':
-                basename = 'unknown' # directories with ? are not fun
-                # especially on windows
-            if isinstance(basename, unicode):
-                basename = basename.encode(sys.getdefaultencoding())
-        else:
-            basename = ''
-    basename = basename.replace('/', '--')
-    if not basename.startswith('-'):
-        basename = '-' + basename
-    if not basename.endswith('-'):
-        basename = basename + '-'
-    return local.make_numbered_dir(rootdir = dir,
-                                   prefix = 'usession' + basename,
-                                   keep = PYPY_KEEP)
-
-udir = make_udir(dir      = os.environ.get('PYPY_USESSION_DIR'),
-                 basename = os.environ.get('PYPY_USESSION_BASENAME'))

pypy/tool/version.py

     if not err:
         return
 
-    from pypy.tool.ansi_print import ansi_log
+    from rpython.tool.ansi_print import ansi_log
     log = py.log.Producer("version")
     py.log.setconsumer("version", ansi_log)
     log.WARNING('Errors getting %s information: %s' % (repo_type, err))

rpython/annotator/annrpython.py

 from __future__ import absolute_import
 
 import types
-from pypy.tool.ansi_print import ansi_log
+from rpython.tool.ansi_print import ansi_log
 from rpython.tool.pairtype import pair
 from pypy.tool.error import (format_blocked_annotation_error,
                              AnnotatorError, gather_error, ErrorWrapper)

rpython/jit/backend/arm/codebuilder.py

 from rpython.jit.backend.llsupport.asmmemmgr import BlockBuilderMixin
 from rpython.rlib.objectmodel import we_are_translated
 from rpython.rtyper.lltypesystem import lltype, rffi, llmemory
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 
 clear_cache = rffi.llexternal(
     "__clear_cache",

rpython/jit/backend/arm/test/gen.py

 import os
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 import tempfile
 from rpython.jit.backend.arm.test.support import AS
 class ASMInstruction(object):

rpython/jit/backend/arm/test/test_zrpy_gc.py

 from rpython.rlib.jit import JitDriver, dont_look_inside
 from rpython.rlib.jit import elidable, unroll_safe
 from rpython.jit.backend.llsupport.gc import GcLLDescr_framework
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from pypy.config.translationoption import DEFL_GC
 from rpython.jit.backend.arm.test.support import skip_unless_run_slow_tests
 skip_unless_run_slow_tests()

rpython/jit/backend/arm/test/test_ztranslation.py

 import py, os, sys
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from rpython.rlib.jit import JitDriver, unroll_parameters, set_param
 from rpython.rlib.jit import PARAMETERS, dont_look_inside
 from rpython.rlib.jit import promote

rpython/jit/backend/arm/tool/viewcode.py

 
 
 def get_tmp_file():
-    # don't use pypy.tool.udir here to avoid removing old usessions which
+    # don't use rpython.tool.udir here to avoid removing old usessions which
     # might still contain interesting executables
     udir = py.path.local.make_numbered_dir(prefix='viewcode-', keep=2)
     tmpfile = str(udir.join('dump.tmp'))

rpython/jit/backend/llgraph/llimpl.py

 from rpython.rlib.rtimer import read_timestamp
 
 import py
-from pypy.tool.ansi_print import ansi_log
+from rpython.tool.ansi_print import ansi_log
 log = py.log.Producer('runner')
 py.log.setconsumer('runner', ansi_log)
 

rpython/jit/backend/x86/runner.py

 from rpython.jit.backend.x86 import regloc
 import sys
 
-from pypy.tool.ansi_print import ansi_log
+from rpython.tool.ansi_print import ansi_log
 log = py.log.Producer('jitbackend')
 py.log.setconsumer('jitbackend', ansi_log)
 

rpython/jit/backend/x86/test/test_runner.py

 from rpython.jit.metainterp.executor import execute
 from rpython.jit.backend.test.runner_test import LLtypeBackendTest
 from rpython.jit.tool.oparser import parse
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 import ctypes
 import sys
 import os

rpython/jit/backend/x86/test/test_rx86_32_auto_encoding.py

 import py
 from rpython.jit.backend.x86 import rx86
 from rpython.rlib.rarithmetic import intmask
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 
 INPUTNAME = 'checkfile_%s.s'
 FILENAME = 'checkfile_%s.o'

rpython/jit/backend/x86/test/test_zrpy_gc.py

 from rpython.rlib.jit import JitDriver, dont_look_inside
 from rpython.rlib.jit import elidable, unroll_safe
 from rpython.jit.backend.llsupport.gc import GcLLDescr_framework
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from pypy.config.translationoption import DEFL_GC
 
 class X(object):

rpython/jit/backend/x86/test/test_ztranslation.py

 import py, os, sys
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from rpython.rlib.jit import JitDriver, unroll_parameters, set_param
 from rpython.rlib.jit import PARAMETERS, dont_look_inside
 from rpython.rlib.jit import promote

rpython/jit/backend/x86/tool/test/test_viewcode.py

 import os
 import py
 import tempfile
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 
 def test_format_code_dump_with_labels():
     lines = StringIO("""

rpython/jit/backend/x86/tool/viewcode.py

 import subprocess
 from bisect import bisect_left
 
-# don't use pypy.tool.udir here to avoid removing old usessions which
+# don't use rpython.tool.udir here to avoid removing old usessions which
 # might still contain interesting executables
 udir = py.path.local.make_numbered_dir(prefix='viewcode-', keep=2)
 tmpfile = str(udir.join('dump.tmp'))
 
 # hack hack
 import pypy.tool
-mod = new.module('pypy.tool.udir')
+mod = new.module('rpython.tool.udir')
 mod.udir = udir
-sys.modules['pypy.tool.udir'] = mod
-pypy.tool.udir = mod
+sys.modules['rpython.tool.udir'] = mod
+rpython.tool.udir = mod
 
 # ____________________________________________________________
 # Some support code from Psyco.  There is more over there,

rpython/jit/codewriter/codewriter.py

 from rpython.jit.codewriter.call import CallControl
 from rpython.jit.codewriter.policy import log
 from rpython.flowspace.model import copygraph
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 
 
 class CodeWriter(object):

rpython/jit/codewriter/policy.py

 from rpython.jit.metainterp import history
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 
 import py
-from pypy.tool.ansi_print import ansi_log
+from rpython.tool.ansi_print import ansi_log
 log = py.log.Producer('jitcodewriter')
 py.log.setconsumer('jitcodewriter', ansi_log)
 

rpython/rlib/clibffi.py

 import sys
 import ctypes.util
 
-from pypy.tool.ansi_print import ansi_log
+from rpython.tool.ansi_print import ansi_log
 log = py.log.Producer("libffi")
 py.log.setconsumer("libffi", ansi_log)
 

rpython/rlib/rwin32.py

 """
 
 from rpython.rtyper.tool import rffi_platform
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
 from rpython.translator.platform import CompilationError
 from rpython.rtyper.lltypesystem import lltype, rffi

rpython/rlib/test/test_clibffi.py

     def test_struct_by_val(self):
         from rpython.translator.tool.cbuild import ExternalCompilationInfo
         from rpython.translator.platform import platform
-        from pypy.tool.udir import udir
+        from rpython.tool.udir import udir
 
         c_file = udir.ensure("test_libffi", dir=1).join("xlib.c")
         c_file.write(py.code.Source('''
     def test_ret_struct_val(self):
         from rpython.translator.tool.cbuild import ExternalCompilationInfo
         from rpython.translator.platform import platform
-        from pypy.tool.udir import udir
+        from rpython.tool.udir import udir
 
         c_file = udir.ensure("test_libffi", dir=1).join("xlib.c")
         c_file.write(py.code.Source('''
     def test_cdll_life_time(self):
         from rpython.translator.tool.cbuild import ExternalCompilationInfo
         from rpython.translator.platform import platform
-        from pypy.tool.udir import udir
+        from rpython.tool.udir import udir
 
         c_file = udir.ensure("test_libffi", dir=1).join("xlib.c")
         c_file.write(py.code.Source('''

rpython/rlib/test/test_libffi.py

 
     @classmethod
     def setup_class(cls):
-        from pypy.tool.udir import udir
+        from rpython.tool.udir import udir
         from rpython.translator.tool.cbuild import ExternalCompilationInfo
         from rpython.translator.tool.cbuild import STANDARD_DEFINES
         from rpython.translator.platform import platform

rpython/rlib/test/test_rmmap.py

-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 import os, sys
 from rpython.rtyper.test.test_llinterp import interpret
 from rpython.rlib.rarithmetic import intmask

rpython/rlib/test/test_rposix.py

 from rpython.rtyper.test.test_llinterp import interpret
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from rpython.rlib import rposix
 import os, sys
 import py

rpython/rlib/test/test_rsocket.py

 def test_unix_socket_connect():
     if getattr(rsocket, 'AF_UNIX', None) is None:
         py.test.skip('AF_UNIX not supported.')
-    from pypy.tool.udir import udir
+    from rpython.tool.udir import udir
     sockpath = str(udir.join('test_unix_socket_connect'))
     a = UNIXAddress(sockpath)
 

rpython/rlib/test/test_rwin32.py

     skip('tests for win32 only')
 
 from rpython.rlib import rwin32
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 
 
 def test_get_osfhandle():

rpython/rlib/test/test_rzipfile.py

 import py
 
 from rpython.rlib.rzipfile import RZipFile
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from zipfile import ZIP_STORED, ZIP_DEFLATED, ZipInfo, ZipFile
 from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
 import os

rpython/rlib/test/test_streamio.py

 import os
 import time
 import random
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 
 from rpython.rlib import streamio
 

rpython/rtyper/llinterp.py

         # start of a dump file
         if not self.TRACE:
             return
-        from pypy.tool.udir import udir
+        from rpython.tool.udir import udir
         n = Tracer.Counter
         Tracer.Counter += 1
         filename = 'llinterp_trace_%d.html' % n
 # by default we route all logging messages to nothingness
 # e.g. tests can then switch on logging to get more help
 # for failing tests
-from pypy.tool.ansi_print import ansi_log
+from rpython.tool.ansi_print import ansi_log
 py.log.setconsumer('llinterp', ansi_log)

rpython/rtyper/lltypesystem/test/test_ll2ctypes.py

 from rpython.rtyper.annlowlevel import llhelper
 from rpython.rlib import rposix
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from rpython.rtyper.test.test_llinterp import interpret
 from rpython.annotator.annrpython import RPythonAnnotator
 from rpython.rtyper.rtyper import RPythonTyper

rpython/rtyper/lltypesystem/test/test_rffi.py

 from rpython.rtyper.lltypesystem.lltype import Signed, Ptr, Char, malloc
 from rpython.rtyper.lltypesystem.rstr import STR
 from rpython.rtyper.lltypesystem import lltype
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from rpython.rtyper.test.test_llinterp import interpret
 from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
 from rpython.annotator.annrpython import RPythonAnnotator

rpython/rtyper/memory/gc/test/test_env.py

 import os, py
 from rpython.rtyper.memory.gc import env
 from rpython.rlib.rarithmetic import r_uint
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 
 
 class FakeEnviron:

rpython/rtyper/memory/gc/test/test_inspector.py

 import os
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from rpython.rtyper.memory.gc.test.test_direct import BaseDirectGCTest, S
 from rpython.rtyper.memory.gc import inspector
 from rpython.rtyper.lltypesystem import llmemory

rpython/rtyper/memory/gctransform/framework.py

 
     def write_typeid_list(self):
         """write out the list of type ids together with some info"""
-        from pypy.tool.udir import udir
+        from rpython.tool.udir import udir
         # XXX not ideal since it is not per compilation, but per run
         # XXX argh argh, this only gives the member index but not the
         #     real typeid, which is a complete mess to obtain now...

rpython/rtyper/memory/gctransform/log.py

 import py
-from pypy.tool.ansi_print import ansi_log
+from rpython.tool.ansi_print import ansi_log
 log = py.log.Producer("gctransform")
 py.log.setconsumer("gctransform", ansi_log)

rpython/rtyper/memory/test/snippet.py

 import os, py
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from rpython.rtyper.lltypesystem import lltype
 from rpython.rtyper.lltypesystem.lloperation import llop
 

rpython/rtyper/module/test/test_ll_os.py

 from py.path import local
 
 import pypy
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from rpython.translator.c.test.test_genc import compile
 from rpython.rtyper.module import ll_os #has side effect of registering functions
 

rpython/rtyper/module/test/test_ll_os_path.py

 from rpython.rtyper.lltypesystem.module.ll_os_path import Implementation as impl
 from rpython.rtyper.module.support import ll_strcpy
 from rpython.rtyper.test.test_llinterp import interpret
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 
 def test_exists():
     filename = impl.to_rstr(str(py.path.local(__file__)))

rpython/rtyper/module/test/test_ll_termios.py

 import py, re, sys
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 # tests here are run as snippets through a pexpected python subprocess
 
 def setup_module(mod):

rpython/rtyper/module/test/test_posix.py

 import py
 from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from rpython.rlib.rarithmetic import is_valid_int
 
 import os

rpython/rtyper/rmodel.py

 # logging/warning
 
 import py
-from pypy.tool.ansi_print import ansi_log
+from rpython.tool.ansi_print import ansi_log
 
 log = py.log.Producer("rtyper")
 py.log.setconsumer("rtyper", ansi_log)

rpython/rtyper/test/test_rbuiltin.py

 from rpython.rtyper.lltypesystem import lltype, rffi
 from rpython.rtyper.test import test_llinterp
 from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
-from pypy.tool import udir
+from rpython.tool import udir
 from rpython.translator.translator import graphof
 
 

rpython/rtyper/tool/rffi_platform.py

 from pypy.tool.gcc_cache import build_executable_cache, try_compile_cache
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
 from rpython.translator.platform import CompilationError
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from pypy.tool.autopath import pypydir
 from rpython.rlib.rarithmetic import r_uint, r_longlong, r_ulonglong, intmask
 

rpython/rtyper/tool/rfficache.py

 import py
 import os
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from rpython.rlib import rarithmetic
 from rpython.rtyper.lltypesystem import lltype
 from pypy.tool.gcc_cache import build_executable_cache

rpython/rtyper/tool/test/test_mkrffi.py

 class TestMkrffi(object):
     def setup_class(cls):
         import ctypes
-        from pypy.tool.udir import udir
+        from rpython.tool.udir import udir
         from rpython.translator.platform import platform
         from rpython.translator.tool.cbuild import ExternalCompilationInfo
         

rpython/rtyper/tool/test/test_rffi_platform.py

 from rpython.rtyper.tool import rffi_platform
 from rpython.rtyper.lltypesystem import lltype
 from rpython.rtyper.lltypesystem import rffi
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
 from rpython.translator.platform import platform
 from rpython.rlib.rarithmetic import r_uint, r_longlong, r_ulonglong

rpython/rtyper/tool/test/test_rfficache.py

 
 from rpython.rtyper.tool.rfficache import *
 from rpython.rtyper.lltypesystem import rffi
-from pypy.tool.udir import udir
+from rpython.tool.udir import udir
 
 def test_sizeof_c_type():
     sizeofchar = sizeof_c_type('char')

rpython/tool/ansi_mandelbrot.py

+import sys
+
+from py.io import ansi_print, get_terminal_width
+
+"""
+Black       0;30     Dark Gray     1;30
+Blue        0;34     Light Blue    1;34
+Green       0;32     Light Green   1;32
+Cyan        0;36     Light Cyan    1;36
+Red         0;31     Light Red     1;31
+Purple      0;35     Light Purple  1;35
+Brown       0;33     Yellow        1;33
+Light Gray  0;37     White         1;37
+"""
+
+
+palette = [39, 34, 35, 36, 31, 33, 32, 37]
+
+
+colour_range = None # used for debugging
+
+
+def print_pixel(colour, value_range, invert=1):
+    global colour_range
+    chars = [".", ".", "+", "*", "%", "#"]
+    idx = lambda chars: (colour+1) * (len(chars) - 1) / value_range
+    if invert:
+        idx = lambda chars, idx=idx:len(chars) - 1 - idx(chars)
+    char = chars[idx(chars)]
+    ansi_colour = palette[idx(palette)]
+    ansi_print(char, ansi_colour, newline=False, flush=True)
+    #if colour_range is None:
+    #    colour_range = [colour, colour]
+    #else:
+    #    colour_range = [min(colour_range[0], colour), max(colour_range[1], colour)]
+
+
+class Mandelbrot:
+    def __init__ (self, width=100, height=28, x_pos=-0.5, y_pos=0, distance=6.75):
+        self.xpos = x_pos
+        self.ypos = y_pos
+        aspect_ratio = 1/3.
+        factor = float(distance) / width # lowering the distance will zoom in
+        self.xscale = factor * aspect_ratio
+        self.yscale = factor
+        self.iterations = 170
+        self.x = width
+        self.y = height
+        self.z0 = complex(0, 0)
+
+    def init(self):
+        self.reset_lines = False
+        xmin = self.xpos - self.xscale * self.x / 2
+        ymin = self.ypos - self.yscale * self.y / 2
+        self.x_range = [xmin + self.xscale * ix for ix in range(self.x)]
+        self.y_range = [ymin + self.yscale * iy for iy in range(self.y)]
+        
+        #print "x", self.x_range[0], self.x_range[-1]
+        #print "y", self.y_range[0], self.y_range[-1]
+
+    def reset(self, cnt):
+        self.reset_lines = cnt
+
+    def generate(self):
+        self.reset_lines = False
+        iy = 0
+        while iy < self.y:
+            ix = 0
+            while ix < self.x:
+                c = complex(self.x_range[ix], self.y_range[iy])
+                z = self.z0
+                colour = 0
+                mind = 2
+
+                for i in range(self.iterations):
+                    z = z * z + c
+                    d = abs(z)
+                    if d >= 2:
+                        colour = min(int(mind / 0.007), 254) + 1
+                        break
+                    else:
+                        mind = min(d, mind)
+
+                yield ix, iy, colour
+                if self.reset_lines is not False: # jump to the beginning of the line
+                    iy += self.reset_lines
+                    do_break = bool(self.reset_lines)
+                    self.reset_lines = False
+                    if do_break:
+                        break
+                    ix = 0
+                else:
+                    ix += 1
+            iy += 1
+
+
+class Driver(object):
+    zoom_locations = [
+        # x, y, "distance", range
+        (0.37865401, 0.669227668, 0.04, 111),
+        (-1.15, -0.28, 0.9, 94),
+        (-1.15, -0.28, 0.3, 58),
+        (-1.15, -0.28, 0.05, 26),
+            ]
+    def __init__(self, **kwargs):
+        self.kwargs = kwargs
+        self.zoom_location = -1
+        self.colour_range = 256
+        self.invert = True
+        self.init()
+
+    def init(self):
+        self.width = get_terminal_width() or 80 # in some envs, the py lib doesnt default the width correctly
+        self.mandelbrot = Mandelbrot(width=(self.width or 1), **self.kwargs)
+        self.mandelbrot.init()
+        self.gen = self.mandelbrot.generate()
+
+    def reset(self, cnt=0):
+        """ Resets to the beginning of the line and drops cnt lines internally. """
+        self.mandelbrot.reset(cnt)
+
+    def catchup(self):
+        """ Fills the current line. """
+        x = 0
+        while x != self.width - 1:
+            x, y, c = self.gen.next()
+            print_pixel(c, self.colour_range, self.invert)
+        print >>sys.stderr
+
+    def restart(self):
+        """ Restarts the current generator. """
+        print >>sys.stderr
+        self.init()
+
+    def dot(self):
+        """ Emits a colourful character. """
+        x = c = 0
+        try:
+            x, y, c = self.gen.next()
+            if x == 0:
+                width = get_terminal_width()
+                if width != self.width:
+                    self.init()
+        except StopIteration:
+            kwargs = self.kwargs
+            self.zoom_location += 1
+            self.zoom_location %= len(self.zoom_locations)
+            loc = self.zoom_locations[self.zoom_location]
+            kwargs.update({"x_pos": loc[0], "y_pos": loc[1], "distance": loc[2]})
+            self.colour_range = loc[3]
+            #global colour_range
+            #print colour_range, loc[2]
+            #colour_range = None
+            return self.restart()
+        print_pixel(c, self.colour_range, self.invert)
+        if x == self.width - 1:
+            print >>sys.stderr
+
+
+if __name__ == '__main__':
+    import random
+    from time import sleep
+
+    d = Driver()
+    for x in xrange(15000):
+        sleep(random.random() / 300)
+        d.dot()
+        if 0 and random.random() < 0.01:
+            d.catchup()
+            print "WARNING! " * 3
+            d.reset(1)
+        #    print "R",
+        if 0 and random.random() < 0.01:
+            string = "WARNING! " * 3
+            d.jump(len(string))
+            print string,
+

rpython/tool/ansi_print.py

+"""
+A color print.
+"""
+
+import sys
+from py.io import ansi_print
+from rpython.tool.ansi_mandelbrot import Driver
+
+class AnsiLog:
+    wrote_dot = False # XXX sharing state with all instances
+
+    KW_TO_COLOR = {
+        # color supress
+        'red': ((31,), True),
+        'bold': ((1,), True),
+        'WARNING': ((31,), False),
+        'event': ((1,), True),
+        'ERROR': ((1, 31), False),
+        'Error': ((1, 31), False),
+        'info': ((35,), False),
+        'stub': ((34,), False),
+    }
+
+    def __init__(self, kw_to_color={}, file=None):
+        self.kw_to_color = self.KW_TO_COLOR.copy()
+        self.kw_to_color.update(kw_to_color)
+        self.file = file
+        self.fancy = True
+        self.isatty = getattr(sys.stderr, 'isatty', lambda: False)
+        if self.fancy and self.isatty(): 
+            self.mandelbrot_driver = Driver()
+        else:
+            self.mandelbrot_driver = None
+
+    def __call__(self, msg):
+        tty = self.isatty()
+        flush = False
+        newline = True
+        keywords = []
+        esc = []
+        for kw in msg.keywords:
+            color, supress = self.kw_to_color.get(kw, (None, False))
+            if color:
+                esc.extend(color)
+            if not supress:
+                keywords.append(kw)
+        if 'start' in keywords:
+            if tty:
+                newline = False
+                flush = True
+                keywords.remove('start')
+        elif 'done' in keywords:
+            if tty:
+                print >> sys.stderr
+                return
+        elif 'dot' in keywords:
+            if tty:
+                if self.fancy:
+                    if not AnsiLog.wrote_dot:
+                        self.mandelbrot_driver.reset()
+                    self.mandelbrot_driver.dot()
+                else:
+                    ansi_print(".", tuple(esc), file=self.file, newline=False, flush=flush)
+                AnsiLog.wrote_dot = True
+                return
+        if AnsiLog.wrote_dot:
+            AnsiLog.wrote_dot = False
+            sys.stderr.write("\n")
+        esc = tuple(esc)
+        for line in msg.content().splitlines():
+            ansi_print("[%s] %s" %(":".join(keywords), line), esc, 
+                       file=self.file, newline=newline, flush=flush)
+
+ansi_log = AnsiLog()

rpython/tool/ansicolor.py

+class colors:
+    black = '30'
+    darkred = '31'
+    darkgreen = '32'    
+    brown = '33'
+    darkblue = '34'
+    purple = '35'
+    teal = '36'
+    lightgray = '37'
+    darkgray = '30;01'
+    red = '31;01'
+    green = '32;01'
+    yellow = '33;01'
+    blue = '34;01'
+    fuchsia = '35;01'
+    turquoise = '36;01'
+    white = '37;01'
+
+def setcolor(s, color):
+    return '\x1b[%sm%s\x1b[00m' % (color, s)
+
+for name in colors.__dict__:
+    if name.startswith('_'):
+        continue
+    exec """
+def %s(s):
+    return setcolor(s, colors.%s)
+""" % (name, name)