from typing import Tuple
from typing import Dict
import io
import tarfile


def get_items_from_tar(binary: bytes) -> Tuple[str, Dict[str, bytes]]:
    """
    Return dictionary of tar file contents.

    Parameters
    ----------
    binary : bytes
        byte array of zip file

    Returns
    -------
    Tuple[str, Dict[str, bytes]]
        Filetype + dictionary of file name + file content

    """
    file_obj = io.BytesIO(binary)
    # Open tarfile
    with tarfile.open(mode="r", fileobj=file_obj) as tar:
        archive_dict: Dict[str, bytes] = {}
        # Iterate over every member
        for item in tar.getnames():
            tar_file = tar.extractfile(item)
            archive_dict[item] = tar_file.read() if tar_file else b""
        return "tar", archive_dict