• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python shlib.to_path函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了to_path函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: initialize

    def initialize(cls,
        gpg_path=None, gpg_home=None, armor=None
    ):
        from .config import get_setting, override_setting

        cls.gpg_path = to_path(
            gpg_path if gpg_path else get_setting('gpg_executable')
        )
        override_setting('gpg_executable', cls.gpg_path)

        cls.gpg_home = to_path(
            gpg_home if gpg_home else get_setting('gpg_home')
        )
        override_setting('gpg_home', cls.gpg_home)

        armor = armor if armor is not None else get_setting('gpg_armor')
        if armor not in ARMOR_CHOICES:
            warn(
                "'%s' is not valid, choose from %s." % (
                    armor, conjoin(ARMOR_CHOICES)
                ), culprit=(get_setting('config_file'), 'gpg_armor')
            )
            armor = None
        cls.armor = armor
        override_setting('gpg_armor', armor)

        gpg_args = {}
        if cls.gpg_path:
            gpg_args.update({'gpgbinary': str(cls.gpg_path)})
        if cls.gpg_home:
            gpg_args.update({'gnupghome': str(cls.gpg_home)})
        cls.gpg = gnupg.GPG(**gpg_args)
开发者ID:KenKundert,项目名称:avendesora,代码行数:32,代码来源:gpg.py


示例3: test_mv_ground

def test_mv_ground():
    """rename nonexistent file"""
    # setup
    f1 = to_path('f1')
    f2 = to_path('f2')

    # run test
    with pytest.raises(IOError):
        mv(f1, f2)
开发者ID:KenKundert,项目名称:shlib,代码行数:9,代码来源:test_mv.py


示例4: test_cp_ground

def test_cp_ground():
    """copy nonexistent file to new file"""
    # setup
    f1 = to_path('f1')
    f2 = to_path('f2')

    # run test
    with pytest.raises(IOError):
        cp(f1, f2)
开发者ID:KenKundert,项目名称:shlib,代码行数:9,代码来源:test_cp.py


示例5: 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


示例6: 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


示例7: 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


示例8: 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


示例9: test_cartesian_product_negative

def test_cartesian_product_negative():
    """cartesian product of paths"""
    # run test
    paths = cartesian_product(
        [to_path('A'), to_path('B'), to_path('C')],
        ['a', 'b', 'c'],
        'f'
    )

    # check
    assert set(str(p) for p in paths) == set([
        'A/a/f', 'A/b/f', 'A/c/f',
        'B/a/f', 'B/b/f', 'B/c/f',
        'C/a/f', 'C/b/f', 'C/c/f',
    ])
开发者ID:KenKundert,项目名称:shlib,代码行数:15,代码来源:test_cartesian_product.py


示例10: test_touch_cymbal

def test_touch_cymbal():
    """touch multiple files"""
    # setup
    f1 = to_path('f1')
    f2 = to_path('f2')

    # run test
    touch([f1, f2])

    # check
    assert f1.is_file()
    assert f2.is_file()

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


示例11: test_mv_cymbal

def test_mv_cymbal():
    """move two files to a new directory"""
    # setup
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')
    touch(f2)
    d1 = to_path('d2')

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

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


示例12: 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


示例13: test_mv_incense

def test_mv_incense():
    """move two files into a nonexistent directory"""
    # setup
    d1 = to_path('d1')
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')
    touch(f2)

    # run test
    with pytest.raises(OSError):
        mv([f1, f2], d1)

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


示例14: test_cp_cymbal

def test_cp_cymbal():
    """copy two files to a new directory"""
    # setup
    d1 = to_path('d1')
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')
    touch(f2)

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

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


示例15: test_cp_downturn

def test_cp_downturn():
    """copy file to new file"""
    # setup
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')

    # run test
    cp(f1, f2)

    # check
    assert f2.is_file()

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


示例16: test_rm_cymbal

def test_rm_cymbal():
    """remove directory"""
    # setup
    d1 = to_path('d1')
    mkdir(d1)
    d1f1 = to_path('d1/f1')
    touch(d1f1)
    f2 = to_path('f2')
    touch(f2)

    # run test
    rm(d1, f2)

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


示例17: read_defaults

 def read_defaults(self):
     settings = {}
     try:
         from appdirs import user_config_dir
         config_file = to_path(user_config_dir('vdiff'), 'config')
         try:
             code = config_file.read_text()
             try:
                 compiled = compile(code, str(config_file), 'exec')
                 exec(compiled, settings)
             except Exception as e:
                 error(e, culprit=config_file)
         except FileNotFoundError:
             pass
         except OSError as e:
             warn(os_error(e))
         if self.useGUI is not None:
             settings['gui'] = self.useGUI
     except ImportError:
         pass
     if settings.get('gui', DEFAULT_GUI):
         if 'DISPLAY' not in os.environ:
             warn('$DISPLAY not set, ignoring request for gvim.')
         else:
             self.cmd = settings.get('gvimdiff', DEFAULT_GVIM)
             return
     self.cmd = settings.get('vimdiff', DEFAULT_VIM)
开发者ID:KenKundert,项目名称:vdiff,代码行数:27,代码来源:vdiff.py


示例18: test_lsf_rissole

def test_lsf_rissole():
    """list files"""
    # setup
    f1 = to_path("f1")
    touch(f1)
    f2 = to_path("f2")
    touch(f2)

    # run test
    files = lsf(f1, f2)

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

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


示例19: test_lsf_narrow

def test_lsf_narrow():
    """list files with select constraint"""
    # setup
    f1 = to_path("f1")
    touch(f1)
    f2 = to_path("f2")
    touch(f2)

    # run test
    files = lsf(f1, f2, select="*2")

    # check
    assert set(str(f) for f in files) == set(["f2"])

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


示例20: test_mv_ruminate

def test_mv_ruminate():
    """move two files into an existing file"""
    # setup
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')
    touch(f2)
    f3 = to_path('f2')
    touch(f3)

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

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python shlib.touch函数代码示例发布时间:2022-05-27
下一篇:
Python shlib.rm函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap