Example #1
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')
Example #2
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')
Example #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")
Example #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)
Example #5
0
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)
Example #6
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)
Example #7
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)
Example #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)
Example #9
0
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)
Example #10
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)
Example #11
0
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)
Example #12
0
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)
Example #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)
Example #14
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)
Example #15
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)
Example #16
0
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)
Example #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)
Example #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)
Example #19
0
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)
Example #20
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)
Example #21
0
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)
Example #22
0
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)
Example #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)