本文整理汇总了Python中dotfiles.core.Dotfiles.move方法的典型用法代码示例。如果您正苦于以下问题:Python Dotfiles.move方法的具体用法?Python Dotfiles.move怎么用?Python Dotfiles.move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dotfiles.core.Dotfiles
的用法示例。
在下文中一共展示了Dotfiles.move方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_move_repository
# 需要导入模块: from dotfiles.core import Dotfiles [as 别名]
# 或者: from dotfiles.core.Dotfiles import move [as 别名]
def test_move_repository(self):
"""Test the move() method for a Dotfiles repository."""
touch(os.path.join(self.repository, 'bashrc'))
dotfiles = Dotfiles(
homedir=self.homedir, path=self.repository,
prefix='', ignore=[], force=True, externals={}, packages=[],
dry_run=False)
dotfiles.sync()
# Make sure sync() did the right thing.
self.assertPathEqual(
os.path.join(self.homedir, '.bashrc'),
os.path.join(self.repository, 'bashrc'))
target = os.path.join(self.homedir, 'MyDotfiles')
dotfiles.move(target)
self.assertTrue(os.path.exists(os.path.join(target, 'bashrc')))
self.assertPathEqual(
os.path.join(self.homedir, '.bashrc'),
os.path.join(target, 'bashrc'))
示例2: test_packages
# 需要导入模块: from dotfiles.core import Dotfiles [as 别名]
# 或者: from dotfiles.core.Dotfiles import move [as 别名]
def test_packages(self):
"""
Test packages.
"""
files = ['foo', 'package/bar', 'package2/foo/bar']
symlinks = ['.foo', '.package/bar', '.package2/foo/bar']
join = os.path.join
# Create files
for filename in files:
path = join(self.repository, filename)
dirname = os.path.dirname(path)
if not os.path.exists(dirname):
os.makedirs(dirname)
touch(path)
# Create Dotfiles object
dotfiles = Dotfiles(
homedir=self.homedir, path=self.repository,
prefix='', ignore=[], externals={},
packages=set(['package', 'package2/foo']), dry_run=False)
# Create symlinks in homedir
dotfiles.sync()
# Verify it created what we expect
for folder in ['.package', '.package2', '.package2/foo']:
self.assertTrue(os.path.isdir(join(self.homedir, folder)))
def check_all(files, symlinks):
for src, dst in zip(files, symlinks):
self.assertTrue(is_link_to(join(self.homedir, dst),
join(self.repository, src)))
check_all(files, symlinks)
# Add files to the repository
new_files = [join(self.homedir, f) for f in
['.bar', '.package/foo', '.package2/foo/bar2']]
for filename in new_files:
path = join(self.homedir, filename)
touch(path)
new_repo_files = ['bar', 'package/foo', 'package2/foo/bar2']
dotfiles.add(new_files)
check_all(files + new_repo_files, symlinks + new_files)
# Remove them from the repository
dotfiles.remove(new_files)
check_all(files, symlinks)
# Move the repository
self.repository = join(self.homedir, 'Dotfiles2')
dotfiles.move(self.repository)
check_all(files, symlinks)