from typing import Dict
import logging
import csv


def read_index(pack_index_path: str) -> Dict[str, str]:
    """
    Reads an index from the page name to the path of the stored pack.

    Args:
        pack_index_path: The path of this index file. The file should be a tab
        separated file.

    Returns:
        A dictionary that maps from the page name to the full path.
    """
    page_idx: Dict[str, str] = {}

    logging.info("Reading pack index from %s", pack_index_path)

    with open(pack_index_path) as idx:
        for page_name, page_path in csv.reader(idx, delimiter='\t'):
            page_idx[page_name] = page_path
    return page_idx