import yaml


def boat_skill_map(file):
    """Load a mapping between boat classes and skills required for this class.

    file: yaml file containing a dict with the mapping {skill: boat_class}
    Returns:
        boat_for_skill: a dict mapping {skill: boat_class}
        skill_for_boat: a dict mapping {boat_class: skill}

    """
    boat_for_skill = yaml.safe_load(file.open("r"))
    skill_for_boat = dict()
    for skill, boatclasses in boat_for_skill.items():
        for bclass in boatclasses:
            skill_for_boat.setdefault(bclass, []).append(skill)

    return boat_for_skill, skill_for_boat