def fix_type(typ, size, additional=None):
    """Fix up creating the appropriate struct type based on the information in the column."""
    if additional is not None:
        my_types = types + additional
    else:
        my_types = types

    for t, info in my_types:
        if callable(t):
            matches = t(typ)
        else:
            matches = t == typ

        if matches:
            if callable(info):
                fmt_str, true_size = info(size)
            else:
                fmt_str, true_size = info
            assert size == true_size, ('{}: Got size {} instead of {}'.format(typ, size,
                                                                              true_size))
            return fmt_str.format(size=size)

    raise ValueError('No type match! ({})'.format(typ))
def fix_type ( typ , size , additional = None ) : if additional is not None : my_types = types + additional else : my_types = types for t , info in my_types : if callable ( t ) : matches = t ( typ ) else : matches = t == typ if matches : if callable ( info ) : fmt_str , true_size = info ( size ) else : fmt_str , true_size = info assert size == true_size , ( '{}: Got size {} instead of {}' . format ( typ , size , true_size ) ) return fmt_str . format ( size = size ) raise ValueError ( 'No type match! ({})' . format ( typ ) )
Fix up creating the appropriate struct type based on the information in the column.