# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/utils/files.ipynb.

# %% auto 0
__all__ = ['upsert_folder', 'change_extension']

# %% ../../nbs/utils/files.ipynb 2
import os
import pathlib

# %% ../../nbs/utils/files.ipynb 3
def upsert_folder(folder_path: str, debug_prn: bool = False):
    folder_path = os.path.dirname(folder_path)

    if debug_prn:
        print(
            {
                "upsert_folder": os.path.abspath(folder_path),
                "is_exist": os.path.exists(folder_path),
            }
        )

    if not os.path.exists(folder_path):
        os.makedirs(folder_path)

# %% ../../nbs/utils/files.ipynb 5
def change_extension(file_path, new_extension):
    path = pathlib.PurePath(file_path)
    new_file_path = path.with_suffix("." + new_extension)
    return str(new_file_path)
