def run(self):
if not self.state.document.settings.file_insertion_enabled:<EOL><INDENT>raise self.warning('<STR_LIT>' % self.name)<EOL><DEDENT>source = self.state_machine.input_lines.source(<EOL>self.lineno - self.state_machine.input_offset - <NUM_LIT:1>)<EOL>source_dir = os.path.dirname(os.path.abspath(source))<EOL>path = rst.directives.path(self.arguments[<NUM_LIT:0>])<EOL>path = os.path.normpath(os.path.join(source_dir, path))<EOL>path = utils.relative_path(None, path)<EOL>path = nodes.reprunicode(path)<EOL>encoding = self.options.get(<EOL>'<STR_LIT>', self.state.document.settings.input_encoding)<EOL>e_handler = self.state.document.settings.input_encoding_error_handler<EOL>tab_width = self.options.get(<EOL>'<STR_LIT>', self.state.document.settings.tab_width)<EOL>try:<EOL><INDENT>self.state.document.settings.record_dependencies.add(path)<EOL>include_file = io.FileInput(source_path=path,<EOL>encoding=encoding,<EOL>error_handler=e_handler)<EOL><DEDENT>except UnicodeEncodeError as error:<EOL><INDENT>raise self.severe('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(self.name, SafeString(path)))<EOL><DEDENT>except IOError as error:<EOL><INDENT>raise self.severe('<STR_LIT>' %<EOL>(self.name, ErrorString(error)))<EOL><DEDENT>try:<EOL><INDENT>rawtext = include_file.read()<EOL><DEDENT>except UnicodeError as error:<EOL><INDENT>raise self.severe('<STR_LIT>' %<EOL>(self.name, ErrorString(error)))<EOL><DEDENT>config = self.state.document.settings.env.config<EOL>converter = M2R(no_underscore_emphasis=config.no_underscore_emphasis)<EOL>include_lines = statemachine.string2lines(converter(rawtext),<EOL>tab_width,<EOL>convert_whitespace=True)<EOL>self.state_machine.insert_input(include_lines, path)<EOL>return []<EOL>
Most of this method is from ``docutils.parser.rst.Directive``.

        docutils version: 0.12