Beispiel #1
0
        return results


_plugins.register_commands(Extract, Next, Order, Previous, Search, View)

##[ Search terms ]############################################################


def mailbox_search(config, idx, term, hits):
    word = term.split(':', 1)[1].lower()
    try:
        mbox_id = FormatMbxId(b36(int(word, 36)))
    except ValueError:
        mbox_id = None

    mailboxes = []
    for m in config.sys.mailbox.keys():
        fn = FilePath(config.sys.mailbox[m]).display().lower()
        if (mbox_id == m) or word in fn:
            mailboxes.append(m)

    rt = []
    for mbox_id in mailboxes:
        mbox_id = FormatMbxId(mbox_id)
        rt.extend(hits('%s:mailbox' % mbox_id))

    return rt


_plugins.register_search_term('mailbox', mailbox_search)
Beispiel #2
0
    group = config._vcards.get(term.split(':', 1)[1])
    rt, emails = [], []
    if group and group.kind == 'group':
        for email, attrs in group.get('EMAIL', []):
            group = config._vcards.get(email.lower(), None)
            if group:
                emails.extend([e[0].lower() for e in group.get('EMAIL', [])])
            else:
                emails.append(email.lower())
    fromto = term.startswith('group:') and 'from' or 'to'
    for email in set(emails):
        rt.extend(hits('%s:%s' % (email, fromto)))
    return rt


_plugins.register_search_term('group', search)
_plugins.register_search_term('togroup', search)

##[ Commands ]################################################################


def GroupVCard(parent):
    """A factory for generating group commands"""
    class GroupVCardCommand(parent):
        SYNOPSIS = tuple([(t and t.replace('vcard', 'group') or t)
                          for t in parent.SYNOPSIS])
        KIND = 'group'
        ORDER = ('Tagging', 4)

        def _valid_vcard_handle(self, vc_handle):
            # If there is already a tag by this name, complain.
Beispiel #3
0
def search(config, idx, term, hits):
    group = config._vcards.get(term.split(':', 1)[1])
    rt, emails = [], []
    if group and group.kind == 'group':
        for email, attrs in group.get('EMAIL', []):
            group = config._vcards.get(email.lower(), None)
            if group:
                emails.extend([e[0].lower() for e in group.get('EMAIL', [])])
            else:
                emails.append(email.lower())
    fromto = term.startswith('group:') and 'from' or 'to'
    for email in set(emails):
        rt.extend(hits('{0!s}:{1!s}'.format(email, fromto)))
    return rt

_plugins.register_search_term('group', search)
_plugins.register_search_term('togroup', search)


##[ Commands ]################################################################

def GroupVCard(parent):
    """A factory for generating group commands"""

    class GroupVCardCommand(parent):
        SYNOPSIS = tuple([(t and t.replace('vcard', 'group') or t)
                          for t in parent.SYNOPSIS])
        KIND = 'group'
        ORDER = ('Tagging', 4)

        def _valid_vcard_handle(self, vc_handle):
Beispiel #4
0
        sig.add('mp_sig-none')
    elif len(sig) > 1:
        sig = choose_one('mp_sig-%s', sig, SignatureInfo.STATUSES)

    # Emit tags for our states
    for tname in (enc | sig):
        tag = index.config.get_tags(slug=tname)
        if tag:
            kw.add('%s:in' % tag[0]._key)

    if 'cryptostate' in index.config.sys.debug:
        print 'part crypto state(=%s): %s' % (msg_mid, ','.join(list(kw)))

    return list(kw)

_plugins.register_text_kw_extractor('crypto_tkwe', text_kw_extractor)
_plugins.register_meta_kw_extractor('crypto_mkwe', meta_kw_extractor)


##[ Search helpers ]##########################################################

def search(config, idx, term, hits):
    #
    # FIXME: Translate things like pgp:signed into a search for all the
    #        tags that have signatures (good or bad).
    #
    return []

_plugins.register_search_term('crypto', search)
_plugins.register_search_term('pgp', search)
Beispiel #5
0
                if info:
                    info['idx'] = e.msg_idx_pos
                    if fn:
                        info['created_file'] = fn
                    results.append(info)
        return results


_plugins.register_commands(Extract, Next, Order, Previous, Search, View)


##[ Search terms ]############################################################

def mailbox_search(config, idx, term, hits):
    word = term.split(':', 1)[1].lower()
    try:
        mbox_id = (('0' * MBX_ID_LEN) + b36(int(word, 36)))[-MBX_ID_LEN:]
    except ValueError:
        mbox_id = None

    mailboxes = [m for m in config.sys.mailbox.keys()
                 if (mbox_id == m) or word in config.sys.mailbox[m].lower()]
    rt = []
    for mbox_id in mailboxes:
        mbox_id = (('0' * MBX_ID_LEN) + mbox_id)[-MBX_ID_LEN:]
        rt.extend(hits('%s:mailbox' % mbox_id))
    return rt


