def recycleAssets(self, path, srcNames):
     """ remove file or tree to trush folder """
     removedPath = self.removedpath(path, timetag() )
     for name in srcNames:
         srcPath = self.joinpath(path, name)
         dstPath = self.joinpath(removedPath, name)
         self.moveAsset(srcPath, dstPath)
Beispiel #2
0
    def walkTrashBox(self, top_path='/', days=0, cmp_result=0):
        """ -1: older than history day; 0: all; 1: greater than history day 

        """
        # XXX need to rewrite
        cur_date = datetime.datetime(*time.gmtime()[:7])
        history_date = cur_date - datetime.timedelta(days)
        history_date_name = timetag(history_date)

        if top_path != '/':
            removeNames = self.listRemoves(top_path)
            if cmp_result != 0:
                removeNames = [removeName for removeName in removeNames
                            if cmp(removeName, history_date_name) == cmp_result]
            if removeNames:
                yield top_path, removeNames

        for parent_path, dirnames, filenames in self.walk(top_path):
            for dirname in dirnames:
                dir_vpath = self.joinpath(parent_path, dirname)
                removeNames = self.listRemoves(dir_vpath)
                if cmp_result != 0:
                    removeNames = [removeName for removeName in removeNames
                            if cmp(removeName, history_date_name) == cmp_result]
                if removeNames:
                    yield dir_vpath, removeNames
Beispiel #3
0
    def walkTrashBox(self, top_path='/', days=0, cmp_result=0):
        """ -1: older than history day; 0: all; 1: greater than history day 

        """
        # XXX need to rewrite
        cur_date = datetime.datetime(*time.gmtime()[:7])
        history_date = cur_date - datetime.timedelta(days)
        history_date_name = timetag(history_date)

        if top_path != '/':
            removeNames = self.listRemoves(top_path)
            if cmp_result != 0:
                removeNames = [
                    removeName for removeName in removeNames
                    if cmp(removeName, history_date_name) == cmp_result
                ]
            if removeNames:
                yield top_path, removeNames

        for parent_path, dirnames, filenames in self.walk(top_path):
            for dirname in dirnames:
                dir_vpath = self.joinpath(parent_path, dirname)
                removeNames = self.listRemoves(dir_vpath)
                if cmp_result != 0:
                    removeNames = [
                        removeName for removeName in removeNames
                        if cmp(removeName, history_date_name) == cmp_result
                    ]
                if removeNames:
                    yield dir_vpath, removeNames
Beispiel #4
0
    def archive(self, path, id=None, **archiveInfo):
        archivePath = self.archivedpath(path)
        if not self.exists(archivePath):
            self.makedirs(archivePath)


        if not id:
            ext = self.splitext(path)[-1]
            id = timetag() + ext
        dstpath = self.joinpath(archivePath, id)
        self.copyAsset(path, dstpath, copycache=0, copy_archiveinfo=0)

        ai_path = self.archiveinfopath(dstpath)
        ai = ArchiveInfo(id=id, filename=self.basename(path), **archiveInfo)
        ai.write2xml(open(self.ospath(ai_path), 'w'))