<s> from django . conf import settings <EOL> from django . utils . importlib import import_module <EOL> from docutils import core <EOL> import os <EOL> REST_BACKENDS = getattr ( settings , '<STR_LIT>' , ( <EOL> '<STR_LIT>' , <EOL> ) ) <EOL> for name in REST_BACKENDS : <EOL> import_module ( name ) . register ( ) <EOL> TEMPLATE = os . path . join ( os . path . dirname ( __file__ ) , '<STR_LIT>' ) <EOL> def html_parts ( input_string , source_path = None , destination_path = None , <EOL> input_encoding = '<STR_LIT>' , doctitle = <NUM_LIT:1> , initial_header_level = <NUM_LIT:2> ) : <EOL> """<STR_LIT>""" <EOL> if not isinstance ( input_string , unicode ) : <EOL> input_string = input_string . decode ( '<STR_LIT:utf8>' ) <EOL> overrides = { '<STR_LIT>' : input_encoding , <EOL> '<STR_LIT>' : doctitle , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : TEMPLATE , <EOL> '<STR_LIT>' : initial_header_level } <EOL> parts = core . publish_parts ( <EOL> source = input_string , source_path = source_path , <EOL> destination_path = destination_path , <EOL> writer_name = '<STR_LIT>' , settings_overrides = overrides ) <EOL> return parts <EOL> def html_body ( input_string , source_path = None , destination_path = None , <EOL> input_encoding = '<STR_LIT>' , output_encoding = '<STR_LIT>' , <EOL> doctitle = <NUM_LIT:1> , initial_header_level = <NUM_LIT:2> ) : <EOL> """<STR_LIT>""" <EOL> parts = html_parts ( <EOL> input_string = input_string , source_path = source_path , <EOL> destination_path = destination_path , <EOL> input_encoding = input_encoding , doctitle = doctitle , <EOL> initial_header_level = initial_header_level ) <EOL> fragment = parts [ '<STR_LIT>' ] <EOL> if output_encoding != '<STR_LIT>' : <EOL> fragment = fragment . encode ( output_encoding ) <EOL> return fragment </s>
