def configure_handler(self, config):
formatter = config.pop('<STR_LIT>', None)<EOL>if formatter:<EOL><INDENT>try:<EOL><INDENT>formatter = self.config['<STR_LIT>'][formatter]<EOL><DEDENT>except StandardError as e:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>' % (formatter, e))<EOL><DEDENT><DEDENT>level = config.pop('<STR_LIT>', None)<EOL>filters = config.pop('<STR_LIT>', None)<EOL>if '<STR_LIT>' in config:<EOL><INDENT>c = config.pop('<STR_LIT>')<EOL>if not hasattr(c, '<STR_LIT>') andhasattr(types, '<STR_LIT>') andisinstance(c, types.ClassType):<EOL><INDENT>c = self.resolve(c)<EOL><DEDENT>factory = c<EOL><DEDENT>else:<EOL><INDENT>klass = self.resolve(config.pop('<STR_LIT:class>'))<EOL>if issubclass(klass, logging.handlers.MemoryHandler) and'<STR_LIT:target>' in config:<EOL><INDENT>try:<EOL><INDENT>config['<STR_LIT:target>'] =self.config['<STR_LIT>'][config['<STR_LIT:target>']]<EOL><DEDENT>except StandardError as e:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>' % (config['<STR_LIT:target>'], e))<EOL><DEDENT><DEDENT>elif issubclass(klass, logging.handlers.SMTPHandler) and'<STR_LIT>' in config:<EOL><INDENT>config['<STR_LIT>'] = self.as_tuple(config['<STR_LIT>'])<EOL><DEDENT>elif issubclass(klass, logging.handlers.SysLogHandler) and'<STR_LIT:address>' in config:<EOL><INDENT>config['<STR_LIT:address>'] = self.as_tuple(config['<STR_LIT:address>'])<EOL><DEDENT>factory = klass<EOL><DEDENT>kwargs = dict((k, config[k]) for k in config if valid_ident(k))<EOL>try:<EOL><INDENT>result = factory(**kwargs)<EOL><DEDENT>except TypeError as te:<EOL><INDENT>if "<STR_LIT>" not in str(te):<EOL><INDENT>raise<EOL><DEDENT>kwargs['<STR_LIT>'] = kwargs.pop('<STR_LIT>')<EOL>result = factory(**kwargs)<EOL><DEDENT>if formatter:<EOL><INDENT>result.setFormatter(formatter)<EOL><DEDENT>if level is not None:<EOL><INDENT>result.setLevel(_checkLevel(level))<EOL><DEDENT>if filters:<EOL><INDENT>self.add_filters(result, filters)<EOL><DEDENT>return result<EOL>
Configure a handler from a dictionary.