import yaml


def validate_spackyaml(filename):
    """
    Ensure that a spack.yaml file has a spack or env directive
    """
    try:
        with open(filename, "r") as fd:
            data = yaml.load(fd, Loader=yaml.FullLoader)
            if "env" not in data and "spack" not in data:
                return False
            return True
    except yaml.YAMLError as exc:
        return False