def to_file(env,header='',setenv='setenv {0} {1}'):
    """Convert config file data to module file.

    Parameters
    ----------
    env : collections.OrderedDict
        A mapping containing all the configuration file data.
    header : str
        String to add to the header of the file produced.
    setenv : str
        The method for setting environment variables in this file type.

    Returns
    -------
    lines : str
        A string representation of the file.
    """
    if len(header) == 0:
        lines = """#
# This file sets up tree/{0}.
#
""".format(env['default']['name'])
    else: lines = header.format(**env['default'])
    for section in env:
        if section == 'default': continue
        lines += """#
# {0}
#
""".format(section)
        setenvs = list()
        for k in env[section]: setenvs.append(setenv.format(k,env[section][k]))
        lines += "\n".join(setenvs)
        lines += "\n"
    return lines