_plugins.register_search_term('mailbox', mailbox_search)
Beispiel #6
0
            if info:
                info["idx"] = email.msg_idx_pos
                if fn:
                    info["created_file"] = fn
                results.append(info)
        return results


_plugins.register_commands(Extract, Next, Order, Previous, Search, View)


##[ Search terms ]############################################################


def mailbox_search(config, idx, term, hits):
    word = term.split(":", 1)[1].lower()
    try:
        mbox_id = (("0" * MBX_ID_LEN) + b36(int(word, 36)))[-MBX_ID_LEN:]
    except ValueError:
        mbox_id = None

    mailboxes = [m for m in config.sys.mailbox.keys() if (mbox_id == m) or word in config.sys.mailbox[m].lower()]
    rt = []
    for mbox_id in mailboxes:
        mbox_id = (("0" * MBX_ID_LEN) + mbox_id)[-MBX_ID_LEN:]
        rt.extend(hits("%s:mailbox" % mbox_id))
    return rt


_plugins.register_search_term("mailbox", mailbox_search)
Beispiel #7
0
def search(config, idx, term, hits):
    try:
        word = term.split(":", 1)[1].lower()

        for range_keyword in _range_keywords:
            if range_keyword in term:
                start, end = word.split(range_keyword)
                break
        else:
            start = end = word

        # if no unit is setup in the start term, use the unit from the end term
        end_unit_size = end.lower()[-1]
        end_unit = 0
        if end_unit_size in _size_units:
            end_unit = _size_units[end_unit_size]

        start = _mk_logsize(start, end_unit)
        end = _mk_logsize(end)
        terms = ["%s:ln2sz" % sz for sz in range(start, end + 1)]

        rt = []
        for t in terms:
            rt.extend(hits(t))
        return rt
    except:
        raise ValueError("Invalid size: %s" % term)


_plugins.register_search_term("size", search)
Beispiel #8
0
                ny = [start[0], 12, 31]
                if ny <= end:
                    terms.append('%d:year' % start[0])
                    start[0] += 1
                    continue

            # Move forward one month?
            if start[2] == 1:
                nm = [start[0], start[1], 31]
                if nm <= end:
                    terms.append('%d-%d:yearmonth' % (start[0], start[1]))
                    start[1] += 1
                    _adjust(start)
                    continue

            # Move forward one day...
            terms.append('%d-%d-%d:date' % tuple(start))
            start[2] += 1
            _adjust(start)

        rt = []
        for t in terms:
            rt.extend(hits(t))
        return rt
    except:
        raise ValueError('Invalid date range: %s' % term)


_plugins.register_search_term('dates', search)
_plugins.register_search_term('date', search)
Beispiel #9
0
def search(config, idx, term, hits):
    try:
        word = term.split(':', 1)[1].lower()

        for range_keyword in _range_keywords:
            if range_keyword in term:
                start, end = word.split(range_keyword)
                break
        else:
            start = end = word

        # if no unit is setup in the start term, use the unit from the end term
        end_unit_size = end.lower()[-1]
        end_unit = 0
        if end_unit_size in _size_units:
            end_unit = _size_units[end_unit_size]

        start = _mk_logsize(start, end_unit)
        end = _mk_logsize(end)
        terms = ['%s:ln2sz' % sz for sz in range(start, end + 1)]

        rt = []
        for t in terms:
            rt.extend(hits(t))
        return rt
    except:
        raise ValueError('Invalid size: %s' % term)


_plugins.register_search_term('size', search)
Beispiel #10
0
def search(config, idx, term, hits):
    try:
        word = term.split(':', 1)[1].lower()

        for range_keyword in _range_keywords:
            if range_keyword in term:
                start, end = word.split(range_keyword)
                break
        else:
            start = end = word

        # if no unit is setup in the start term, use the unit from the end term
        end_unit_size = end.lower()[-1]
        end_unit = 0
        if end_unit_size in _size_units:
            end_unit = _size_units[end_unit_size]

        start = _mk_logsize(start, end_unit)
        end = _mk_logsize(end)
        terms = ['%s:ln2sz' % sz for sz in range(start, end+1)]

        rt = []
        for t in terms:
            rt.extend(hits(t))
        return rt
    except:
        raise ValueError('Invalid size: %s' % term)


_plugins.register_search_term('size', search)
Beispiel #11
0
                ny = [start[0], 12, 31]
                if ny <= end:
                    terms.append('%d:year' % start[0])
                    start[0] += 1
                    continue

            # Move forward one month?
            if start[2] == 1:
                nm = [start[0], start[1], 31]
                if nm <= end:
                    terms.append('%d-%d:yearmonth' % (start[0], start[1]))
                    start[1] += 1
                    _adjust(start)
                    continue

            # Move forward one day...
            terms.append('%d-%d-%d:date' % tuple(start))
            start[2] += 1
            _adjust(start)

        rt = []
        for t in terms:
            rt.extend(hits(t))
        return rt
    except:
        raise ValueError('Invalid date range: %s' % term)


