import re


def pull_stats(summary: list) -> dict:
    """
    Convert stats to a dictionary.

    Each line in the summary table in the log file needs to be parsed by first
    converting the table to a comma-separated list for easy parsing, then
    taking the first column as the statistical category and placing the
    remaining values into maximum, minimum, mean, and standard deviation.

    Parameters
    ----------
    summary : list
        A ``list`` of ``strings`` representing each line in the summary table
        of the metadata file.

    Returns
    -------
    dict
        Returns a ``dictionary`` of the converted table.
    """
    results = {}

    for stat in summary:
        # Convert the table to a comma-separated list to make it easier to
        # parse.
        stat = stat.replace(':', '')
        stat_csv = re.sub('  +', ',', stat.strip())
        components = stat_csv.split(',')
        key, max_val, min_val, mean, stdev = components
        results[key] = {
            'max': float(max_val),
            'min': float(min_val),
            'mean': float(mean),
            'stdev': float(stdev)
        }
    return results