import six


def query_builder(info, funcid):
    """Function builder for the query expression

    Parameters
    ----------
    info: dict
        From the `query_parser()`
    funcid: str
        The name for the function being generated

    Returns
    -------
    func: a python function of the query
    """
    args = info['args']
    def_line = 'def {funcid}({args}):'.format(funcid=funcid,
                                              args=', '.join(args))
    lines = [def_line, '    return {}'.format(info['source'])]
    source = '\n'.join(lines)
    glbs = {}
    six.exec_(source, glbs)
    return glbs[funcid]