'Filter data_set based on exclusion_rules.
Compare each book in data_set to each exclusion_rule. Remove
books matching exclusion criteria.
Args:
data_set (list): all candidate books
Return:
(list): filtered data_set'

def process_exclusions(self, data_set):

    filtered_data_set = []
    exclusion_pairs = []
    exclusion_set = []
    for rule in self.opts.exclusion_rules:
        if (rule[1].startswith('#') and (rule[2] != '')):
            field = rule[1]
            pat = rule[2]
            exclusion_pairs.append((field, pat))
        else:
            continue
    if exclusion_pairs:
        if self.opts.verbose:
            self.opts.log.info('    Books    excluded    by    custom    field    contents:')
        for record in data_set:
            for exclusion_pair in exclusion_pairs:
                (field, pat) = exclusion_pair
                field_contents = self.db.get_field(record['id'], field, index_is_id=True)
                if ((self.db.metadata_for_field(field)['datatype'] == 'bool') and (field_contents is None)):
                    field_contents = _('False')
                if (field_contents is not None):
                    if (self.db.metadata_for_field(field)['datatype'] == 'bool'):
                        field_contents = _(repr(field_contents))
                    matched = re.search(pat, unicode(field_contents), re.IGNORECASE)
                    if (matched is not None):
                        if self.opts.verbose:
                            field_md = self.db.metadata_for_field(field)
                            for rule in self.opts.exclusion_rules:
                                if (rule[1] == ('#%s' % field_md['label'])):
                                    self.opts.log.info(("        -    '%s'    by    %s    (%s:    '%s'    contains    '%s')" % (record['title'], record['authors'][0], rule[0], self.db.metadata_for_field(field)['name'], field_contents)))
                        exclusion_set.append(record)
                        if (record in filtered_data_set):
                            filtered_data_set.remove(record)
                        break
                    elif (record not in filtered_data_set):
                        filtered_data_set.append(record)
                elif ((record not in filtered_data_set) and (record not in exclusion_set)):
                    filtered_data_set.append(record)
        return filtered_data_set
    else:
        return data_set
