[py-svn] r10775 - py/dist/py/misc
hpk at codespeak.net
hpk at codespeak.net
Sun Apr 17 16:33:03 CEST 2005
Author: hpk
Date: Sun Apr 17 16:33:03 2005
New Revision: 10775
Modified:
py/dist/py/misc/rest.py
Log:
allow for an explicit encoding (defaults to 'latin1')
Modified: py/dist/py/misc/rest.py
==============================================================================
--- py/dist/py/misc/rest.py (original)
+++ py/dist/py/misc/rest.py Sun Apr 17 16:33:03 2005
@@ -8,7 +8,7 @@
def log(msg):
pass
-def convert_rest_html(source, source_path, stylesheet=None):
+def convert_rest_html(source, source_path, stylesheet=None, encoding='latin1'):
""" return html latin1-encoded document for the given input.
source a ReST-string
sourcepath where to look for includes (basically)
@@ -18,14 +18,14 @@
kwargs = {
'stylesheet' : stylesheet,
'traceback' : 1,
- 'output_encoding' : 'latin1',
+ 'output_encoding' : encoding,
#'halt' : 0, # 'info',
'halt_level' : 2,
}
return publish_string(source, str(source_path), writer_name='html',
settings_overrides=kwargs)
-def process(txtpath):
+def process(txtpath, encoding='latin1'):
""" process a textfile """
log("processing %s" % txtpath)
assert txtpath.check(ext='.txt')
@@ -37,8 +37,8 @@
stylesheet = style.basename
else:
stylesheet = None
- doc = convert_rest_html(txtpath.read(), txtpath,
- stylesheet=stylesheet)
+ content = unicode(txtpath.read(), encoding)
+ doc = convert_rest_html(content, txtpath, stylesheet=stylesheet, encoding=encoding)
htmlpath.write(doc)
#log("wrote %r" % htmlpath)
#if txtpath.check(svnwc=1, versioned=1):
More information about the pytest-commit
mailing list