Exemple #1
0
def index(xapproxy, msg_key, labels):
    msg = mail_grab.get(msg_key)
    doc = xappy.UnprocessedDocument()
    doc.id = str(msg_key)
    doc = _populate_fields(msg, doc, labels)
    doc = _do_append_field(doc, 'content', _content_parse(msg))
    xapproxy.replace(doc)
Exemple #2
0
    def __init__(self, msgobj):
        self.spacer = collapser_blank('', 'blank', 'blank')
        #self.spacer = collapser_label('', 'blank', 'blank')
        #self.spacer = collapser_label('\n', 'blank', 'blank')
        self.__super.__init__()
        self.msgobj = msgobj
        self._state_order = {}
        #if 'S' in msgobj.get('flags', ''): self.new = False
        #else: self.new = True

        __msg_get = mail_grab.get(msgobj.muuid())
        __processed = msg_machine.process(__msg_get)

        if self.new: self._change_detailed(True)
        else: self.update_widget()
        #if self.new: self.update_widget()
        #else: self._change_expanded(False)

        def fadd(p):
            try: self._cache[self._state_order[p[0]]].append(machined_widget(p, ref(self)))
            except KeyError:
                self._state_order[p[0]] = len(self._state_order)
                return fadd(p)
            except IndexError: 
                #try: self._cache.append(group_state(machined_widget(p)))
                try: self._cache[self._state_order[p[0]]] = group_state(machined_widget(p, ref(self)), ref(self))
                except:
                     self._cache.append(group_state(machined_widget(p, ref(self)), ref(self)))
                     #raise ValueError('data: %s\nstate_order: %s\ncache: %s' % (str(p), str(self._state_order), str(self._cache)))

        map(fadd, __processed)
        threadmap.map(lambda x: x.update_widget(), self._cache)
Exemple #3
0
def set_read(muuid):
    """
    Set the Seen flag in the index as well as on the filesystem.
    """
    emit_signal(eband, 'log', 'doing set_read on muuid %s' % muuid)
    msg = mail_grab.get(muuid)
    subdir = msg.get_subdir()
    if subdir == 'new':
        msg.set_subdir('cur')
    if 'S' not in msg.get_flags():
        msg.add_flag('S')
        t = time.time()
        mail_grab.update(muuid, msg)
        t = time.time() - t
        emit_signal(eband, 'log', 'update took %s seconds' % t)
        return (muuid, [('flags', 'S')])
    else:
        mail_grab.update(muuid, msg)
    return None
Exemple #4
0
def set_unread(muuid):
    """
    Remove the seen flag both from the xapian index and from the filesystem.
    """
    emit_signal(eband, 'log', 'doing set_unread on muuid %s' % muuid)
    msg = mail_grab.get(muuid)
    subdir = msg.get_subdir()
    if subdir == 'new':
        msg.set_subdir('cur')
    if 'S' in msg.get_flags():
        msg.remove_flag('S')
        t = time.time()
        mail_grab.update(muuid, msg)
        t = time.time() - t
        emit_signal(eband, 'log', 'update took %s seconds' % t)
        return (muuid, [('flags', 'S')])
    else:
        mail_grab.update(muuid, msg)
    return None
Exemple #5
0
def msg_factory(muuid, msg=None):
    '''
    Takes a xapian search result objects and maildir message objects and
    returns a standardized msg_container with everything I need.
    Always working with data in the same format makes it easier to index it
    and write code to display it.
    '''
    try:
        muuid, msg = muuid.id, muuid.data
    except AttributeError:
        try:
            muuid, msg = muuid
        except: pass


    '''
    if type(muuid) is xappy.searchconnection.SearchResult:
        muuid, msg = muuid.id, muuid.data
    elif type(muuid) is tuple:
        muuid, msg = muuid
    elif type(muuid) is ProcessedDocument:
        muuid, msg = muuid.id, muuid.data
    elif type(muuid) is SearchResult:
        muuid, msg = muuid.id, muuid.data
    elif type(muuid) is UnprocessedDocument:
        muuid, msg = muuid.id, muuid.data
        '''

    if type(muuid) is msg_container:
        return muuid
    elif type(msg) is msg_container:
        return msg

    if not msg:
        msg = mail_grab.get(muuid)
        if not msg:
            raise KeyError("invalid muuid given! Couldn't find a message to parse!\nmuuid type is: %s" % str(type(muuid)))
    __r = _msg_factory(muuid, msg)
    __r = msg_container(*__r)
    return __r