#!/usr/bin/env python
import os
import sys

import gnucash
import gnucash.gnucash_business

print gnucash
print gnucash.gnucash_business

Session = gnucash.Session
Entry = gnucash.gnucash_business.Entry

uri = "xml://{0}".format(os.path.abspath(sys.argv[1]))
ses = Session(uri, is_new=False)
try:
    book = ses.get_book()
    invoice = book.InvoiceLookupByID('0001')
    assert(len(invoice.GetEntries()) == 3)
    for e in invoice.GetEntries():
        entry = Entry(instance=e)
        print entry.GetDescription()
finally:
    ses.end()
