コード例 #1
0
ファイル: fallback.py プロジェクト: broiledmeat/pydgeot
 def generate(self, path):
     rel = os.path.relpath(path, self.app.source_root)
     target = os.path.join(self.app.build_root, rel)
     os.makedirs(os.path.dirname(target), exist_ok=True)
     if self._is_copy_path(path):
         shutil.copy2(path, target)
     elif self._is_symlink_path(path):
         create_symlink(path, target)
     self.app.sources.set_targets(path, [target])
コード例 #2
0
def test_create_symlink(temp_dir):
    from pydgeot.filesystem import create_symlink

    with open(os.path.join(temp_dir, 'test'), 'w') as fh:
        sym_path = os.path.join(temp_dir, 'test_sym')
        create_symlink(fh.name, sym_path)
        assert os.path.isfile(sym_path)

        if sys.platform != 'win32':
            assert os.path.islink(sym_path)
コード例 #3
0
    def generate(self, path):
        from .dirconfig import DirConfig

        if path in self._generate_files:
            config = DirConfig.get(self.app, path)
            if not config.is_valid:
                return

            target_path = self.app.target_path(path)

            os.makedirs(os.path.dirname(target_path), exist_ok=True)
            if config.use_symlinks:
                create_symlink(path, target_path)
            else:
                shutil.copy2(path, target_path)

            # Generate thumbnail
            thumb_path = self._generate_thumbnail(config, path)
            if thumb_path is not None:
                self.app.sources.set_targets(path, [target_path, thumb_path])