There are a number of callbacks in rinterface that one can set to
control R's console -- setWriteConsole, setReadConsole, etc. This
patch fixes to limitations with the current API:
1) It is impossible to read out the current callback. This would be
useful for switching another callback into place temporarily, as in
something like:
def my_repr(robj):
saved = rinterface.getWriteConsole()
buf = []
def capture(s):
buf.append(s)
try:
rinterface.setWriteConsole(capture)
r["print"](robj)
finally:
rinterface.setWriteConsole(saved)
return "".join(buf)
2) The initial callback is NULL, but once a callback has been set, it
is impossible to set it back to NULL. In practice this isn't really a
problem, but in principle it could break the above idiom.
The attached patch adds getWriteConsole and friends, and defines them
to return None when a callback is unset, and allows None to be passed
back to setWriteConsole and friends to explicitly unset the
corresponding callback.
The patch builds and contains tests, but I haven't actually tested it
-- easy_install <my checkout> is producing a rinterface.so that fails
to import ("undefined symbol: R_ProcessEvents"). Probably just
something odd about my setup (though easy_install rpy2-2.0.1.tar.gz
worked fine), but FYI.
Thanks,
-- Nathaniel
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
rpy-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rpy-list