def compile(node,
                uri,
                filename=None,
                default_filters=None,
                buffer_filters=None,
                imports=None,
                future_imports=None,
                source_encoding=None,
                generate_magic_comment=True,
                disable_unicode=False,
                strict_undefined=False,
                enable_loop=True,
                reserved_names=frozenset()):

    """Generate module source code given a parsetree node,
      uri, and optional source filename"""

    # if on Py2K, push the "source_encoding" string to be
    # a bytestring itself, as we will be embedding it into
    # the generated source and we don't want to coerce the
    # result into a unicode object, in "disable_unicode" mode
    if not compat.py3k and isinstance(source_encoding, compat.text_type):
        source_encoding = source_encoding.encode(source_encoding)


    buf = util.FastEncodingBuffer()

    printer = PythonPrinter(buf)
    _GenerateRenderMethod(printer,
                            _CompileContext(uri,
                                            filename,
                                            default_filters,
                                            buffer_filters,
                                            imports,
                                            future_imports,
                                            source_encoding,
                                            generate_magic_comment,
                                            disable_unicode,
                                            strict_undefined,
                                            enable_loop,
                                            reserved_names),
                                node)
    return buf.getvalue()
def compile ( node , uri , filename = None , default_filters = None , buffer_filters = None , imports = None , future_imports = None , source_encoding = None , generate_magic_comment = True , disable_unicode = False , strict_undefined = False , enable_loop = True , reserved_names = frozenset ( ) ) : if not compat . py3k and isinstance ( source_encoding , compat . text_type ) : source_encoding = source_encoding . encode ( source_encoding ) buf = util . FastEncodingBuffer ( ) printer = PythonPrinter ( buf ) _GenerateRenderMethod ( printer , _CompileContext ( uri , filename , default_filters , buffer_filters , imports , future_imports , source_encoding , generate_magic_comment , disable_unicode , strict_undefined , enable_loop , reserved_names ) , node ) return buf . getvalue ( )
Generate module source code given a parsetree node,
      uri, and optional source filename