import csv


def get_type_efficacies(csv_dir, pkm_types):
    """Get information to build pokediadb.models.TypeEfficacy objects.

    Args:
        csv_dir (pathlib.Path): Path to csv directory.
        pkm_types (dict): Dict of dict containing type infos.

    Returns:
        list: Dict containing infos to build
            pokediadb.models.TypeEfficacy object.

    Raises:
        FileNotFoundError: Raised if type_efficacy.csv does not exist.

    """
    pkm_type_eff = []
    with (csv_dir / "type_efficacy.csv").open(encoding="utf8") as f_type_eff:
        reader = csv.reader(f_type_eff)
        next(reader)  # Skip header

        for row in reader:
            pkm_type_eff.append({
                "damage_type": pkm_types[int(row[0])]["id"],
                "target_type": pkm_types[int(row[1])]["id"],
                "damage_factor": int(row[2])
            })

    return pkm_type_eff