from portal import cache_file, io
from portal.portal_io import cache_dir


def get_pretrained_name_or_path(config, default):
    if hasattr(config, "path") and config.path is not None and io.isfile(config.path):
        return cache_file(config.path, check_md5=True, force=True)
    elif hasattr(config, "path") and config.path is not None and io.isdir(config.path):
        return cache_dir(config.path, check_md5=True, force=True)
    return default

from portal import cache_file, io
from portal.portal_io import cache_dir


def get_pretrained_name_or_path(config, default):
    if hasattr(config, "path") and config.path is not None and io.isfile(config.path):
        return cache_file(config.path, check_md5=True, force=True)
    elif hasattr(config, "path") and config.path is not None and io.isdir(config.path):
        return cache_dir(config.path, check_md5=True, force=True)
    return default
