コード例 #1
0
def test_strip_escapes():
    assert "Hi there" == strip_escapes(
        colorize("Hi there", Colors.Red, start=3)
    )

    assert strip_escapes(
        colorize("Hi", None, bold=True) +
        " there, " +
        colorize("stranger", Colors.Green, bold=True)
    ) == "Hi there, stranger"
コード例 #2
0
ファイル: test_colors.py プロジェクト: pdex/ansicolor
def test_strip_escapes():
    assert "Hi there" == strip_escapes(
        colorize("Hi there", Colors.Red, start=3)
    )

    assert strip_escapes(
        colorize("Hi", None, bold=True) +
        " there, " +
        colorize("stranger", Colors.Green, bold=True)
    ) == "Hi there, stranger"
コード例 #3
0
def test_colorize_v2():
    assert (
        get_code(Colors.Red)
        + "Hi there"
        + get_code(None)
    ) == colorize("Hi there", Colors.Red)

    assert (
        "H"
        + get_code(Colors.Red)
        + "i ther"
        + get_code(None)
        + "e"
    ) == colorize("Hi there", Colors.Red, start=1, end=7)
コード例 #4
0
def _get_colorize_formatter_map(violation):
    formatter_map = _get_formatter_map(violation)
    colorized_formatter_map = {}

    for key, value in formatter_map.items():
        if key in FORMAT_COLOR_MAP:
            Color = FORMAT_COLOR_MAP[key]
            colorized_formatter_map[key] = colorize(str(value), Color())
        else:
            colorized_formatter_map[key] = value

    return colorized_formatter_map
コード例 #5
0
ファイル: formatter.py プロジェクト: Kuniwak/vint
def _get_colorize_formatter_map(violation):
    formatter_map = _get_formatter_map(violation)
    colorized_formatter_map = {}

    for key, value in formatter_map.items():
        if key in FORMAT_COLOR_MAP:
            Color = FORMAT_COLOR_MAP[key]
            colorized_formatter_map[key] = colorize(str(value), Color())
        else:
            colorized_formatter_map[key] = value

    return colorized_formatter_map
コード例 #6
0
ファイル: test_colors.py プロジェクト: pdex/ansicolor
def test_colorize1():
    assert (
        get_code(Colors.Red)
        + "Hi there"
        + get_code(None)
    ) == colorize("Hi there", Colors.Red)
コード例 #7
0
def test_colorize1():
    assert (
        get_code(Colors.Red)
        + "Hi there"
        + get_code(None)
    ) == colorize("Hi there", Colors.Red)
コード例 #8
0
from ansicolor import Colors
from ansicolor import colorize

print(colorize('''"I'm blue", said the smurf.''', Colors.Blue, start=1, end=9))
コード例 #9
0
from ansicolor import Colors
from ansicolor import colorize

print(colorize("I'm blue", Colors.Blue))