예제 #1
0
파일: __init__.py 프로젝트: ush98/dvc
def _prettify(entries, with_color=False):
    if with_color:
        ls_colors = LsColors()
        fmt = ls_colors.format
    else:

        def fmt(entry):
            return entry["path"]

    return [fmt(entry) for entry in entries]
예제 #2
0
def test_ls_repo_with_custom_color_env_defined(monkeypatch):
    monkeypatch.setenv("LS_COLORS", "rs=0:di=01;34:*.xml=01;31:*.dvc=01;33:")
    ls_colors = LsColors()
    colorizer = colorize(ls_colors)

    assert colorizer(".dvcignore") == ".dvcignore"
    assert colorizer(".gitignore") == ".gitignore"
    assert colorizer("README.md") == "README.md"
    assert colorizer("data", "d") == "\x1b[01;34mdata\x1b[0m"
    assert colorizer("structure.xml") == "\x1b[01;31mstructure.xml\x1b[0m"
    assert (
        colorizer("structure.xml.dvc") == "\x1b[01;33mstructure.xml.dvc\x1b[0m"
    )
def test_ls_colors_ext():
    ls_colors = LsColors(LsColors.default + ":*.xml=01;33")
    assert colorize(ls_colors)("file.xml") == "\x1b[01;33mfile.xml\x1b[0m"
def test_ls_colors_exec():
    ls_colors = LsColors(LsColors.default)
    assert (colorize(ls_colors)("script.sh",
                                "e") == "\x1b[01;32mscript.sh\x1b[0m")
def test_ls_colors_dir():
    ls_colors = LsColors(LsColors.default)
    assert colorize(ls_colors)("dir", "d") == "\x1b[01;34mdir\x1b[0m"
def test_ls_colors_file():
    ls_colors = LsColors(LsColors.default)
    assert colorize(ls_colors)("file") == "file"