You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
imaginAIry/imaginairy/utils/format_file_name.py

20 lines
514 B
Python

import os
from urllib.parse import urlparse
def format_filename(format_template: str, data: dict) -> str:
"""
Formats the filename based on the provided template and variables.
"""
if not isinstance(format_template, str):
raise TypeError("format argument must be a string")
filename = format_template.format(**data)
return filename
def get_url_file_name(url):
parsed = urlparse(url)
model_name, _ = os.path.splitext(os.path.basename(parsed.path))
return model_name