本文整理汇总了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)