예제 #1
0
파일: test_ls.py 프로젝트: vdo-lab/shlib
def test_ls_abominate():
    """recursive list of directory"""
    # setup
    mkdir('work')
    with cd('work'):
        d1 = to_path('d1')
        mkdir(d1)
        d1d1 = to_path('d1/d1')
        mkdir(d1d1)
        d1d2 = to_path('d1/d2')
        mkdir(d1d2)
        d1d1f1 = to_path('d1/d1/f1')
        touch(d1d1f1)
        d1d2f2 = to_path('d1/d2/f2')
        touch(d1d2f2)

        # run test
        paths = ls('.', select='**/*')

        # check
        assert set(str(f) for f in paths) == set(
            ['d1', 'd1/d1', 'd1/d2', 'd1/d1/f1', 'd1/d2/f2'])

    # cleanup
    rm('work')
예제 #2
0
파일: test_ls.py 프로젝트: KenKundert/shlib
def test_ls_abominate():
    """recursive list of directory"""
    # setup
    mkdir('work')
    with cd('work'):
        d1 = to_path('d1')
        mkdir(d1)
        d1d1 = to_path('d1/d1')
        mkdir(d1d1)
        d1d2 = to_path('d1/d2')
        mkdir(d1d2)
        d1d1f1 = to_path('d1/d1/f1')
        touch(d1d1f1)
        d1d2f2 = to_path('d1/d2/f2')
        touch(d1d2f2)

        # run test
        paths = ls('.', select='**/*')

        # check
        assert set(str(f) for f in paths) == set(
           ['d1', 'd1/d1', 'd1/d2', 'd1/d1/f1', 'd1/d2/f2']
        )

    # cleanup
    rm('work')
예제 #3
0
def test_ls_abominate():
    """recursive list of directory"""
    # setup
    mkdir("work")
    with cd("work"):
        d1 = to_path("d1")
        mkdir(d1)
        d1d1 = to_path("d1/d1")
        mkdir(d1d1)
        d1d2 = to_path("d1/d2")
        mkdir(d1d2)
        d1d1f1 = to_path("d1/d1/f1")
        touch(d1d1f1)
        d1d2f2 = to_path("d1/d2/f2")
        touch(d1d2f2)

        # run test
        paths = ls(".", select="**/*")

        # check
        assert set(str(f) for f in paths) == set(
            ["d1", "d1/d1", "d1/d2", "d1/d1/f1", "d1/d2/f2"])

    # cleanup
    rm("work")
예제 #4
0
def archive_gpg(config, archive):
    """
    Copy `~/.gnupg` into the archive.
    """
    dest = archive / '.gnupg'; mkdir(dest)
    # Don't try to copy sockets (S.*); it won't work.
    srcs = list(ls('~/.gnupg', reject='S.*'))
    cp(srcs, dest)
예제 #5
0
파일: test_ls.py 프로젝트: vdo-lab/shlib
def test_ls_narrow():
    """list files with select constraint"""
    # setup
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')
    touch(f2)

    # run test
    paths = ls(f1, f2, select='*2')

    # check
    assert set(str(f) for f in paths) == set(['f2'])

    # cleanup
    rm(f1, f2)
예제 #6
0
파일: test_ls.py 프로젝트: vdo-lab/shlib
def test_ls_rissole():
    """list files"""
    # setup
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')
    touch(f2)

    # run test
    paths = ls(f1, f2)

    # check
    assert set(str(f) for f in paths) == set(['f1', 'f2'])

    # cleanup
    rm(f1, f2)
예제 #7
0
파일: test_ls.py 프로젝트: KenKundert/shlib
def test_ls_rissole():
    """list files"""
    # setup
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')
    touch(f2)

    # run test
    paths = ls(f1, f2)

    # check
    assert set(str(f) for f in paths) == set(['f1', 'f2'])

    # cleanup
    rm(f1, f2)
예제 #8
0
def test_ls_rissole():
    """list files"""
    # setup
    f1 = to_path("f1")
    touch(f1)
    f2 = to_path("f2")
    touch(f2)

    # run test
    paths = ls(f1, f2)

    # check
    assert set(str(f) for f in paths) == set(["f1", "f2"])

    # cleanup
    rm(f1, f2)
예제 #9
0
파일: test_ls.py 프로젝트: KenKundert/shlib
def test_ls_narrow():
    """list files with select constraint"""
    # setup
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')
    touch(f2)

    # run test
    paths = ls(f1, f2, select='*2')

    # check
    assert set(str(f) for f in paths) == set(['f2'])

    # cleanup
    rm(f1, f2)
