def generate_from_template(template, exclude=None):
    # name, ctype, capable of holding NA
    function_list = [
        ('float64', 'float64_t', 'np.float64', True, True),
        ('float32', 'float32_t', 'np.float32', True, True),
        ('object', 'object', 'object', True, False),
        ('int32', 'int32_t', 'np.int32', False, True),
        ('int64', 'int64_t', 'np.int64', False, True),
        ('bool', 'uint8_t', 'np.bool', False, True)
    ]

    output = StringIO()
    for name, c_type, dtype, can_hold_na, nogil in function_list:
        if exclude is not None and name in exclude:
            continue

        func = template % {'name': name, 'c_type': c_type,
                           'dtype': dtype,
                           'raise_on_na': 'False' if can_hold_na else 'True',
                           'nogil' : 'with nogil:' if nogil else '',
                           'tab' : '    ' if nogil else '' }
        output.write(func)
        output.write("\n")
    return output.getvalue()
dataset/ETHPy150Open pydata/pandas/pandas/src/generate_code.py/generate_from_template/original