from pathlib import Path


def check_db_dir(parent: Path):
    """Checks whether the db directory exists.
    If not, create it.

    Args:
        parent (Path): the parent to both server_settings and db

    Returns:
        Path: the directory itself

    Raises:
        Exception: the db dir path exists, but it isn't a directory

    """
    db_dir = parent / 'db'
    if db_dir.exists() and not db_dir.is_dir():
        raise Exception(f"""{db_dir} exists, but it isn't a directory!""")
    elif not db_dir.exists():
        db_dir.mkdir()

    return db_dir