def write_cache(cache, fobj, format=None):
<EOL>if isinstance(fobj, string_types):<EOL><INDENT>with open(fobj, '<STR_LIT:w>') as fobj2:<EOL><INDENT>return write_cache(cache, fobj2, format=format)<EOL><DEDENT><DEDENT>if format is None:<EOL><INDENT>formatter = str<EOL><DEDENT>elif format.lower() == "<STR_LIT>":<EOL><INDENT>formatter = _format_entry_lal<EOL><DEDENT>elif format.lower() == "<STR_LIT>":<EOL><INDENT>formatter = _format_entry_ffl<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>".format(format))<EOL><DEDENT>for line in map(formatter, cache):<EOL><INDENT>try:<EOL><INDENT>print(line, file=fobj)<EOL><DEDENT>except TypeError:  <EOL><INDENT>fobj.write("<STR_LIT>".format(line).encode("<STR_LIT:utf-8>"))<EOL><DEDENT><DEDENT>
Write a `list` of cache entries to a file

    Parameters
    ----------
    cache : `list` of `str`
        The list of file paths to write

    fobj : `file`, `str`
        The open file object, or file path to write to.

    format : `str`, optional
        The format to write to, one of

        - `None` : format each entry using `str`
        - ``'lal'`` : write a LAL-format cache
        - ``'ffl'`` : write an FFL-format cache