[Zope-Checkins] CVS: Zope/lib/python/reStructuredText - __init__.py:1.3
Andreas Jung
andreas@andreas-jung.com
Sat, 1 Feb 2003 08:16:22 -0500
Update of /cvs-repository/Zope/lib/python/reStructuredText
In directory cvs.zope.org:/tmp/cvs-serv3433/lib/python/reStructuredText
Modified Files:
__init__.py
Log Message:
- removed debug print
- added env. variables for input/output encodings
=== Zope/lib/python/reStructuredText/__init__.py 1.2 => 1.3 ===
--- Zope/lib/python/reStructuredText/__init__.py:1.2 Sat Feb 1 04:26:22 2003
+++ Zope/lib/python/reStructuredText/__init__.py Sat Feb 1 08:16:20 2003
@@ -17,9 +17,14 @@
import docutils.core
from docutils.io import StringOutput, StringInput
-import sys
+import sys, os
+
+default_input_encoding = os.environ.get("REST_INPUT_ENCODING", sys.getdefaultencoding())
+default_output_encoding = os.environ.get("REST_OUTPUT_ENCODING", sys.getdefaultencoding())
+
class Warnings:
+
def __init__(self):
self.messages = []
@@ -28,7 +33,8 @@
def HTML(src, writer='html4zope', report_level=1, stylesheet='default.css',
- input_encoding=None, output_encoding=None):
+ input_encoding=default_input_encoding,
+ output_encoding=default_output_encoding):
""" render HTML from a reStructuredText string
- 'src' -- string containing a valid reST document
@@ -44,12 +50,6 @@
pub.set_reader('standalone', None, 'restructuredtext')
pub.set_writer(writer)
- if input_encoding is None:
- input_encoding = sys.getdefaultencoding()
-
- if output_encoding is None:
- output_encoding = sys.getdefaultencoding()
-
# go with the defaults
pub.get_settings()
@@ -78,6 +78,5 @@
warnings = ''.join(pub.settings.warning_stream.messages)
# do the format
- print pub.writer.write(document, pub.destination)
return pub.writer.write(document, pub.destination)