[Checkins] SVN: docutils/tags/0.4.0-zope/ Branch docutils 0.4.0 to include local patch, disabling docutils file inclusion.

Tres Seaver tseaver at palladion.com
Thu Jul 6 23:10:20 EDT 2006


Log message for revision 69017:
  Branch docutils 0.4.0 to include local patch, disabling docutils file inclusion.
  

Changed:
  A   docutils/tags/0.4.0-zope/
  U   docutils/tags/0.4.0-zope/parsers/rst/directives/misc.py

-=-
Copied: docutils/tags/0.4.0-zope (from rev 69016, docutils/tags/0.4.0)

Modified: docutils/tags/0.4.0-zope/parsers/rst/directives/misc.py
===================================================================
--- docutils/tags/0.4.0/parsers/rst/directives/misc.py	2006-07-07 02:56:30 UTC (rev 69016)
+++ docutils/tags/0.4.0-zope/parsers/rst/directives/misc.py	2006-07-07 03:10:20 UTC (rev 69017)
@@ -28,50 +28,7 @@
 def include(name, arguments, options, content, lineno,
             content_offset, block_text, state, state_machine):
     """Include a reST file as part of the content of this reST file."""
-    if not state.document.settings.file_insertion_enabled:
-        warning = state_machine.reporter.warning(
-              '"%s" directive disabled.' % name,
-              nodes.literal_block(block_text, block_text), line=lineno)
-        return [warning]
-    source = state_machine.input_lines.source(
-        lineno - state_machine.input_offset - 1)
-    source_dir = os.path.dirname(os.path.abspath(source))
-    path = directives.path(arguments[0])
-    if path.startswith('<') and  path.endswith('>'):
-        path = os.path.join(standard_include_path, path[1:-1])
-    path = os.path.normpath(os.path.join(source_dir, path))
-    path = utils.relative_path(None, path)
-    encoding = options.get('encoding', state.document.settings.input_encoding)
-    try:
-        state.document.settings.record_dependencies.add(path)
-        include_file = io.FileInput(
-            source_path=path, encoding=encoding,
-            error_handler=state.document.settings.input_encoding_error_handler,
-            handle_io_errors=None)
-    except IOError, error:
-        severe = state_machine.reporter.severe(
-              'Problems with "%s" directive path:\n%s: %s.'
-              % (name, error.__class__.__name__, error),
-              nodes.literal_block(block_text, block_text), line=lineno)
-        return [severe]
-    try:
-        include_text = include_file.read()
-    except UnicodeError, error:
-        severe = state_machine.reporter.severe(
-              'Problem with "%s" directive:\n%s: %s'
-              % (name, error.__class__.__name__, error),
-              nodes.literal_block(block_text, block_text), line=lineno)
-        return [severe]
-    if options.has_key('literal'):
-        literal_block = nodes.literal_block(include_text, include_text,
-                                            source=path)
-        literal_block.line = 1
-        return literal_block
-    else:
-        include_lines = statemachine.string2lines(include_text,
-                                                  convert_whitespace=1)
-        state_machine.insert_input(include_lines, path)
-        return []
+    raise NotImplementedError, 'File inclusion not allowed!'
 
 include.arguments = (1, 0, 1)
 include.options = {'literal': directives.flag,
@@ -87,6 +44,8 @@
     Content may be included inline (content section of directive) or
     imported from a file or url.
     """
+    if options.has_key('file') or options.has_key('url'):
+        raise NotImplementedError, 'File inclusion not allowed!'
     if ( not state.document.settings.raw_enabled
          or (not state.document.settings.file_insertion_enabled
              and (options.has_key('file') or options.has_key('url'))) ):



More information about the Checkins mailing list