예제 #10
0
파일: test_ls.py 프로젝트: KenKundert/shlib
def test_ls_contrast():
    """recursive list of directories in directory"""
    # setup
    d1 = to_path('d1')
    mkdir(d1)
    d1d1 = to_path('d1/d1')
    mkdir(d1d1)
    d1d2 = to_path('d1/d2')
    mkdir(d1d2)
    d1d1f1 = to_path('d1/d1/f1')
    touch(d1d1f1)
    d1d2f2 = to_path('d1/d2/f2')
    touch(d1d2f2)

    # run test
    paths = ls(d1, select='**')

    # check
    assert set(str(f) for f in paths) == set(['d1', 'd1/d1', 'd1/d2'])

    # cleanup
    rm(d1)
예제 #11
0
파일: test_ls.py 프로젝트: KenKundert/shlib
def test_ls_cadge():
    """list a directory that contains dot files while discarding hidden"""
    # setup
    d1 = to_path('d1')
    mkdir(d1)
    d1f1 = to_path('d1/.f1')
    touch(d1f1)
    d1f2 = to_path('d1/f2')
    touch(d1f2)
    d1d1 = to_path('d1/.d1')
    mkdir(d1d1)
    d1d2 = to_path('d1/d2')
    mkdir(d1d2)

    # run test
    paths = ls(d1, hidden=False)

    # check
    assert set(str(f) for f in paths) == set(['d1/d2', 'd1/f2'])

    # cleanup
    rm(d1)
예제 #12
0
파일: test_ls.py 프로젝트: vdo-lab/shlib
def test_ls_manicure():
    """list a directory that contains dot files with select constraint"""
    # setup
    d1 = to_path('d1')
    mkdir(d1)
    d1f1 = to_path('d1/.f1')
    touch(d1f1)
    d1f2 = to_path('d1/.f2')
    touch(d1f2)
    d1d1 = to_path('d1/.d1')
    mkdir(d1d1)
    d1d2 = to_path('d1/.d2')
    mkdir(d1d2)

    # run test
    paths = ls(d1)

    # check
    assert set(str(f) for f in paths) == set([])

    # cleanup
    rm(d1)
예제 #13
0
def test_ls_nunnery():
    """list a directory that contains dot files with reject constraint"""
    # setup
    d1 = to_path("d1")
    mkdir(d1)
    d1f1 = to_path("d1/.f1")
    touch(d1f1)
    d1f2 = to_path("d1/.f2")
    touch(d1f2)
    d1d1 = to_path("d1/.d1")
    mkdir(d1d1)
    d1d2 = to_path("d1/.d2")
    mkdir(d1d2)

    # run test
    paths = ls(d1, reject=".*")

    # check
    assert set(str(f) for f in paths) == set([])

    # cleanup
    rm(d1)
예제 #14
0
파일: test_ls.py 프로젝트: KenKundert/shlib
def test_ls_endorse():
    """list a directory with select constraint"""
    # setup
    d1 = to_path('d1')
    mkdir(d1)
    d1f1 = to_path('d1/f1')
    touch(d1f1)
    d1f2 = to_path('d1/f2')
    touch(d1f2)
    d1d1 = to_path('d1/d1')
    mkdir(d1d1)
    d1d2 = to_path('d1/d2')
    mkdir(d1d2)

    # run test
    paths = ls(d1, select='*2')

    # check
    assert set(str(f) for f in paths) == set(['d1/d2', 'd1/f2'])

    # cleanup
    rm(d1)
예제 #15
0
파일: test_ls.py 프로젝트: vdo-lab/shlib
def test_ls_contrast():
    """recursive list of directories in directory"""
    # setup
    d1 = to_path('d1')
    mkdir(d1)
    d1d1 = to_path('d1/d1')
    mkdir(d1d1)
    d1d2 = to_path('d1/d2')
    mkdir(d1d2)
    d1d1f1 = to_path('d1/d1/f1')
    touch(d1d1f1)
    d1d2f2 = to_path('d1/d2/f2')
    touch(d1d2f2)

    # run test
    paths = ls(d1, select='**')

    # check
    assert set(str(f) for f in paths) == set(['d1', 'd1/d1', 'd1/d2'])

    # cleanup
    rm(d1)
예제 #16
0
파일: test_ls.py 프로젝트: vdo-lab/shlib
def test_ls_cadge():
    """list a directory that contains dot files while discarding hidden"""
    # setup
    d1 = to_path('d1')
    mkdir(d1)
    d1f1 = to_path('d1/.f1')
    touch(d1f1)
    d1f2 = to_path('d1/f2')
    touch(d1f2)
    d1d1 = to_path('d1/.d1')
    mkdir(d1d1)
    d1d2 = to_path('d1/d2')
    mkdir(d1d2)

    # run test
    paths = ls(d1, hidden=False)

    # check
    assert set(str(f) for f in paths) == set(['d1/d2', 'd1/f2'])

    # cleanup
    rm(d1)
