当前位置: 首页>>代码示例>>Python>>正文


Python shlib.rm函数代码示例

本文整理汇总了Python中shlib.rm函数的典型用法代码示例。如果您正苦于以下问题:Python rm函数的具体用法?Python rm怎么用?Python rm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rm函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_ls_abominate

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')
开发者ID:KenKundert,项目名称:shlib,代码行数:26,代码来源:test_ls.py

示例2: test_rm_endorse

def test_rm_endorse():
    """remove nonexistent file"""
    # setup
    f1 = to_path('f1')

    # run test
    rm(f1)

    # check
    assert not f1.exists()
开发者ID:KenKundert,项目名称:shlib,代码行数:10,代码来源:test_rm.py

示例3: test_rm_downturn

def test_rm_downturn():
    """remove existing file"""
    # setup
    f1 = to_path('f1')
    touch(f1)

    # run test
    rm(f1)

    # check
    assert not f1.exists()
开发者ID:KenKundert,项目名称:shlib,代码行数:11,代码来源:test_rm.py

示例4: cleanup

 def cleanup(self):
     if self.vim:
         self.vim.kill()
         for each in cull([self.file1, self.file2, self.file3, self.file4]):
             path = to_path(each)
             dn = path.parent
             fn = path.name
             swpfile = to_path(dn, '.' + fn + '.swp')
             try:
                 rm(swpfile)
             except OSError as e:
                 error(os_error(e))
开发者ID:KenKundert,项目名称:vdiff,代码行数:12,代码来源:vdiff.py

示例5: test_mkdir_cymbal

def test_mkdir_cymbal():
    """attempt to make a directory over an existing file"""
    # setup
    f1 = to_path('f1')
    touch(f1)

    # run test
    with pytest.raises(OSError):
        mkdir(f1)

    # cleanup
    rm(f1)
开发者ID:KenKundert,项目名称:shlib,代码行数:12,代码来源:test_mkdir.py

示例6: test_mkdir_solstice

def test_mkdir_solstice():
    """attempt to make a directory and it parent directories"""
    # setup
    d1d1 = to_path('d1/d1')

    # run test
    mkdir(d1d1)

    # check
    assert d1d1.is_dir()

    # cleanup
    rm(d1d1)
开发者ID:KenKundert,项目名称:shlib,代码行数:13,代码来源:test_mkdir.py

示例7: test_touch_endorse

def test_touch_endorse():
    """touch a new file"""
    # setup
    f1 = to_path('f1')

    # run test
    touch(f1)

    # check
    assert f1.is_file()

    # cleanup
    rm(f1)
开发者ID:KenKundert,项目名称:shlib,代码行数:13,代码来源:test_touch.py

示例8: test_mkdir_downturn

def test_mkdir_downturn():
    """make a directory"""
    # setup
    d1 = to_path('d1')

    # run test
    mkdir(d1)

    # check
    assert d1.is_dir()

    # cleanup
    rm(d1)
开发者ID:KenKundert,项目名称:shlib,代码行数:13,代码来源:test_mkdir.py

示例9: test_rm_ground

def test_rm_ground():
    """remove two files"""
    # setup
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')
    touch(f2)

    # run test
    rm(f1, f2)

    # check
    assert not f1.exists()
    assert not f2.exists()
开发者ID:KenKundert,项目名称:shlib,代码行数:14,代码来源:test_rm.py

示例10: test_ln_ground

def test_ln_ground():
    """link to a pre-existing name"""
    # setup
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')
    touch(f2)

    # run test
    with pytest.raises(OSError):
        ln(f1, f2)

    # cleanup
    rm(f1, f2)
开发者ID:KenKundert,项目名称:shlib,代码行数:14,代码来源:test_ln.py

示例11: test_mkdir_brain

def test_mkdir_brain():
    """attempt to make a directory over an existing directory"""
    # setup
    d1d1 = to_path('d1/d1')
    mkdir(d1d1)

    # run test
    mkdir(d1d1)

    # check
    assert d1d1.is_dir()

    # cleanup
    rm(d1d1)
开发者ID:KenKundert,项目名称:shlib,代码行数:14,代码来源:test_mkdir.py

示例12: test_ln_endorse

def test_ln_endorse():
    """link a nonexistent file"""
    # setup
    f1 = to_path('f1')
    f2 = to_path('f2')

    # run test
    ln(f1, f2)

    # check
    assert f2.is_symlink()

    # cleanup
    rm(f1, f2)
开发者ID:KenKundert,项目名称:shlib,代码行数:14,代码来源:test_ln.py

示例13: test_touch_downturn

def test_touch_downturn():
    """touch an existing file"""
    # setup
    f1 = to_path('f1')
    touch(f1)

    # run test
    touch(f1)

    # check
    assert f1.is_file()

    # cleanup
    rm(f1)
开发者ID:KenKundert,项目名称:shlib,代码行数:14,代码来源:test_touch.py

示例14: test_mkdir_gathering

def test_mkdir_gathering():
    """attempt to make a directory over an existing file"""
    # setup
    d1 = to_path('d1')
    mkdir(d1)

    # run test
    mkdir(d1)

    # check
    assert d1.is_dir()

    # cleanup
    rm(d1)
开发者ID:KenKundert,项目名称:shlib,代码行数:14,代码来源:test_mkdir.py

示例15: test_mkdir_ground

def test_mkdir_ground():
    """make two directories"""
    # setup
    d1 = to_path('d1')
    d2 = to_path('d2')

    # run test
    mkdir([d1, d2])

    # check
    assert d1.is_dir()
    assert d2.is_dir()

    # cleanup
    rm(d1, d2)
开发者ID:KenKundert,项目名称:shlib,代码行数:15,代码来源:test_mkdir.py


注:本文中的shlib.rm函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。