Source code for core.plugs.find

# core/plugs/find.py
#
#

""" find objects based on attribute values. """

__copyright__ = "Copyright 2014 B.H.J Thate"

## IMPORTS

from core.utils import format, txt_parse, b_time
from core import kernel

## basic

import threading
import logging
import time
import re

## CMNDS

[docs]def find(event): nr = 1 parsed = event.get_parsed() if not parsed.args: return objs = kernel.selected(parsed) if "uniq" in parsed.wanted: uniq = parsed.wanted.uniq else: uniq = "" uniq_list = [] for obj in sorted(objs, key=lambda x: x.get_timed()): if uniq in obj: if obj[uniq] in uniq_list: continue uniq_list.append(obj[uniq]) event.reply(format(obj, nr=nr, keys=parsed.args)) ; nr += 1
kernel.cmnds.register("find", find)