from pathlib import Path


def save_string(data: str, file_path: Path) -> bool:
    """Save a string. Makes parent directories if they don't exist.

    Traps all errors and prints them to std out.

    Arguments:
        data {str} -- The string to save
        file_path {Path} -- Path to the saved file.

    Returns:
        bool -- True if successful
    """
    try:
        if not file_path.parent.exists():
            file_path.parent.mkdir(parents=True)
        with open(file_path, "w") as out_file:
            out_file.write(data)
    except Exception as e:
        print(e)
        return False
    return True