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


Python Vasp.files方法代码示例

本文整理汇总了Python中pylada.vasp.Vasp.files方法的典型用法代码示例。如果您正苦于以下问题:Python Vasp.files方法的具体用法?Python Vasp.files怎么用?Python Vasp.files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pylada.vasp.Vasp的用法示例。


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

示例1: test_copy_files

# 需要导入模块: from pylada.vasp import Vasp [as 别名]
# 或者: from pylada.vasp.Vasp import files [as 别名]
def test_copy_files():
    from tempfile import mkdtemp
    from shutil import rmtree
    from os import makedirs
    from os.path import exists, join
    from pylada.vasp import Vasp

    directory = mkdtemp()
    if exists(directory):
        rmtree(directory)
    makedirs(directory)
    makedirs(join(directory, 'indir'))
    with open(join(directory, 'indir', 'infile'), 'w') as file:
        file.write('hello')
    with open(join(directory, 'indir', 'this'), 'w') as file:
        file.write('hello')
    with open(join(directory, 'indir', 'that'), 'w') as file:
        file.write('hello')
    try:
        vasp = Vasp()
        # Shouldn't copy yet
        vasp._copy_additional_files(outdir=join(directory, 'outdir'))
        assert not exists(join(directory, 'outdir', 'infile'))
        assert not exists(join(directory, 'outdir', 'this'))
        assert not exists(join(directory, 'outdir', 'that'))
        # Now should copy
        vasp.files = join(directory, 'indir', 'infile')
        vasp._copy_additional_files(outdir=join(directory, 'outdir'))
        assert exists(join(directory, 'outdir', 'infile'))
        assert not exists(join(directory, 'outdir', 'this'))
        assert not exists(join(directory, 'outdir', 'that'))
        # Do it again, should be fine
        vasp._copy_additional_files(outdir=join(directory, 'outdir'))
        assert exists(join(directory, 'outdir', 'infile'))
        # Copy mutliple files
        vasp.files = [
            join(directory, 'indir', u) for u in ['infile', 'this', 'that']
        ]
        vasp._copy_additional_files(outdir=join(directory, 'outdir'))
        assert exists(join(directory, 'outdir', 'infile'))
        assert exists(join(directory, 'outdir', 'this'))
        assert exists(join(directory, 'outdir', 'that'))

    finally:
        if directory != '/tmp/test':
            rmtree(directory)
开发者ID:pylada,项目名称:pylada-light,代码行数:48,代码来源:test_copyfiles.py


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