import ledger
import re
account_re = "Assets:Cash"
# A poor man's register report
running_total = ledger.Value(0)
for txn in ledger.Journal("/tmp/bug.dat"):
for post in txn:
if re.match(account_re, str(post.account)):
running_total += post.amount
print "%s %-20.20s %-20.20s %12s %12s" % \
(txn.date, txn.payee, post.account, post.amount,
running_total)
Beyond just making most of the Ledger objects available so you can
drive reports from top down, like above, you can add new function's to
Ledger's value expression namespace. Any global Python function is
callable from any value expression, so long as you use --import option
to pull in the definitions. Then you can use those functions in
filters, sorting terms, automated expressions, expression-based
posting amounts, etc.
John