'set a consumer for a set of keywords.'

def setconsumer(self, keywords, consumer):

    if isinstance(keywords, str):
        keywords = tuple(filter(None, keywords.split()))
    elif hasattr(keywords, '_keywords'):
        keywords = keywords._keywords
    elif (not isinstance(keywords, tuple)):
        raise TypeError(('key    %r    is    not    a    string    or    tuple' % (keywords,)))
    if ((consumer is not None) and (not py.builtin.callable(consumer))):
        if (not hasattr(consumer, 'write')):
            raise TypeError(('%r    should    be    None,    callable    or    file-like' % (consumer,)))
        consumer = File(consumer)
    self.keywords2consumer[keywords] = consumer
