from django.utils.module_loading import import_string
from django.conf import settings
import random
import string
import os


def _get_or_create_path(path: str) -> str:
    current_path = ""
    if path:
        current_path = path
    else:
        current_path = "Untitled" + _get_random_string()
    return str(current_path)


def _add_slugify_filename(filename: str) -> str:
    name, ext = os.path.splitext(filename)
    slugified = _get_random_string()
    return str(slugified + ext)


def _get_random_string() -> str:
    return "".join(random.sample(string.ascii_lowercase * 16, 16))


def _get_storage_class() -> str:
    return import_string(
        getattr(
            settings,
            "STORAGE",
            "django.core.files.storage.DefaultStorage",
        )
    )()


_storage = _get_storage_class()

from django.utils.module_loading import import_string
from django.conf import settings
import random
import string
import os


def _get_or_create_path(path: str) -> str:
    current_path = ""
    if path:
        current_path = path
    else:
        current_path = "Untitled" + _get_random_string()
    return str(current_path)


def _add_slugify_filename(filename: str) -> str:
    name, ext = os.path.splitext(filename)
    slugified = _get_random_string()
    return str(slugified + ext)


def _get_random_string() -> str:
    return "".join(random.sample(string.ascii_lowercase * 16, 16))


def _get_storage_class() -> str:
    return import_string(
        getattr(
            settings,
            "STORAGE",
            "django.core.files.storage.DefaultStorage",
        )
    )()


_storage = _get_storage_class()
