import json
from pathlib import Path


def load_settings(filepath):
    """
    Load settings from json file.

    Parameters
    ----------
    filepath: pathlib.Path
        Where to find redcode_settings.json

    Returns
    -------
    dict
    """
    try:
        sett = json.loads(filepath.read_text())
    except FileNotFoundError:
        sett = {"loadfrom": str(Path.home())}
        filepath.write_text(json.dumps(sett, indent=2))
    return sett