[Zope-Checkins] CVS: Zope/lib/python/docutils/parsers/rst/directives - __init__.py:1.1.2.2 admonitions.py:1.1.2.2 body.py:1.1.2.2 html.py:1.1.2.2 images.py:1.1.2.2 misc.py:1.1.2.2 parts.py:1.1.2.2 references.py:1.1.2.2
Andreas Jung
andreas@andreas-jung.com
Sat, 25 Jan 2003 07:44:44 -0500
Update of /cvs-repository/Zope/lib/python/docutils/parsers/rst/directives
In directory cvs.zope.org:/tmp/cvs-serv2352/parsers/rst/directives
Modified Files:
Tag: ajung-restructuredtext-integration-branch
__init__.py admonitions.py body.py html.py images.py misc.py
parts.py references.py
Log Message:
docutils updated
=== Zope/lib/python/docutils/parsers/rst/directives/__init__.py 1.1.2.1 => 1.1.2.2 ===
--- Zope/lib/python/docutils/parsers/rst/directives/__init__.py:1.1.2.1 Tue Nov 5 04:03:58 2002
+++ Zope/lib/python/docutils/parsers/rst/directives/__init__.py Sat Jan 25 07:44:09 2003
@@ -122,30 +122,37 @@
def directive(directive_name, language_module, document):
"""
Locate and return a directive function from its language-dependent name.
- If not found in the current language, check English.
+ If not found in the current language, check English. Return None if the
+ named directive cannot be found.
"""
normname = directive_name.lower()
messages = []
+ msg_text = []
if _directives.has_key(normname):
return _directives[normname], messages
+ canonicalname = None
try:
canonicalname = language_module.directives[normname]
- except (KeyError, AttributeError):
- warning = document.reporter.warning(
- 'No directive entry for "%s" in module "%s".'
- % (directive_name, language_module.__name__),
- line=document.current_line)
+ except AttributeError, error:
+ msg_text.append('Problem retrieving directive entry from language '
+ 'module %r: %s.' % (language_module, error))
+ except KeyError:
+ msg_text.append('No directive entry for "%s" in module "%s".'
+ % (directive_name, language_module.__name__))
+ if not canonicalname:
try:
- # Try English as a fallback:
canonicalname = _fallback_language_module.directives[normname]
- warning[-1] += nodes.Text(
- 'Using English fallback for directive "%s".' % directive_name)
+ msg_text.append('Using English fallback for directive "%s".'
+ % directive_name)
except KeyError:
- warning[-1] += nodes.Text(
- 'Trying "%s" as canonical directive name.' % directive_name)
+ msg_text.append('Trying "%s" as canonical directive name.'
+ % directive_name)
# The canonical name should be an English name, but just in case:
canonicalname = normname
- messages.append(warning)
+ if msg_text:
+ message = document.reporter.info(
+ '\n'.join(msg_text), line=document.current_line)
+ messages.append(message)
try:
modulename, functionname = _directive_registry[canonicalname]
except KeyError:
=== Zope/lib/python/docutils/parsers/rst/directives/admonitions.py 1.1.2.1 => 1.1.2.2 ===
=== Zope/lib/python/docutils/parsers/rst/directives/body.py 1.1.2.1 => 1.1.2.2 ===
=== Zope/lib/python/docutils/parsers/rst/directives/html.py 1.1.2.1 => 1.1.2.2 ===
=== Zope/lib/python/docutils/parsers/rst/directives/images.py 1.1.2.1 => 1.1.2.2 ===
=== Zope/lib/python/docutils/parsers/rst/directives/misc.py 1.1.2.1 => 1.1.2.2 ===
--- Zope/lib/python/docutils/parsers/rst/directives/misc.py:1.1.2.1 Tue Nov 5 04:03:58 2002
+++ Zope/lib/python/docutils/parsers/rst/directives/misc.py Sat Jan 25 07:44:09 2003
@@ -11,15 +11,16 @@
import sys
import os.path
from urllib2 import urlopen, URLError
-from docutils import nodes, statemachine, utils
+from docutils import io, nodes, statemachine, utils
from docutils.parsers.rst import directives, states
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."""
- source_dir = os.path.dirname(
- os.path.abspath(state.document.current_source))
+ source = state_machine.input_lines.source(
+ lineno - state_machine.input_offset - 1)
+ source_dir = os.path.dirname(os.path.abspath(source))
path = ''.join(arguments[0].splitlines())
if path.find(' ') != -1:
error = state_machine.reporter.error(
@@ -29,14 +30,14 @@
path = os.path.normpath(os.path.join(source_dir, path))
path = utils.relative_path(None, path)
try:
- include_file = open(path)
+ include_file = io.FileInput(
+ source_path=path, encoding=state.document.settings.input_encoding)
except IOError, error:
severe = state_machine.reporter.severe(
'Problems with "%s" directive path:\n%s.' % (name, error),
nodes.literal_block(block_text, block_text), line=lineno)
return [severe]
include_text = include_file.read()
- include_file.close()
if options.has_key('literal'):
literal_block = nodes.literal_block(include_text, include_text,
source=path)
@@ -45,13 +46,7 @@
else:
include_lines = statemachine.string2lines(include_text,
convert_whitespace=1)
- current_source = state.document.current_source
- state.document.note_source(path)
- state.memo.reporter.source = path
- state.nested_parse(include_lines, 0, node=state_machine.node,
- match_titles=state_machine.match_titles)
- state.document.note_source(current_source)
- state.memo.reporter.source = current_source
+ state_machine.insert_input(include_lines, path)
return []
include.arguments = (1, 0, 1)
=== Zope/lib/python/docutils/parsers/rst/directives/parts.py 1.1.2.1 => 1.1.2.2 ===
=== Zope/lib/python/docutils/parsers/rst/directives/references.py 1.1.2.1 => 1.1.2.2 ===