예제 #17
0
def test_ls_endorse():
    """list a directory with select constraint"""
    # setup
    d1 = to_path("d1")
    mkdir(d1)
    d1f1 = to_path("d1/f1")
    touch(d1f1)
    d1f2 = to_path("d1/f2")
    touch(d1f2)
    d1d1 = to_path("d1/d1")
    mkdir(d1d1)
    d1d2 = to_path("d1/d2")
    mkdir(d1d2)

    # run test
    paths = ls(d1, select="*2")

    # check
    assert set(str(f) for f in paths) == set(["d1/d2", "d1/f2"])

    # cleanup
    rm(d1)
예제 #18
0
def test_ls_contrast():
    """recursive list of directories in directory"""
    # setup
    d1 = to_path("d1")
    mkdir(d1)
    d1d1 = to_path("d1/d1")
    mkdir(d1d1)
    d1d2 = to_path("d1/d2")
    mkdir(d1d2)
    d1d1f1 = to_path("d1/d1/f1")
    touch(d1d1f1)
    d1d2f2 = to_path("d1/d2/f2")
    touch(d1d2f2)

    # run test
    paths = ls(d1, select="**")

    # check
    assert set(str(f) for f in paths) == set(["d1", "d1/d1", "d1/d2"])

    # cleanup
    rm(d1)
예제 #19
0
파일: test_ls.py 프로젝트: KenKundert/shlib
def test_ls_downturn():
    """list a directory"""
    # setup
    d1 = to_path('d1')
    mkdir(d1)
    d1f1 = to_path('d1/f1')
    touch(d1f1)
    d1f2 = to_path('d1/f2')
    touch(d1f2)
    d1d1 = to_path('d1/d1')
    mkdir(d1d1)
    d1d2 = to_path('d1/d2')
    mkdir(d1d2)

    # run test
    paths = ls(d1)

    # check
    assert set(str(f) for f in paths) == set(['d1/d1', 'd1/d2', 'd1/f1', 'd1/f2'])

    # cleanup
    rm(d1)
예제 #20
0
파일: test_ls.py 프로젝트: vdo-lab/shlib
def test_ls_endorse():
    """list a directory with select constraint"""
    # setup
    d1 = to_path('d1')
    mkdir(d1)
    d1f1 = to_path('d1/f1')
    touch(d1f1)
    d1f2 = to_path('d1/f2')
    touch(d1f2)
    d1d1 = to_path('d1/d1')
    mkdir(d1d1)
    d1d2 = to_path('d1/d2')
    mkdir(d1d2)

    # run test
    paths = ls(d1, select='*2')

    # check
    assert set(str(f) for f in paths) == set(['d1/d2', 'd1/f2'])

    # cleanup
    rm(d1)
예제 #21
0
파일: test_ls.py 프로젝트: KenKundert/shlib
def test_ls_manicure():
    """list a directory that contains dot files with select constraint"""
    # setup
    d1 = to_path('d1')
    mkdir(d1)
    d1f1 = to_path('d1/.f1')
    touch(d1f1)
    d1f2 = to_path('d1/.f2')
    touch(d1f2)
    d1d1 = to_path('d1/.d1')
    mkdir(d1d1)
    d1d2 = to_path('d1/.d2')
    mkdir(d1d2)

    # run test
    paths = ls(d1)

    # check
    assert set(str(f) for f in paths) == set([])

    # cleanup
    rm(d1)
예제 #22
0
파일: test_ls.py 프로젝트: vdo-lab/shlib
def test_ls_downturn():
    """list a directory"""
    # setup
    d1 = to_path('d1')
    mkdir(d1)
    d1f1 = to_path('d1/f1')
    touch(d1f1)
    d1f2 = to_path('d1/f2')
    touch(d1f2)
    d1d1 = to_path('d1/d1')
    mkdir(d1d1)
    d1d2 = to_path('d1/d2')
    mkdir(d1d2)

    # run test
    paths = ls(d1)

    # check
    assert set(str(f)
               for f in paths) == set(['d1/d1', 'd1/d2', 'd1/f1', 'd1/f2'])

    # cleanup
    rm(d1)
예제 #23
0
def test_ls_principle():
    """list a directory that contains dot files while retaining hidden"""
    # setup
    d1 = to_path("d1")
    mkdir(d1)
    d1f1 = to_path("d1/.f1")
    touch(d1f1)
    d1f2 = to_path("d1/f2")
    touch(d1f2)
    d1d1 = to_path("d1/.d1")
    mkdir(d1d1)
    d1d2 = to_path("d1/d2")
    mkdir(d1d2)

    # run test
    paths = ls(d1, hidden=True)

    # check
    assert set(str(f)
               for f in paths) == set(["d1/.d1", "d1/d2", "d1/.f1", "d1/f2"])

    # cleanup
    rm(d1)