예제 #1
0
파일: lfs.py 프로젝트: Ramel/itools
            # Write and truncate (calls to "_save_state" must be done with the
            # pointer pointing to the beginning)
            f.write(data)
            f.truncate(f.tell())
        finally:
            f.close()

    def traverse_resources(self):
        raise NotImplementedError

    def do_transaction(self, commit_message, data, added, changed, removed,
                       handlers):
        # List of Changed
        added_and_changed = list(added) + list(changed)
        # Build the tree from index
        for key in added_and_changed:
            handler = handlers.get(key)
            parent_path = dirname(key)
            if not self.fs.exists(parent_path):
                self.fs.make_folder(parent_path)
            handler.save_state()
        for key in removed:
            self.fs.remove(key)

    def abort_transaction(self):
        # Cannot abort transaction with this backend
        pass


register_backend('lfs', LFSBackend)
예제 #2
0
파일: lfs.py 프로젝트: hforge/itools
            f.truncate(f.tell())
        finally:
            f.close()


    def traverse_resources(self):
        raise NotImplementedError


    def do_transaction(self, commit_message, data, added, changed, removed, handlers):
        # List of Changed
        added_and_changed = list(added) + list(changed)
        # Build the tree from index
        for key in added_and_changed:
            handler = handlers.get(key)
            parent_path = dirname(key)
            if not self.fs.exists(parent_path):
                self.fs.make_folder(parent_path)
            handler.save_state()
        for key in removed:
            self.fs.remove(key)



    def abort_transaction(self):
        # Cannot abort transaction with this backend
        pass


register_backend('lfs', LFSBackend)
예제 #3
0
파일: git.py 프로젝트: hforge/itools
        #    self.worktree.repo.checkout_head(strategy)


    def flush_catalog(self, docs_to_unindex, docs_to_index):
        for path in docs_to_unindex:
            self.catalog.unindex_document(path)
        for resource, values in docs_to_index:
            self.catalog.index_document(values)


    def get_catalog(self):
        path = '{0}/catalog'.format(self.path)
        if not lfs.is_folder(path):
            return None
        return Catalog(path, self.fields, read_only=self.read_only)


    def search(self, query=None, **kw):
        """Launch a search in the catalog.
        """
        catalog = self.catalog
        xquery = _get_xquery(catalog, query, **kw)
        return SearchResults(catalog, xquery)


    def close(self):
        self.catalog.close()


register_backend('git', GitBackend)
예제 #4
0
        #    self.worktree.repo.checkout_head(strategy)


    def flush_catalog(self, docs_to_unindex, docs_to_index):
        for path in docs_to_unindex:
            self.catalog.unindex_document(path)
        for resource, values in docs_to_index:
            self.catalog.index_document(values)


    def get_catalog(self):
        path = '{0}/catalog'.format(self.path)
        if not lfs.is_folder(path):
            return None
        return Catalog(path, self.fields, read_only=self.read_only)


    def search(self, query=None, **kw):
        """Launch a search in the catalog.
        """
        catalog = self.catalog
        xquery = _get_xquery(catalog, query, **kw)
        return SearchResults(catalog, xquery)


    def close(self):
        self.catalog.close()


register_backend('git', GitBackend)
예제 #5
0
파일: git_bare.py 프로젝트: Ramel/itools
        email = self.useremail
        committer = Signature(name, email, when_time, when_offset)

        # Author
        if author is None:
            author = (name, email)

        if date:
            if date.tzinfo:
                from pytz import utc
                when_time = date.astimezone(utc)  # To UTC
                when_time = when_time.timetuple()  # As struct_time
                when_time = timegm(when_time)  # To unix time
                when_offset = date.utcoffset().seconds / 60
            else:
                err = "Worktree.git_commit doesn't support naive datatime yet"
                raise NotImplementedError, err

        author = Signature(author[0], author[1], when_time, when_offset)

        # Create the commit
        return self.repo.create_commit('HEAD', author, committer, message,
                                       tree, parents)

    def abort_transaction(self):
        # TODO: Remove created blobs
        pass


register_backend('git-bare', GitBareBackend)