def select_renderer(request: web.Request, renderers: OrderedDict, force=True):
header = request.headers.get('<STR_LIT>', '<STR_LIT>')<EOL>best_match = mimeparse.best_match(renderers.keys(), header)<EOL>if not best_match or best_match not in renderers:<EOL><INDENT>if force:<EOL><INDENT>return tuple(renderers.items())[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>raise web.HTTPNotAcceptable<EOL><DEDENT><DEDENT>return best_match, renderers[best_match]<EOL>
Given a request, a list of renderers, and the ``force`` configuration
option, return a two-tuple of:
(media type, render callable). Uses mimeparse to find the best media
type match from the ACCEPT header.