|
From: David G. <go...@py...> - 2003-01-25 15:58:48
|
Andreas Jung wrote:
> I tried upgrading the docutils package for the Zope 2.7 release but
> the API seems to have changed since November.
Are you surprised? ;-)
> The following code does no longer work and I can figure out why:
...
> pub.set_reader('restructuredtext', None, 'restructuredtext')
...
> ImportError: No module named restructuredtext
On November 8th I "removed bogus aliases" from docutils/readers/__init__.py
(version 1.12). There is no such thing as a "restructuredtext" reader; that
was a mistake ("restructuredtext" is the parser). Use "standalone"
instead::
pub.set_reader('standalone', None, 'restructuredtext')
It looks like your code was copied from Richard Jones' ZReST writer module.
I fixed his code when I made the changes, but didn't know about yours.
I also changed the IO classes' API a bit. They'll still work the old way,
but raise a deprecation warning. As of Docutils 0.3, the old way will stop
working. Change this:
> pub.source = docutils.io.StringInput(pub.settings)
> pub.source.source = src
To this:
pub.source = docutils.io.StringInput(
source=self.source, encoding=pub.settings.input_encoding)
And this:
> pub.destination = docutils.io.StringOutput(pub.settings)
To this:
pub.destination = docutils.io.StringOutput(
encoding=pub.settings.output_encoding)
You should be able to simplify your code a lot if you use the
docutils.core.publish_string convenience function. It might even insulate
your code against future changes -- not that I'm planning any, but one never
knows. Docutils *is* still experimental.
-- David Goodger http://starship.python.net/~goodger
Programmer/sysadmin for hire: http://starship.python.net/~goodger/cv
|