def export_comps(request):
in_memory = BytesIO()<EOL>zip = ZipFile(in_memory, "<STR_LIT:a>")<EOL>comps = settings.COMPS_DIR<EOL>static = settings.STATIC_ROOT or "<STR_LIT>"<EOL>context = RequestContext(request, {})<EOL>context['<STR_LIT>'] = False<EOL>for dirname, dirs, filenames in os.walk(static):<EOL><INDENT>for filename in filenames:<EOL><INDENT>full_path = os.path.join(dirname, filename)<EOL>rel_path = os.path.relpath(full_path, static)<EOL>content = open(full_path, '<STR_LIT:rb>').read()<EOL>try:<EOL><INDENT>ext = os.path.splitext(filename)[<NUM_LIT:1>]<EOL><DEDENT>except IndexError:<EOL><INDENT>pass<EOL><DEDENT>if ext == '<STR_LIT>':<EOL><INDENT>dotted_rel = os.path.relpath(static, full_path)<EOL>new_rel_path = '<STR_LIT>'.format(dotted_rel, '<STR_LIT>')<EOL>content = content.replace(b'<STR_LIT>', bytes(new_rel_path, '<STR_LIT:utf8>'))<EOL><DEDENT>path = os.path.join('<STR_LIT>', rel_path)<EOL>zip.writestr(path, content)<EOL><DEDENT><DEDENT>for dirname, dirs, filenames in os.walk(comps):<EOL><INDENT>for filename in filenames:<EOL><INDENT>full_path = os.path.join(dirname, filename)<EOL>rel_path = os.path.relpath(full_path, comps)<EOL>template_path = os.path.join(comps.split('<STR_LIT:/>')[-<NUM_LIT:1>], rel_path)<EOL>html = render_to_string(template_path, context)<EOL>depth = len(rel_path.split(os.sep)) - <NUM_LIT:1><EOL>if depth == <NUM_LIT:0>:<EOL><INDENT>dotted_rel = '<STR_LIT:.>'<EOL><DEDENT>else:<EOL><INDENT>dotted_rel = '<STR_LIT>'<EOL>i = <NUM_LIT:0><EOL>while i < depth:<EOL><INDENT>dotted_rel += '<STR_LIT>'<EOL>i += <NUM_LIT:1><EOL><DEDENT><DEDENT>new_rel_path = '<STR_LIT>'.format(dotted_rel, '<STR_LIT>')<EOL>html = html.replace('<STR_LIT>', new_rel_path)<EOL>if PY2:<EOL><INDENT>html = unicode(html)<EOL><DEDENT>zip.writestr(rel_path, html.encode('<STR_LIT:utf8>'))<EOL><DEDENT><DEDENT>for item in zip.filelist:<EOL><INDENT>item.create_system = <NUM_LIT:0><EOL><DEDENT>zip.close()<EOL>response = HttpResponse(content_type="<STR_LIT>")<EOL>response["<STR_LIT>"] = "<STR_LIT>"<EOL>in_memory.seek(<NUM_LIT:0>)<EOL>response.write(in_memory.read())<EOL>return response<EOL>
Returns a zipfile of the rendered HTML templates in the COMPS_DIR