From: Paul T. <pau...@gm...> - 2011-02-03 02:52:14
|
On 2/2/11 4:15 PM, Guenter Milde wrote: > On 2011-02-02, Paul Tremblay wrote: >> A simple question (I think). Can someone show me how to use the front >> end tools (or any other method) that allows me to convert an RST file to >> XML so that I get a string? I also need to use command line arguments. >> from docutils.core import publish_cmdline, default_description >> description = ('Generates Docutils-native XML from standalone ' >> 'reStructuredText sources. ' + default_description) >> publish_cmdline(writer_name='xml', description=description) >> Outputs to the terminal. I need to capture the output as a string (or as >> a path) and do further transformations. > >> status, output = commands.getstatusoutput('rst2xml.py --arsg >> file.rst') > >> Would work, but that is a bit of a hack, to say the least. > How about re-directing sys.stdout? > Meaning what? |