_plugins.register_search_term('dates', search)
_plugins.register_search_term('date', search)
Beispiel #12
0
        sig = choose_one('mp_sig-%s', sig, SignatureInfo.STATUSES)

    # Emit tags for our states
    for tname in (enc | sig):
        tag = index.config.get_tags(slug=tname)
        if tag:
            kw.add('%s:in' % tag[0]._key)

    if 'cryptostate' in index.config.sys.debug:
        print 'part crypto state(=%s): %s' % (msg_mid, ','.join(list(kw)))

    return list(kw)


_plugins.register_text_kw_extractor('crypto_tkwe', text_kw_extractor)
_plugins.register_meta_kw_extractor('crypto_mkwe', meta_kw_extractor)

##[ Search helpers ]##########################################################


def search(config, idx, term, hits):
    #
    # FIXME: Translate things like pgp:signed into a search for all the
    #        tags that have signatures (good or bad).
    #
    return []


_plugins.register_search_term('crypto', search)
_plugins.register_search_term('pgp', search)
Beispiel #13
0
                ny = [start[0], 12, 31]
                if ny <= end:
                    terms.append("%d:year" % start[0])
                    start[0] += 1
                    continue

            # Move forward one month?
            if start[2] == 1:
                nm = [start[0], start[1], 31]
                if nm <= end:
                    terms.append("%d-%d:yearmonth" % (start[0], start[1]))
                    start[1] += 1
                    _adjust(start)
                    continue

            # Move forward one day...
            terms.append("%d-%d-%d:date" % tuple(start))
            start[2] += 1
            _adjust(start)

        rt = []
        for t in terms:
            rt.extend(hits(t))
        return rt
    except:
        raise ValueError("Invalid date range: %s" % term)


_plugins.register_search_term("dates", search)
_plugins.register_search_term("date", search)
Beispiel #14
0
                info['idx'] = email.msg_idx_pos
                if fn:
                    info['created_file'] = fn
                results.append(info)
        return results


_plugin_manager.register_commands(Extract, Next, Order, Previous,
                                  Search, View)


##[ Search terms ]############################################################

def mailbox_search(config, idx, term, hits):
    word = term.split(':', 1)[1].lower()
    try:
        mailbox_id = b36(int(word, 36))
    except ValueError:
        mailbox_id = None

    mailboxes = [m for m in config.sys.mailbox.keys()
                 if word in config.sys.mailbox[m].lower() or mailbox_id == m]
    rt = []
    for mbox_id in mailboxes:
        mbox_id = (('0' * MBX_ID_LEN) + mbox_id)[-MBX_ID_LEN:]
        rt.extend(hits('%s:mailbox' % mbox_id))
    return rt


_plugin_manager.register_search_term('mailbox', mailbox_search)
Beispiel #15
0
            if info:
                info["idx"] = email.msg_idx_pos
                if fn:
                    info["created_file"] = fn
                results.append(info)
        return results


_plugin_manager.register_commands(Extract, Next, Order, Previous, Search, View)


##[ Search terms ]############################################################


def mailbox_search(config, idx, term, hits):
    word = term.split(":", 1)[1].lower()
    try:
        mailbox_id = b36(int(word, 36))
    except ValueError:
        mailbox_id = None

    mailboxes = [m for m in config.sys.mailbox.keys() if word in config.sys.mailbox[m].lower() or mailbox_id == m]
    rt = []
    for mbox_id in mailboxes:
        mbox_id = (("0" * MBX_ID_LEN) + mbox_id)[-MBX_ID_LEN:]
        rt.extend(hits("%s:mailbox" % mbox_id))
    return rt


_plugin_manager.register_search_term("mailbox", mailbox_search)
Beispiel #16
0
                if fn:
                    info['created_file'] = fn
                results.append(info)
        return results


_plugin_manager.register_commands(Extract, Next, Order, Previous, Search, View)

##[ Search terms ]############################################################


def mailbox_search(config, idx, term, hits):
    word = term.split(':', 1)[1].lower()
    try:
        mailbox_id = b36(int(word, 36))
    except ValueError:
        mailbox_id = None

    mailboxes = [
        m for m in config.sys.mailbox.keys()
        if word in config.sys.mailbox[m].lower() or mailbox_id == m
    ]
    rt = []
    for mbox_id in mailboxes:
        mbox_id = (('0' * MBX_ID_LEN) + mbox_id)[-MBX_ID_LEN:]
        rt.extend(hits('%s:mailbox' % mbox_id))
    return rt


_plugin_manager.register_search_term('mailbox', mailbox_search)