

def filename_from_url(url, content_type):
    fn = urlsplit(url).path.rstrip('/')
    fn = (os.path.basename(fn) if fn else 'index')
    if (('.' not in fn) and content_type):
        content_type = content_type.split(';')[0]
        if (content_type == 'text/plain'):
            ext = '.txt'
        else:
            ext = mimetypes.guess_extension(content_type)
        if (ext == '.htm'):
            ext = '.html'
        if ext:
            fn += ext
    return fn

dataset/ETHPy150Open RoseOu/flasky/venv/lib/python2.7/site-packages/httpie/downloads.py filename_from_url/original