简体   繁体   English

如何捕获MoinMoin解析器的输出?

[英]How do I capture the output from a MoinMoin parser?

Say I'm writing a parser, and want to include the output of another parser in the results I'm returning. 假设我正在编写一个解析器,并且想在我返回的结果中包括另一个解析器的输出。 If I do something like this: 如果我做这样的事情:

WikiParser = wikiutil.importPlugin(self.request.cfg, 'parser', 'text_moin_wiki', 'Parser')
wp = WikiParser("some text",self.request)
wp.format(self.formatter)

then WikiParser will throw the results of its work straight into my self.request object. 然后WikiParser会将其工作结果直接放入我的self.request对象中。

I'd like to intercept that, though - I'd rather grab the results of the WikiParser work, and manipulate them a bit more. 不过,我想拦截一下-我宁愿抓取WikiParser工作的结果,并对其进行更多操作。

Is there a way for me to do this? 我有办法吗? How do I do it? 我该怎么做?

为此,Request对象具有redirectedOutput函数:

parsed_formatted_string = self.request.redirectedOutput(wp.format, self.formatter)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM