This patch stores the original name of an account in the account class, and allows python interface to get it back.
Since the --no-aliases
flag is ignored in a python context, there is
no other way to get the actual name of the account.
diff --git a/src/account.h b/src/account.h
index 7ea0e269..7d29ecfe 100644
--- a/src/account.h
+++ b/src/account.h
@@ -71,6 +71,7 @@ public:
posts_list posts;
optional<deferred_posts_map_t> deferred_posts;
optional<expr_t> value_expr;
+ string original_alias;
mutable string _fullname;
#if DOCUMENT_MODEL
diff --git a/src/journal.cc b/src/journal.cc
index a6559e3d..5968fb28 100644
--- a/src/journal.cc
+++ b/src/journal.cc
@@ -162,6 +162,7 @@ account_t * journal_t::expand_aliases(string name) {
// then Bar:Foo will be expanded to Baaz:Bar:Foo.
// The expansion loop keeps a list of already expanded names in order to
// prevent infinite excursion. Each alias may only be expanded at most once.
+ string original_name = name;
account_t * result = NULL;
if (no_aliases)
@@ -210,6 +211,9 @@ account_t * journal_t::expand_aliases(string name) {
keep_expanding = false;
}
} while(keep_expanding && recursive_aliases);
+ if (result) {
+ result->original_alias = original_name;
+ }
return result;
}
diff --git a/src/py_account.cc b/src/py_account.cc
index 2e1fd35b..7999b473 100644
--- a/src/py_account.cc
+++ b/src/py_account.cc
@@ -210,6 +210,7 @@ void export_account()
.def_readwrite("name", &account_t::name)
.def_readwrite("note", &account_t::note)
.def_readonly("depth", &account_t::depth)
+ .def_readonly("original_alias", &account_t::original_alias)
.def("__str__", &account_t::fullname)
.def("__unicode__", py_account_unicode)