import csv


def get_abilities(csv_dir):
    """Get information to build pokediadb.models.Ability objects.

    Args:
        csv_dir (pathlib.Path): Path to csv directory.

    Returns:
        dict: Dict of dict containing infos to build
            pokediadb.models.Ability object.

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

    """
    pkm_abilities = {}
    with (csv_dir / "abilities.csv").open(encoding="utf8") as f_ability:
        reader = csv.reader(f_ability)
        next(reader)  # Skip header

        for row in reader:
            ability_id = int(row[0])
            # Skip weird abilities
            if ability_id > 10000:
                break

            pkm_abilities[ability_id] = {
                "id": int(row[0]), "generation": int(row[2])
            }

    return pkm_abilities