report in python, a first version
John Ralls
jralls at ceridwen.us
Mon Nov 14 23:37:10 EST 2016
> On Nov 14, 2016, at 7:05 PM, Sébastien de Menten <sdementen at gmail.com> wrote:
>
> On Nov 15, 2016 1:27 AM, "John Ralls" <jralls at ceridwen.us <mailto:jralls at ceridwen.us>> wrote:
> >
> >
> > > On Nov 14, 2016, at 1:31 PM, Sébastien de Menten <sdementen at gmail.com <mailto:sdementen at gmail.com>> wrote:
> > >
> > > Hello,
> > >
> > > I have finished a first version of a mechanism to use python for reporting
> > > in gnucash.
> > > It uses a scheme script to start a python process that does the heavy
> > > lifthing.
> > >
> > > Should you be interested, you can find documentation/instructions here:
> > > http://gnucash-utilities.readthedocs.io/en/master/doc/doc.html#report-creation-linux-and-windows-python-3-5 <http://gnucash-utilities.readthedocs.io/en/master/doc/doc.html#report-creation-linux-and-windows-python-3-5>
> > > as well as an example of the simplest report possible
> > > http://gnucash-utilities.readthedocs.io/en/master/doc/doc.html#a-simple-report <http://gnucash-utilities.readthedocs.io/en/master/doc/doc.html#a-simple-report>
> > >
> > > Any feedback appreciated.
> >
> > Sébastien,
> >
> > Did you decide to not use the facility in src/optional/python to start a Python interpreter inside of GnuCash because you didn't know about it, because it was easier to do something in Scheme, or because that interpreter can't interact with the existing (Scheme) report facilities?
> >
> > Regards,
> > John Ralls
> >
>
> I didn't (and still don't) know a lot about this embedded python interpreter. Any link pointing to doc by any chance ?
> I wanted something that could leverage the "report options" framework (this is purely in scheme, correct ?), could be hot plugable on gnucash (no recompilation) and rather generic (the subprocess can be any specific python intepreter, usually one in a virtualenv, but this could be adapted to launch any subprocess ... perl ? node.js ?).
> I therefore hacked a way via scheme reusing logic found in the quote updater to spawn external processes.
> If anything can be simplified/better designed, I am in.
>
>
Sébastien,
Sorry, wrong directory. The regular python bindings are in src/optional/python; the embedded interpreter is in src/python.
I don't think there's any docs beyond whatever comments are in the module. History says it was a drive-by contribution 5+ years ago that Christian polished up a bit and committed.
Options, including report options but not preferences, are a horror-show that bounces back and forth between C and Scheme. The C bits are obviously swigged so that Scheme can see them. IIRC (I haven't looked at it in a bit over a year) Scheme passes callbacks to C rather than there being anything directly callable from C, so any Python code that wanted to get at it would have to duplicate the Scheme part of the functionality. There might be a way to get at the Scheme functions via Guile (whose internals are exposed both as C and Scheme), but it wouldn't be a trivial undertaking.
Regards,
John Ralls
More information about the gnucash-devel
mailing list