summaryrefslogtreecommitdiff
path: root/src/py_account.cc
diff options
context:
space:
mode:
authorELIPTUS <eliptus+git@gmail.com>2014-11-12 22:51:56 -0800
committerELIPTUS <eliptus+git@gmail.com>2014-11-12 22:51:56 -0800
commitaf571c104790b0703d94b0f94b949041cf4f5c1d (patch)
tree43d0d7024aeb3d0f9327307f420acd9b5c182b32 /src/py_account.cc
parenta3f3aa304fcfb19fc716c5eaf33a6e152bb3aa71 (diff)
downloadfork-ledger-af571c104790b0703d94b0f94b949041cf4f5c1d.tar.gz
fork-ledger-af571c104790b0703d94b0f94b949041cf4f5c1d.tar.bz2
fork-ledger-af571c104790b0703d94b0f94b949041cf4f5c1d.zip
Improve Embedded Python Support
Discussion: https://groups.google.com/d/msg/ledger-cli/kq9sKoRX9vw/fmyhvPslzokJ
Diffstat (limited to 'src/py_account.cc')
-rw-r--r--src/py_account.cc27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/py_account.cc b/src/py_account.cc
index 3054512e..7b8eda8c 100644
--- a/src/py_account.cc
+++ b/src/py_account.cc
@@ -35,6 +35,7 @@
#include "pyutils.h"
#include "account.h"
#include "post.h"
+#include "expr.h"
namespace ledger {
@@ -97,6 +98,26 @@ namespace {
return str_to_py_unicode(account.fullname());
}
+ value_t py_amount_0(const account_t& account)
+ {
+ return account.amount();
+ }
+
+ value_t py_amount_1(const account_t& account, const boost::optional<expr_t&>& expr)
+ {
+ return account.amount(expr);
+ }
+
+ value_t py_total_0(const account_t& account)
+ {
+ return account.total();
+ }
+
+ value_t py_total_1(const account_t& account, const boost::optional<expr_t&>& expr)
+ {
+ return account.total(expr);
+ }
+
} // unnamed namespace
void export_account()
@@ -221,8 +242,10 @@ void export_account()
.def("xdata", py_xdata,
return_internal_reference<>())
- .def("amount", &account_t::amount)
- .def("total", &account_t::total)
+ .def("amount", py_amount_0)
+ .def("amount", py_amount_1, args("expr"))
+ .def("total", py_total_0)
+ .def("total", py_total_1, args("expr"))
.def("self_details", &account_t::self_details,
return_internal_reference<>())