Pop one event from each of the event queues whose names
        match (in a sense of regular expression) regex_pattern.
546823
def _match_and_pop(self, regex_pattern):
        
        results = []
        self.lock.acquire()
        for name in self.event_dict.keys():
            if re.match(regex_pattern, name):
                q = self.event_dict[name]
                if q:
                    try:
                        results.append(q.get(False))
                    except:
                        pass
        self.lock.release()
        return results
101663
def pop_trigger(data):
    """"""

    trigger_name = data.pop('trigger')
    trigger_args = {}

    if trigger_name == 'date':
        trigger_arg_names = ('run_date', 'timezone')
    elif trigger_name == 'interval':
        trigger_arg_names = ('weeks', 'days', 'hours', 'minutes', 'seconds', 'start_date', 'end_date', 'timezone')
    elif trigger_name == 'cron':
        trigger_arg_names = ('year', 'month', 'day', 'week', 'day_of_week', 'hour', 'minute', 'second', 'start_date', 'end_date', 'timezone')
    else:
        raise Exception('Trigger %s is not supported.' % trigger_name)

    for arg_name in trigger_arg_names:
        if arg_name in data:
            trigger_args[arg_name] = data.pop(arg_name)

    return trigger_name, trigger_args
1188596
def regxy(pattern, response, supress_regex, custom):
    """"""
    try:
        matches = re.findall(r'%s' % pattern, response)
        for match in matches:
            verb('Custom regex', match)
            custom.add(match)
    except:
        supress_regex = True
1268705
def popleft(self):
        """"""
        self._mq.send("^", True, type=1)
        message = self._wait_receive_msg()
        reply = int(message[0].decode('utf-8'))
        #print(reply)
        if reply == -1:
            raise IndexError("pop from empty list")
        return reply
880137
private List<Event> filterEvents(List<Event> events) {
        List<Event> filteredEvents = new ArrayList<Event>();
        for (Event event : events) {
            if (!filter(event)) {
                filteredEvents.add(event);
            }
        }
        return filteredEvents;
    }
682156
def pick_event(self):
        
        logger.debug("checking event queue")
        event = snap7.snap7types.SrvEvent()
        ready = ctypes.c_int32()
        code = self.library.Srv_PickEvent(self.pointer, ctypes.byref(event),
                                          ctypes.byref(ready))
        check_error(code)
        if ready:
            logger.debug("one event ready: %s" % event)
            return event
        logger.debug("no events ready")
764317
def matchesWithMatchers(self, event):
        '''
        
        '''
        ret = []
        self._matches(event, set(), ret)
        return tuple(ret)
995869
def matches(self, event):
        '''
        
        '''
        ret = []
        self._matches(event, set(), ret)
        return tuple(r[0] for r in ret)
864057
def clear_events(self, event_name):
        
        self.lock.acquire()
        try:
            q = self.get_event_q(event_name)
            q.queue.clear()
        except queue.Empty:
            return
        finally:
            self.lock.release()
120099
def re(self, event_property, value):
        
        c = self.copy()
        c.filters.append(filters.RE(event_property, value))
        return c
1139639
def trigger_events(events, loop):
    
    for event in events:
        result = event(loop)
        if isawaitable(result):
            loop.run_until_complete(result)
1175289
def _reExec(regex, string):
    ''''''
    m = regex.search(string)
    if not m: return None
    return [m.group()] + list(m.groups())
429020
def filter_event(tag, data, defaults):
    '''
    
    '''
    ret = {}
    keys = []
    use_defaults = True

    for ktag in __opts__.get('filter_events', {}):
        if tag != ktag:
            continue
        keys = __opts__['filter_events'][ktag]['keys']
        use_defaults = __opts__['filter_events'][ktag].get('use_defaults', True)

    if use_defaults is False:
        defaults = []

    # For PY3, if something like ".keys()" or ".values()" is used on a dictionary,
    # it returns a dict_view and not a list like in PY2. "defaults" should be passed
    # in with the correct data type, but don't stack-trace in case it wasn't.
    if not isinstance(defaults, list):
        defaults = list(defaults)

    defaults = list(set(defaults + keys))

    for key in defaults:
        if key in data:
            ret[key] = data[key]

    return ret
1086250
def pop_all(self):
        
        with self.lock:
            if self.please_stop:
                return [THREAD_STOP]
            if self.db.status.end == self.start:
                return []

            output = []
            for i in range(self.start, self.db.status.end):
                output.append(self.db[str(i)])

            self.start = self.db.status.end
            return output
479146
def _trigger(self, event_name, *args, **kwargs):
        
        self.log('event: %s' % event_name, *args)
        for f in self._events[event_name]:
            f(*args, **kwargs)
1005174
def trigger(self, *args, **kargs):
        
        event = args[0]

        if isinstance(event, str) and ' ' in event:
            event = event.split(' ')  # split event names ...

        if isinstance(event, list):  # event is a list of events
            for each in event:
                self.events[each].trigger(*args[1:], **kargs)
        else:
            self.events[event].trigger(*args[1:], **kargs)
632504
def check_event_coverage(patterns, event_list):
    """"""
    proportions = []
    for pattern_list in patterns:
        proportion = 0
        for pattern in pattern_list:
            for node in pattern.nodes():
                if node in event_list:
                    proportion += 1.0 / len(pattern_list)
                    break
        proportions.append(proportion)
    return proportions