import csv


def get_types(csv_dir):
    """Get information to build pokediadb.models.Type objects.

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

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

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

    """
    pkm_types = {}
    with (csv_dir / "types.csv").open(encoding="utf8") as f_type:
        reader = csv.reader(f_type)
        next(reader)  # Skip header

        for row in reader:
            type_id = int(row[0])

            # Skip shadow and unknown types
            if type_id > 10000:
                break

            pkm_types[type_id] = {"id": type_id, "generation": int(row[2])}

    return pkm_types