From 6126d48e279e04aaa99cc7a17cda7a9803597ac2 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 7 Sep 2004 19:38:21 -0400 Subject: some python code fixes --- journal.cc | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'journal.cc') diff --git a/journal.cc b/journal.cc index e4c53dd0..2ef19555 100644 --- a/journal.cc +++ b/journal.cc @@ -405,7 +405,6 @@ bool journal_t::valid() const #ifdef USE_BOOST_PYTHON #include -#include using namespace boost::python; using namespace ledger; @@ -427,7 +426,12 @@ transaction_t& transactions_getitem(entry_t& entry, int i) throw_error_already_set(); } - return *(entry.transactions[i < 0 ? len + i : i]); + int x = i < 0 ? len + i : i; + transactions_list::iterator elem = entry.transactions.begin(); + while (--x >= 0) + elem++; + + return **elem; } unsigned int entries_len(journal_t& journal) @@ -444,7 +448,12 @@ entry_t& entries_getitem(journal_t& journal, int i) throw_error_already_set(); } - return *(journal.entries[i < 0 ? len + i : i]); + int x = i < 0 ? len + i : i; + entries_list::iterator elem = journal.entries.begin(); + while (--x >= 0) + elem++; + + return **elem; } unsigned int accounts_len(account_t& account) @@ -485,10 +494,6 @@ void export_journal() .def("valid", &transaction_t::valid) ; - class_< transactions_list > ("TransactionsList") - .def(vector_indexing_suite< transactions_list >()) - ; - class_< entry_t > ("Entry") .def_readwrite("date", &entry_t::date) .def_readwrite("state", &entry_t::state) @@ -528,14 +533,6 @@ void export_journal() .def("valid", &account_t::valid) ; - class_< entries_list > ("EntriesList") - .def(vector_indexing_suite< entries_list >()) - ; - - class_< strings_list > ("StringsList") - .def(vector_indexing_suite< strings_list >()) - ; - class_< journal_t > ("Journal") .def_readonly("sources", &journal_t::sources) -- cgit v1.2.3