Example #1
0
    def copyAsset(self, src, dst, copy_archiveinfo=False, **kw):
        """ copy folder / file and associated manifest/subfiles, not include archives

        don't keep stat
        """
        if self.isfile(src):
            self.copyfile(src, dst)
        else:
            # copy folder
            if not self.exists(dst):
                self.makedirs(dst)
            for name in self.listdir(src):
                self.copyAsset(self.joinpath(src, name), self.joinpath(dst, name), copycache=0)

        # TODO : should be more generic, copy all file/folder except archived

        # copy manifest
        # generate new uid when copy
        if self.version == '':
            self.genManifestUID(dst, self.getManifest(src) )

            # copy subfiles too
            srcSubfolder = self.subfilespath(src)
            if self.exists(srcSubfolder):
                dstSubfolder = self.subfilespath(dst)
                m_dir_path = self.dirname(dstSubfolder)
                if not self.exists(m_dir_path):
                    self.makedirs(m_dir_path)
                self.copytree(srcSubfolder, dstSubfolder)
        elif self.version == 'json':
            metadata = self.getMetadata(src)
            # how to uid?
            #复制后的新id为0,将在其他地方以intid替换
            metadata['zope']['id'] = 0
            self.saveMetadata(dst, metadata)

        # copy archiveinfo file
        if copy_archiveinfo:
            srcArchivePath = self.archiveinfopath(src)
            if self.exists(srcArchivePath):
                dstArchivePath = self.archiveinfopath(dst)
                m_dir_path = self.dirname(dstArchivePath)
                if not self.exists(m_dir_path):
                    self.makedirs(m_dir_path)
                self.copyfile(srcArchivePath, dstArchivePath)

        # copy cache
        CacheMixin.copyCache(self, src,dst)
Example #2
0
    def copyAsset(self, src, dst, **kw):
        """ copy folder / file and associated subfiles, not include archives

        don't keep stat
        """
        if self.isfile(src):
            self.copyfile(src, dst)
        else:
            # copy folder
            if not self.exists(dst):
                self.makedirs(dst)
            for name in self.listdir(src):
                self.copyAsset(self.joinpath(src, name), self.joinpath(dst, name), copycache=0)

        # copy cache
        CacheMixin.copyCache(self, src,dst)
Example #3
0
    def copyAsset(self, src, dst, **kw):
        """ copy folder / file and associated subfiles, not include archives

        don't keep stat
        """
        if self.isfile(src):
            self.copyfile(src, dst)
        else:
            # copy folder
            if not self.exists(dst):
                self.makedirs(dst)
            for name in self.listdir(src):
                self.copyAsset(self.joinpath(src, name),
                               self.joinpath(dst, name),
                               copycache=0)

        # copy cache
        CacheMixin.copyCache(self, src, dst)