(stats: PrimitiveDict)
return stats_collector
Given a dictionary following this layout:

        {
            'encoded:label': 'Encoded',
            'encoded:value': 'Yes',
            'encoded:description': 'Indicates if the column is encoded',
            'encoded:include': True,

            'size:label': 'Size',
            'size:value': 128,
            'size:description': 'Size of the table in MB',
            'size:include': True,
        }

    format_stats will convert the dict into a StatsDict with keys of 'encoded'
    and 'size'.
Given a dictionary following this layout:
Given a dictionary following this layout :
def format_stats(stats: PrimitiveDict) -> StatsDict:
    """Given a dictionary following this layout:

        {
            'encoded:label': 'Encoded',
            'encoded:value': 'Yes',
            'encoded:description': 'Indicates if the column is encoded',
            'encoded:include': True,

            'size:label': 'Size',
            'size:value': 128,
            'size:description': 'Size of the table in MB',
            'size:include': True,
        }

    format_stats will convert the dict into a StatsDict with keys of 'encoded'
    and 'size'.
    """
    stats_collector: StatsDict = {}

    base_keys = {k.split(':')[0] for k in stats}
    for key in base_keys:
        dct: PrimitiveDict = {'id': key}
        for subkey in ('label', 'value', 'description', 'include'):
            dct[subkey] = stats['{}:{}'.format(key, subkey)]

        try:
            stats_item = StatsItem.from_dict(dct)
        except ValidationError:
            continue
        if stats_item.include:
            stats_collector[key] = stats_item

    # we always have a 'has_stats' field, it's never included
    has_stats = StatsItem(
        id='has_stats',
        label='Has Stats?',
        value=len(stats_collector) > 0,
        description='Indicates whether there are statistics for this table',
        include=False,
    )
    stats_collector['has_stats'] = has_stats
    return stats_collector
def format_stats ( stats : PrimitiveDict ) -> StatsDict : stats_collector : StatsDict = { } base_keys = { k . split ( ':' ) [ 0 ] for k in stats } for key in base_keys : dct : PrimitiveDict = { 'id' : key } for subkey in ( 'label' , 'value' , 'description' , 'include' ) : dct [ subkey ] = stats [ '{}:{}' . format ( key , subkey ) ] try : stats_item = StatsItem . from_dict ( dct ) except ValidationError : continue if stats_item . include : stats_collector [ key ] = stats_item # we always have a 'has_stats' field, it's never included has_stats = StatsItem ( id = 'has_stats' , label = 'Has Stats?' , value = len ( stats_collector ) > 0 , description = 'Indicates whether there are statistics for this table' , include = False , ) stats_collector [ 'has_stats' ] = has_stats return stats_collector