def _store_data(self):
        '''
        loops through all the events and matches events against the desired
        backends from the config. if it matches, the the backend gets initiated
        and the event is passed to the backend with the backend-settings. the
        backend takes care of pushing the data further.
        '''
        # look through all the events and pass them on to the corresponding
        # backend each available backend is started only, if an event requires
        # it.
        batch_backend_map = {}

        for entry in self.events:
            for event in self.event_map.keys():
                batch_mode = self.event_map[event].get("batch_mode", False)

                event_sets = []
                event_set = None

                # check if the event matches any of our tags from the config
                if self.event_map[event]['tag'].match(entry['tag']):

                    # if we have match, use that settings for this event
                    event_sets.append(self.event_map[event])

                    # if the event has a subs-section, check the sub-events if
                    # they match. if so, use these settings for this event.
                    if 'subs' in self.event_map[event]:
                        for subevent in self.event_map[event]['subs'].keys():
                            # check for 'fun'- or 'tag'-field as these are the
                            # fields we filter by. we check for both and put
                            # the event into the corresponding backend which
                            # we might have to create prior to adding an event
                            if 'fun' in self.event_map[event]['subs'][subevent]:
                                #
                                # There are two possible event-formats:
                                #
                                # event.fire_master has the 'fun' within a 'data' dict
                                if entry in 'data':
                                    try:
                                        if self.event_map[event]['subs'][subevent]['fun'].match(entry['data']['fun']):
                                            event_sets.append(self.event_map[event]['subs'][subevent])
                                    except KeyError:
                                        # Due to https://github.com/saltstack/salt/issues/12935
                                        # not being resolved yet, we have to workaround.
                                        log.debug('Workaround for Issue 12935 applied!')
                                        if self.event_map[event]['subs'][subevent]['fun'].match(entry['data']['data']['fun']):
                                            event_sets.append(self.event_map[event]['subs'][subevent])

                                # while 'salt minion module.func' and 'salt-call' have it directly in the event
                                else:
                                    if self.event_map[event]['subs'][subevent]['fun'].match(entry['fun']):
                                        event_sets.append(self.event_map[event]['subs'][subevent])

                            # the 'tag' field is always on the first level of the event.
                            elif 'tag' in self.event_map[event]['subs'][subevent]:
                                if self.event_map[event]['subs'][subevent]['tag'].match(entry['data']['tag']):
                                    event_sets.append(self.event_map[event]['subs'][subevent])

                    if len(event_sets) == 0:
                        log.error("{0}# event '{1}' not found in config".format(self.name, entry))
                    else:
                        # log.debug("{0}# event match details:".format(self.name))
                        # log.debug("{0}# event_set: {1}".format(self.name,
                        #                                        event_set))
                        # log.debug("{0}# event: {1}".format(self.name,
                        #                                    entry))

                        # if the backend for this type of event has not
                        # been initiated yet, take care of that
                        # Only init if not running in batch mode
                        if not batch_mode:
                            for event_set in event_sets:
                                if event_set['backend'] not in self.active_backends.keys():
                                    self._init_backend(event_set['backend'])

                        # finally send that event to the backend including
                        # the config-set for this event
                        for event_set in event_sets:
                            if not batch_mode:
                                self.active_backends[event_set['backend']].send(entry, event_set)
                            else:
                                batch_backend_map.setdefault(event_set['backend'], []).append((entry, event_set))
                event_sets = []

        # Init all backends and send all events at once
        for backend, backend_data in batch_backend_map.items():
            if backend not in self.active_backends.keys():
                self._init_backend(backend)
            self.active_backends[backend].send_batch(backend_data)

        # have all backends clean up their cleanup
        self._cleanup()
dataset/ETHPy150Open felskrone/salt-eventsd/salteventsd/worker.py/SaltEventsdWorker._store_data/swapped operands of `in`