Python Bindings

John Ralls jralls at ceridwen.us
Sat May 31 15:27:25 EDT 2014


On May 31, 2014, at 11:42 AM, Marc Shapiro wrote:

> Keeping this on the list...
> 
> That's documentation, of a sort.  Not great, but it does pretty much verify that there is nothing in there for handling budget, or future transactions.  Since I would need that in order to do a proper forecasting report (Balance Sheet on an arbitrary date in the future) it looks like my only option is to try and teach myself just enough Guile to follow the current reports and combine them.  I had started on this, then got stuck.  I figured that if there was a way to avoid learning any LISP derivative that it was a good thing to do.  It does not look like it is going to work out,, however.  It's either back to Guile, or pass on creating the report.

Why not instead add python to the swig files for the API that you need? It's only one header, gnc-budget.h, and you can use the Guile adapter code in src/engine/engine.i as a guide.

Regards,
John Ralls


> 
> On 05/28/2014 08:37 AM, angus wrote:
>> Marc
>> 
>> I'm a fairly typical programmer - what's documentation :-)
>> 
>> I've mainly been using it to manage my shares/investments - determining cost base, summarise income and yield for a period (financial year), etc. The few lines below give an example of what I'm producing. The problem I had experienced was the change covered in Bug 726430 - Python: account.getName() raises TypeError - "Account functions return Accounts or lists of Accounts now instead of SwigPyObjects." so was fairly easy to sort out once I'd figured that out.
>> 
>> XXX - XXX Limited (609.00 shares; Mkt Price: $2728.32) as at 2013-06-30
>> Date             Shares     Price        Value Expenses    Share Bal    Value Bal    Cost Base Description
>> ---------- ------------ --------- ------------ --------- ------------ ------------ ------------ -----------
>> 1997-11-20     152.0000   10.4300     1,585.36 0.00     152.0000     1,585.36     1,585.36 Demutualisation
>> 1998-06-22      52.0000   18.7000       972.40 17.02     204.0000     2,557.76     2,574.78 Buy some more
>> 
>> I run my Python scripts outside of gnucash. I see you've been investigating tying them in more neatly with the gnucash Report menu (https://www.mail-archive.com/gnucash-devel@gnucash.org/msg34711.html ).  I also looked briefly at Scheme-guile and decided native Python was the way to go.  Sometime in the future I might look at integrating it/them better.
>> 
>> I haven't yet looked at Budget info or Future transactions neither with the bindings or gnucash itself. If I understood things a little more I'd guess that currently the bindings for these aren't there. If you look at http://svn.gnucash.org/docs/head/annotated.html and expand python-bindings it might give a flavour for what's currently covered.
>> 
>> Once I'm more comfortable with what I'm doing/done I will document it for the greater good.
>> 
>> Kind regards
>> 
>> AnGus
>> 
>> On 28/05/14 22:25, Marc Shapiro wrote:
>>> Angus,
>>> 
>>> I have a few questions about Python bindings, and since you have been using them regularly...  Do you have any documentation on what can, or cannot be done with them?  What functions are available?  What the syntax for those functions is?  Do the bindings include functions to access budget info, or Future Transactions?
>>> 
>>> Marc
>> -- 
>> Kind regards
>> 
>> AnGus King
>> Switched on Solar!
> 
> _______________________________________________
> gnucash-devel mailing list
> gnucash-devel at gnucash.org
> https://lists.gnucash.org/mailman/listinfo/gnucash-devel




More information about the gnucash-devel mailing list