def _write_to_filepath(content, output):
    """
    :param content: Content string to write to
    :param output: Output file path
    """
    outdir = os.path.dirname(output)
    if outdir and not os.path.exists(outdir):
        os.makedirs(outdir)

    with anytemplate.compat.copen(output, 'w') as out:
        out.write(content)