summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-09-17 19:33:10 -0400
committerJohn Wiegley <johnw@newartisans.com>2004-09-17 19:33:10 -0400
commita2bbd7dc8fa3e5ae07bb662689bb107945aacf2e (patch)
treeb2da54da50944fe6ca28331e0efa61ac3ec539bc
parent79b664f6f0399ac1b272de89107515aa6af20dcd (diff)
downloadfork-ledger-a2bbd7dc8fa3e5ae07bb662689bb107945aacf2e.tar.gz
fork-ledger-a2bbd7dc8fa3e5ae07bb662689bb107945aacf2e.tar.bz2
fork-ledger-a2bbd7dc8fa3e5ae07bb662689bb107945aacf2e.zip
fixes to main.py
-rw-r--r--journal.cc18
-rw-r--r--ledger.h28
-rwxr-xr-xmain.py5
3 files changed, 47 insertions, 4 deletions
diff --git a/journal.cc b/journal.cc
index 702f013b..dde4a1d2 100644
--- a/journal.cc
+++ b/journal.cc
@@ -578,6 +578,9 @@ void export_journal()
class_< transaction_t > ("Transaction")
.def(init<account_t *, amount_t, optional<unsigned int, std::string> >())
+ .def(self == self)
+ .def(self != self)
+
.add_property("entry",
make_getter(&transaction_t::entry,
return_value_policy<reference_existing_object>()))
@@ -593,6 +596,9 @@ void export_journal()
class_< account_t >
("Account", init<optional<account_t *, std::string, std::string> >())
+ .def(self == self)
+ .def(self != self)
+
.def_readwrite("parent", &account_t::parent)
.def_readwrite("name", &account_t::name)
.def_readwrite("note", &account_t::note)
@@ -615,11 +621,18 @@ void export_journal()
;
class_< journal_t > ("Journal")
+ .def(self == self)
+ .def(self != self)
+
.def_readonly("sources", &journal_t::sources)
.def("__len__", entries_len)
+#if 0
.def("__getitem__", entries_getitem, return_internal_reference<1>())
-
+#else
+ .def("__getitem__", entries_getitem,
+ return_value_policy<reference_existing_object>())
+#endif
.def("add_account", &journal_t::add_account)
.def("remove_account", &journal_t::remove_account)
.def("find_account", py_find_account_1, return_internal_reference<1>())
@@ -634,6 +647,9 @@ void export_journal()
;
scope in_entry = class_< entry_t > ("Entry")
+ .def(self == self)
+ .def(self != self)
+
.def_readwrite("date", &entry_t::date)
.def_readwrite("state", &entry_t::state)
.def_readwrite("code", &entry_t::code)
diff --git a/ledger.h b/ledger.h
index b1bb7fc0..cc177f82 100644
--- a/ledger.h
+++ b/ledger.h
@@ -62,6 +62,13 @@ class transaction_t
delete cost;
}
+ bool operator==(const transaction_t& xact) {
+ return this == &xact;
+ }
+ bool operator!=(const transaction_t& xact) {
+ return ! (*this == xact);
+ }
+
bool valid() const;
};
@@ -96,6 +103,13 @@ class entry_t
(*i)->~transaction_t();
}
+ bool operator==(const entry_t& entry) {
+ return this == &entry;
+ }
+ bool operator!=(const entry_t& entry) {
+ return ! (*this == entry);
+ }
+
void add_transaction(transaction_t * xact);
bool remove_transaction(transaction_t * xact);
@@ -129,6 +143,13 @@ class account_t
~account_t();
+ bool operator==(const account_t& account) {
+ return this == &account;
+ }
+ bool operator!=(const account_t& account) {
+ return ! (*this == account);
+ }
+
std::string fullname() const;
void add_account(account_t * acct) {
@@ -183,6 +204,13 @@ class journal_t
}
~journal_t();
+ bool operator==(const journal_t& journal) {
+ return this == &journal;
+ }
+ bool operator!=(const journal_t& journal) {
+ return ! (*this == journal);
+ }
+
void add_account(account_t * acct) {
master->add_account(acct);
}
diff --git a/main.py b/main.py
index 6fbf7c34..6eb5ae31 100755
--- a/main.py
+++ b/main.py
@@ -106,7 +106,8 @@ class FormatTransaction (TransactionHandler):
self.output.flush ()
def __call__ (self, xact):
- if self.nformatter is not None and xact.entry is self.last_entry:
+ if self.nformatter is not None and self.last_entry is not None and \
+ xact.entry.payee == self.last_entry.payee:
self.output.write(self.nformatter.format(xact))
else:
self.output.write(self.formatter.format(xact))
@@ -150,9 +151,7 @@ if 0:
else:
# These for loops are equivalent to `walk_entries', but far slower
for entry in journal:
- #print "1:", entry
for xact in entry:
- #print "2:", xact.entry
handler (xact)
handler.flush ()