示例#1
0
文件: db.py 项目: cycomanic/alot
    def tag(self, querystring, tags, afterwards=None, remove_rest=False):
        """
        add tags to messages matching `querystring`.
        This appends a tag operation to the write queue and raises
        :exc:`DatabaseROError` if in read only mode.

        :param querystring: notmuch search string
        :type querystring: str
        :param tags: a list of tags to be added
        :type tags: list of str
        :param afterwards: callback that gets called after successful
                           application of this tagging operation
        :type afterwards: callable
        :param remove_rest: remove tags from matching messages before tagging
        :type remove_rest: bool
        :exception: :exc:`DatabaseROError`

        .. note::
            You need to call :meth:`DBManager.flush` to actually write out.
        """
        if self.ro:
            raise DatabaseROError()
        sync_maildir_flags = config.getboolean('maildir', 'synchronize_flags')
        if remove_rest:
            self.writequeue.append(('set', querystring, tags,
                                    sync_maildir_flags, afterwards))
        else:
            self.writequeue.append(('tag', querystring, tags,
                                    sync_maildir_flags, afterwards))
示例#2
0
文件: db.py 项目: jhcepas/alot
    def untag(self, querystring, tags):
        """
        add tags to all matching messages. Raises
        :exc:`DatabaseROError` if in read only mode.

        :param querystring: notmuch search string
        :type querystring: str
        :param tags: a list of tags to be added
        :type tags: list of str
        :exception: :exc:`NotmuchError`
        """
        if self.ro:
            raise DatabaseROError()
        sync_maildir_flags = config.getboolean('maildir', 'synchronize_flags')
        self.writequeue.append(('untag', querystring, tags,
                                sync_maildir_flags))
示例#3
0
文件: db.py 项目: 0x64746b/alot
    def untag(self, querystring, tags):
        """
        removes tags from messages that match `querystring`.
        This appends an untag operation to the write queue and raises
        :exc:`DatabaseROError` if in read only mode.

        :param querystring: notmuch search string
        :type querystring: str
        :param tags: a list of tags to be added
        :type tags: list of str
        :exception: :exc:`DatabaseROError`

        .. note::
            You need to call :meth:`DBManager.flush` to actually write out.
        """
        if self.ro:
            raise DatabaseROError()
        sync_maildir_flags = config.getboolean('maildir', 'synchronize_flags')
        self.writequeue.append(('untag', querystring, tags,
                                sync_maildir_flags))
示例#4
0
文件: db.py 项目: jhcepas/alot
    def tag(self, querystring, tags, remove_rest=False):
        """
        add tags to all matching messages. Raises
        :exc:`DatabaseROError` if in read only mode.

        :param querystring: notmuch search string
        :type querystring: str
        :param tags: a list of tags to be added
        :type tags: list of str
        :param remove_rest: remove tags from matching messages before tagging
        :type remove_rest: boolean
        :exception: :exc:`NotmuchError`
        """
        if self.ro:
            raise DatabaseROError()
        sync_maildir_flags = config.getboolean('maildir', 'synchronize_flags')
        if remove_rest:
            self.writequeue.append(('set', querystring, tags,
                                    sync_maildir_flags))
        else:
            self.writequeue.append(('tag', querystring, tags,
                                    sync_maildir_flags))