Python report-writing mechanism?
hendrik at topoi.pooq.com
hendrik at topoi.pooq.com
Tue Mar 6 20:45:39 EST 2007
On Tue, Mar 06, 2007 at 11:18:25PM +0000, Roger McCalman wrote:
> On Tue, Mar 06, 2007 at 05:37:45PM -0500, Michael B. Trausch wrote:
> > Is there any known mechanisms for perhaps being able to create GnuCash
> > reports in a more friendly language, such as Python, or is Scheme the
> > only mechanism for this? (And, are there any plans to perhaps permit
> > GnuCash to interface with Python that anyone knows of?)
>
> I have some shell and perl scripts that extract the required data from
> the XML file to generate a text report to fill my VAT return in. It works
> for the limited use I make of it.
>
> I wrote them by examining the XML rather than looking at any DTD's or docs
> so it is probably not a good way to do it.
*Are* there DTD's?
I've been looking at cduce, and have drafted a set of cduce type
definitions for my gnucash files. There's probably a lot left out that
I'm not using, though.
cduce's type definitions seem pretty adequate. I'm still looking for a
few af the tree-transformatios I need, though. Still learning. Started
this about two days ago, so there's hope. Perhaps a cduce-ocaml hybrid
is what's needed.
In case anyone is interested, I've attached what I've found out so far.
-- hendrik
=============cut=============
namespace gnc = "http://www.gnucash.org/XML/gnc"
namespace act = "http://www.gnucash.org/XML/act"
namespace book = "http://www.gnucash.org/XML/book"
namespace cd = "http://www.gnucash.org/XML/cd"
namespace cmdty = "http://www.gnucash.org/XML/cmdty"
namespace slot = "http://www.gnucash.org/XML/slot"
namespace trn = "http://www.gnucash.org/XML/trn"
namespace ts = "http://www.gnucash.org/XML/ts"
namespace split = "http://www.gnucash.org/XML/split"
let sss = "frame"
type gnc-v2 = <gnc-v2>[
( gnc_book
| book:id
| gnc_count_data
| gnc_commodity
| gnc_account
| gnc_transaction
)* ]
type gnc_count_data = <gnc:count-data cd:type=String>[ '0'--'9'+ ]
type gnc_book = <gnc:book version=String>[
( book:id
| gnc_count_data
| gnc_commodity
| gnc_account
| gnc_transaction)* ]
type book:id = <book:id type=String>[ Char* ]
type gnc_commodity = <gnc:commodity version=String>
[ cmdty_space
cmdty_id
cmdty_name
cmdty_xcode?
cmdty_fraction
cmdty_get_quotes?
cmdty_quote_source?
cmdty_quote_tz?
]
type gnc_account = <gnc:account version=String>[
act_name
act_id
act_type
act_commodity
act_commodity-scu
act_description?
act_slots?
act_parent?]
type act_name = <act:name >[Char*]
type act_id = <act:id type=String>[Char*] /* ID */
type act_type = <act:type >[Char*]
type act_commodity = <act:commodity>[cmdty_space cmdty_id]
type act_commodity-scu = <act:commodity-scu>[ '0'--'9'+ ]
type act_description = <act:description>[Char*]
type act_parent = <act:parent type=String>[Char *]
type act_slots = <act:slots>[ slot* ]
type slot = <slot>[slot_key slot_value]
type slot_key = <slot:key>[Char*]
type slot_value = <slot:value type="string"> [ Char* ]
| <slot:value type="frame"> [ slot* ]
| <slot:value type="integer"> [ '-'?'0'--'9'* ]
type gnc_transaction = <gnc:transaction version=String >[
trn_id
trn_currency
trn_num?
trn_date-posted
trn_date-entered
trn_description
trn_splits ]
type trn_id = <trn:id type=String>[ Char *] /* hash */
type trn_currency = <trn:currency >[cmdty_space cmdty_id]
type trn_num = <trn:num>[Char*]
type trn_date-posted = <trn:date-posted>[ts_date] /* TODO: date */
type trn_date-entered = <trn:date-entered>[ts_date ts_ns?]
type trn_description = <trn:description >[Char *]
type trn_splits = <trn:splits>[trn_split*]
type trn_split = <trn:split>[
split_id
split_action?
split_memo?
split_reconciled-state
split_reconcile-date? /* only if reconciled_state says so */
split_value
split_quantity
split_account]
type split_id = <split:id type=String>[Char*] /* hash */
type split_action = <split:action>['-'] /* What is this? */
type split_memo = <split:memo>[Char*]
type split_reconcile-date = <split:reconcile-date>[ts_date] /* date */
type split_reconciled-state = <split:reconciled-state>[Char] /* TODO:
which chars? */
type split_value = <split:value>[('-'?'0'--'9'+)'/'('0'--'9'+)]
type split_quantity = <split:quantity>[('-'?'0'--'9'+)'/'('0'--'9'+)]
type split_account = <split:account type=String>[Char*] /* hash */
type ts_date = <ts:date>[Char *] /* TODO: date */
type ts_ns = <ts:ns>['0'--'9'*] /* What is this? */
type cmdty_space = <cmdty:space>[ Char* ]
type cmdty_id = <cmdty:id>[ Char* ]
type cmdty_name = <cmdty:name>[ Char* ]
type cmdty_xcode = <cmdty:xcode>[ '0'--'9'+ ]
type cmdty_fraction = <cmdty:fraction>[ '0'--'9'+ ]
type cmdty_get_quotes = <cmdty:get_quotes>[]
type cmdty_quote_source = <cmdty:quote_source>[ Char* ]
type cmdty_quote_tz = <cmdty:quote_tz>[]
=============end=============
More information about the gnucash-user
mailing list