[Zope-Checkins] CVS: Zope/lib/python/reStructuredText -
__init__.py:1.7.2.2.4.4
Christian 'Tiran' Heimes
heimes at faho.rwth-aachen.de
Wed May 12 15:58:43 EDT 2004
Update of /cvs-repository/Zope/lib/python/reStructuredText
In directory cvs.zope.org:/tmp/cvs-serv4203/lib/python/reStructuredText
Modified Files:
Tag: tiran-restfixing-branch
__init__.py
Log Message:
cleanup imports
=== Zope/lib/python/reStructuredText/__init__.py 1.7.2.2.4.3 => 1.7.2.2.4.4 ===
--- Zope/lib/python/reStructuredText/__init__.py:1.7.2.2.4.3 Wed May 12 15:24:09 2004
+++ Zope/lib/python/reStructuredText/__init__.py Wed May 12 15:58:41 2004
@@ -18,9 +18,11 @@
try:
import docutils
except ImportError:
- docutils_version = None
+ docutils_version = ''
+ version_tuple = None
else:
docutils_version = docutils.__version__
+ version_tuple = tuple(docutils_version.split('.'))
from App.config import getConfiguration
from zLOG import LOG as log
@@ -40,19 +42,19 @@
if default_lang and '_' in default_lang:
default_lang = default_lang[:default_lang.index('_')]
-if docutils_version is None:
+if version_tuple is None:
USE_DOCUTILS = False
log('reStructuredText', PROBLEM, 'docutils package not found.')
-elif docutils_version >= '0.3.4':
+elif version_tuple >= ('0', '3', '4'):
USE_DOCUTILS = True
USE_NEW_IMPLEMENTATION = True
log('reStructuredText', INFO, 'is using the NEW implementation of the reST '
- 'writer.')
+ 'writer (version %s).' % docutils_version)
else:
USE_DOCUTILS = True
USE_NEW_IMPLEMENTATION = False
log('reStructuredText', INFO, 'is using the OLD implementation of the reST '
- 'writer.')
+ 'writer (version %s).' % docutils_version)
class Warnings:
@@ -63,7 +65,7 @@
self.messages.append(message)
######################################################################
-# old style implementation
+# old style implementation (XXX remove it later)
# works with older versions of docutils
if USE_DOCUTILS and not USE_NEW_IMPLEMENTATION:
from docutils.core import Publisher
@@ -82,7 +84,7 @@
output_encoding=default_output_encoding,
language_code=default_lang,
warnings = None,
- **kwargs):
+ settings = {}):
""" render HTML from a reStructuredText string
@@ -102,7 +104,7 @@
- 'warnings' - will be overwritten with a string containing the warnings
- - 'kwargs' - more keyword args which are applied to the parser
+ - 'settings' - more keyword args which are applied to the parser
"""
pub = Publisher(source_class=io.StringInput,
destination_class=io.StringOutput
@@ -113,8 +115,7 @@
pub.set_writer(writer)
# update settings for kwargs
- settings = pub.get_settings()
- kwargs.update({
+ settings.update({
'stylesheet' : stylesheet,
'_destination' : None, # this is needed, but doesn't seem to do anything
'report_level' : report_level,
@@ -124,7 +125,7 @@
'output_encoding' : output_encoding,
'language_code' : language_code,
})
- settings._update(kwargs, 'loose')
+ pub.get_settings()._update(settings, 'loose')
# set source and destination
pub.set_source(source=src)
@@ -154,7 +155,7 @@
output_encoding=default_output_encoding,
language_code=default_lang,
warnings = None,
- settings=None):
+ settings = {}):
""" render HTML from a reStructuredText string
@@ -180,7 +181,7 @@
"""
# Docutils settings:
- settings = (settings or {}).copy()
+ settings = settings.copy()
settings['input_encoding'] = input_encoding
settings['output_encoding'] = output_encoding
settings['stylesheet'] = stylesheet
More information about the Zope-Checkins
mailing list