コード例 #1
0
ファイル: test_loader.py プロジェクト: unixnut/rainbow
def load_from_command_line(args):
    stdout_builder = TransformerBuilder()
    stderr_builder = TransformerBuilder()
    errors = []

    ConfigLoader(stdout_builder=stdout_builder,
                 stderr_builder=stderr_builder,
                 paths=['tests/data/cfg'],
                 error_handler=errors.append) \
        .load_config_from_command_line(args)

    return stdout_builder.build(), stderr_builder.build(), errors
コード例 #2
0
ファイル: test_loader.py プロジェクト: unixnut/rainbow
def load_by_name(config):
    stdout_builder = TransformerBuilder()
    stderr_builder = TransformerBuilder()
    errors = []

    ConfigLoader(stdout_builder=stdout_builder,
                 stderr_builder=stderr_builder,
                 paths=['tests/data/cfg'],
                 error_handler=errors.append) \
        .load_config_by_name(config)

    return stdout_builder.build(), stderr_builder.build(), errors
コード例 #3
0
ファイル: test_parser.py プロジェクト: unixnut/rainbow
def parse(config):
    stdout_builder = TransformerBuilder()
    stderr_builder = TransformerBuilder()
    errors = []

    ConfigParser(stdout_builder=stdout_builder,
                 stderr_builder=stderr_builder,
                 paths=None,
                 error_handler=errors.append) \
        .parse_file(config)

    return stdout_builder.build(), stderr_builder.build(), errors
コード例 #4
0
ファイル: test_builtin.py プロジェクト: nicoulaj/rainbow
def load_builtin_config(config):
    stdout_builder = TransformerBuilder()
    errors = []
    ConfigLoader(stdout_builder=stdout_builder,
                 stderr_builder=DummyTransformerBuilder(),
                 paths=['rainbow/config/builtin'],
                 error_handler=errors.append) \
        .load_config_by_name(config)
    return stdout_builder.build(), errors
コード例 #5
0
ファイル: test_builtin.py プロジェクト: dirkakrid/rainbow-1
def load_builtin_config(config):
    stdout_builder = TransformerBuilder()
    errors = []
    ConfigLoader(stdout_builder=stdout_builder,
                 stderr_builder=DummyTransformerBuilder(),
                 paths=['rainbow/config/builtin'],
                 error_handler=errors.append) \
        .load_config_by_name(config, )
    return stdout_builder.build(), errors
コード例 #6
0
ファイル: test_transformer.py プロジェクト: nicoulaj/rainbow
def test_transformer_builder():
    builder = TransformerBuilder()
    builder.add_mapping("test1", FILTERS_BY_NAME['foreground-red'])
    builder.add_mapping("test2", FILTERS_BY_NAME['background-green-before'])
    builder.add_mapping("test3", FILTERS_BY_NAME['foreground-yellow-after'])
    transformer = builder.build()
    assert isinstance(transformer, ListTransformer)
    assert isinstance(transformer.transformers[0], InsertBeforeAndAfterRegexTransformer)
    assert transformer.transformers[0].regex.pattern == 'test1'
    assert transformer.transformers[0].before == ansi.ANSI_FOREGROUND_RED
    assert transformer.transformers[0].after == ansi.ANSI_FOREGROUND_RESET
    assert isinstance(transformer.transformers[1], InsertBeforeRegexTransformer)
    assert transformer.transformers[1].regex.pattern == 'test2'
    assert transformer.transformers[1].before == ansi.ANSI_BACKGROUND_GREEN
    assert isinstance(transformer.transformers[2], InsertAfterRegexTransformer)
    assert transformer.transformers[2].regex.pattern == 'test3'
    assert transformer.transformers[2].after == ansi.ANSI_FOREGROUND_YELLOW
コード例 #7
0
ファイル: test_transformer.py プロジェクト: unixnut/rainbow
def test_transformer_builder():
    builder = TransformerBuilder()
    builder.add_mapping("test1", FILTERS_BY_NAME['foreground-red'])
    builder.add_mapping("test2", FILTERS_BY_NAME['background-green-before'])
    builder.add_mapping("test3", FILTERS_BY_NAME['foreground-yellow-after'])
    transformer = builder.build()
    assert isinstance(transformer, ListTransformer)
    assert isinstance(transformer.transformers[0],
                      InsertBeforeAndAfterRegexTransformer)
    assert transformer.transformers[0].regex.pattern == 'test1'
    assert transformer.transformers[0].before == ansi.ANSI_FOREGROUND_RED
    assert transformer.transformers[0].after == ansi.ANSI_FOREGROUND_RESET
    assert isinstance(transformer.transformers[1],
                      InsertBeforeRegexTransformer)
    assert transformer.transformers[1].regex.pattern == 'test2'
    assert transformer.transformers[1].before == ansi.ANSI_BACKGROUND_GREEN
    assert isinstance(transformer.transformers[2], InsertAfterRegexTransformer)
    assert transformer.transformers[2].regex.pattern == 'test3'
    assert transformer.transformers[2].after == ansi.ANSI_FOREGROUND_YELLOW