Exemple #1
0
def test_colors():
    style = color.color_style()
    style.ERROR = termcolors.make_style(fg='red', opts=('bold',))
    style.INFO = termcolors.make_style(fg='blue')
    style.OK = termcolors.make_style(fg='green')
    style.WARNING = termcolors.make_style(fg='yellow')

    print style.ERROR('I am red and bold')
    print style.INFO('I am blue')
    print style.OK('I am green')
    print style.WARNING('I am yellow')
Exemple #2
0
def color_style():
    """Returns a Style object with the Django color scheme."""
    if not supports_color():
        return no_style()
    class dummy: pass
    style = dummy()
    style.ERROR = termcolors.make_style(fg='red', opts=('bold',))
    style.ERROR_OUTPUT = termcolors.make_style(fg='red', opts=('bold',))
    style.NOTICE = termcolors.make_style(fg='red')
    style.SQL_FIELD = termcolors.make_style(fg='green', opts=('bold',))
    style.SQL_COLTYPE = termcolors.make_style(fg='green')
    style.SQL_KEYWORD = termcolors.make_style(fg='yellow')
    style.SQL_TABLE = termcolors.make_style(opts=('bold',))
    return style
Exemple #3
0
import os, sys, re
import unittest

from termcolors import make_style

sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), '..')))

expected_re = re.compile(r'\s*#\s*!expected\s*')
expected_end_re = re.compile(r'\s*#\s*!\s*')

should_re = re.compile(r'\s*#\s*([.\w\d]+):(\d+):([\w,]+)\s*')
newline_re = re.compile(r'\r?\n')

from parser import parsestring, readmk, TYPE_TARGET, TYPE_VARIABLE

makeid_ = make_style(fg='green', opts=('bold',))
comment_ = make_style(fg='green')
lang_ = make_style(fg='green', opts=('underscore',))
err_ = make_style(fg='red')

def _desc(name, type):
    type = int(type)
    if type == TYPE_TARGET:
        return "target `%s`" % name
    elif type == TYPE_VARIABLE:
        return "variable `%s`" % name
    return "Expr %s" % name

def _id(name, type):
    return "%s:%s" % (name, str(type))