當前位置: 首頁>>代碼示例>>Python>>正文


Python Dotfiles.move方法代碼示例

本文整理匯總了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'))
開發者ID:IvanMalison,項目名稱:dotfiles-1,代碼行數:27,代碼來源:test_basic.py

示例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)
開發者ID:jeffrey4l,項目名稱:dotfiles,代碼行數:54,代碼來源:test_basic.py


注:本文中的dotfiles.core.Dotfiles.move方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。