def parse_render(render):
    """Parse render URL parameter.

    >>> parse_render(None)
    'png'
    >>> parse_render('html')
    'png'
    >>> parse_render('png')
    'png'
    >>> parse_render('jpg')
    'jpeg'
    >>> parse_render('gif')
    'gif'
    """
    formats = {
        'jpeg': guess_all_extensions('image/jpeg'),
        'png': guess_all_extensions('image/png'),
        'gif': guess_all_extensions('image/gif'),
        'bmp': guess_all_extensions('image/x-ms-bmp'),
        'tiff': guess_all_extensions('image/tiff'),
        'xbm': guess_all_extensions('image/x-xbitmap'),
        'pdf': guess_all_extensions('application/pdf')
    }
    if not render:
        render = 'png'
    else:
        render = render.lower()
        for k, v in formats.items():
            if '.%s' % render in v:
                render = k
                break
        else:
            render = 'png'
    return render
def parse_render ( render ) : formats = { 'jpeg' : guess_all_extensions ( 'image/jpeg' ) , 'png' : guess_all_extensions ( 'image/png' ) , 'gif' : guess_all_extensions ( 'image/gif' ) , 'bmp' : guess_all_extensions ( 'image/x-ms-bmp' ) , 'tiff' : guess_all_extensions ( 'image/tiff' ) , 'xbm' : guess_all_extensions ( 'image/x-xbitmap' ) , 'pdf' : guess_all_extensions ( 'application/pdf' ) } if not render : render = 'png' else : render = render . lower ( ) for k , v in formats . items ( ) : if '.%s' % render in v : render = k break else : render = 'png' return render
Parse render URL parameter.

    >>> parse_render(None)
    'png'
    >>> parse_render('html')
    'png'
    >>> parse_render('png')
    'png'
    >>> parse_render('jpg')
    'jpeg'
    >>> parse_render('gif')
    'gif'