def METHOD_NAME(url, replace_ext=None, subdir=None):
    if subdir:
        filename = os.path.join(data_dir, subdir, url.split("/")[-1])
    else:
        filename = os.path.join(data_dir, url.split("/")[-1])
    if replace_ext:
        dot_index = filename.rfind(".")
        filename = filename[:dot_index] + replace_ext
    return filename