some functions to make life easier when using python-bindings
More...
Go to the source code of this file.
some functions to make life easier when using python-bindings
- Author
- Christoph Holtermann (c.hol.nosp@m.term.nosp@m.ann@g.nosp@m.mx.d.nosp@m.e)
- Date
- May 2011
Definition in file gnc_convenience.py.
◆ find_account()
def gnc_convenience.find_account |
( |
|
account, |
|
|
|
name, |
|
|
|
account_list = None |
|
) |
| |
Recursively searches full names of account and descendents
returns a list of accounts which contain name.
options:
account: account to start search in.
name: name to search for.
account_list: (optional) list to append accounts to.
Definition at line 64 of file gnc_convenience.py.
64 def find_account(account,name,account_list=None):
65 """Recursively searches full names of account and descendents 67 returns a list of accounts which contain name. 71 account: account to start search in. 72 name: name to search for. 73 account_list: (optional) list to append accounts to. 80 for child
in account.get_children():
81 if type(child) != Account:
83 account_list=find_account(child,name,account_list)
85 account_name=account.GetName()
86 if name
in account_name:
87 account_list.append(account)
◆ find_lot()
def gnc_convenience.find_lot |
( |
|
lot_list, |
|
|
|
search_string |
|
) |
| |
Searches lots in lot_list for search_string.
returns list of lots where title contains search_string.
options:
lot_list: List of Lots to search in.
search_string: String to search for.
Definition at line 92 of file gnc_convenience.py.
92 def find_lot(lot_list,search_string):
93 """Searches lots in lot_list for search_string. 95 returns list of lots where title contains search_string. 99 lot_list: List of Lots to search in. 100 search_string: String to search for. 106 if type(lot).__name__ ==
'SwigPyObject':
107 lot = gnucash.GncLot(instance=lot)
108 ltitle=lot.get_title()
109 if search_string
in ltitle:
◆ find_split()
def gnc_convenience.find_split |
( |
|
split_list, |
|
|
|
search_string |
|
) |
| |
Searches a list of splits for search_string
returns a list of splits that have search_string as part of
memo or
description of parent transaction.
options:
split_list: List of Splits to search in.
search_string: String to search for.
Definition at line 114 of file gnc_convenience.py.
114 def find_split(split_list,search_string):
115 """Searches a list of splits for search_string 117 returns a list of splits that have search_string as part of 119 description of parent transaction. 123 split_list: List of Splits to search in. 124 search_string: String to search for. 129 for split
in split_list:
131 transaction_description=split.GetParent().GetDescription()
132 if (search_string
in memo)
or (search_string
in transaction_description):
◆ find_split_recursive()
def gnc_convenience.find_split_recursive |
( |
|
account, |
|
|
|
search_string |
|
) |
| |
Searches account and descendants for Splits containing search_string
returns a list of splits that have search_string as part of
memo or
description of parent transaction.
options:
account: Account to search in.
search_string: String to search for.
Definition at line 137 of file gnc_convenience.py.
137 def find_split_recursive(account, search_string):
138 """Searches account and descendants for Splits containing search_string 140 returns a list of splits that have search_string as part of 142 description of parent transaction. 146 account: Account to search in. 147 search_string: String to search for. 152 child_account_splits = []
155 for child
in account.get_children():
156 if type(child) != Account:
157 child =
Account(instance=child)
158 childsplits = find_split_recursive(child, search_string)
159 for split
in childsplits:
160 if type(split) != Split:
161 split = Split(instance=split)
162 child_account_splits += childsplits
165 splits=account.GetSplitList()
167 if type(split) != Split:
168 split = Split(instance=split)
169 basic_account_splits=find_split(splits,search_string)
171 rlist=child_account_splits+basic_account_splits
◆ find_transaction()
def gnc_convenience.find_transaction |
( |
|
account, |
|
|
|
name, |
|
|
|
ignore_case = True , |
|
|
|
transaction_list = None |
|
) |
| |
Searches the transactions of an account for name.
Searches in description and in memo of each split.
returns a list of transactions that match criteria.
options:
account: Account to search in.
name: String to search for.
ignore_case: (optional, default=True) Ignore case if True.
transaction_list: (optional) list of transactions to search in.
Definition at line 175 of file gnc_convenience.py.
175 def find_transaction(account,name,ignore_case=True,transaction_list=None):
176 """Searches the transactions of an account for name. 178 Searches in description and in memo of each split. 179 returns a list of transactions that match criteria. 183 account: Account to search in. 184 name: String to search for. 185 ignore_case: (optional, default=True) Ignore case if True. 186 transaction_list: (optional) list of transactions to search in. 190 if not transaction_list:
191 transaction_list=get_transaction_list(account)
197 for transaction
in transaction_list:
200 desc=transaction.GetDescription()
207 sl=transaction.GetSplitList()
209 if type(split) != Split:
210 split=Split(instance=split)
212 memo = split.GetMemo()
220 ret.append(transaction)
◆ get_splits_without_lot()
def gnc_convenience.get_splits_without_lot |
( |
|
account = None , |
|
|
|
split_list = None |
|
) |
| |
Returns a list of those Splits in split_list or account which do not have an according lot.
options:
account: (optional) Account to search in.
split_list: (optional) List of Splits to search in.
one or the other has to be provided.
Definition at line 37 of file gnc_convenience.py.
37 def get_splits_without_lot(account=None,split_list=None):
38 """Returns a list of those Splits in split_list or account which do not have an according lot. 42 account: (optional) Account to search in. 43 split_list: (optional) List of Splits to search in. 45 one or the other has to be provided. 52 split_list=account.GetSplitList()
55 for split
in split_list:
56 if type(split).__name__ ==
'SwigPyObject':
57 split = Split(instance=split)
◆ get_transaction_list()
def gnc_convenience.get_transaction_list |
( |
|
account | ) |
|
Returns all transactions in account.
Splits are derived from account.GetSplitList().
options:
account: Account to get transactions from.
Definition at line 15 of file gnc_convenience.py.
15 def get_transaction_list(account):
16 """Returns all transactions in account. 18 Splits are derived from account.GetSplitList(). 22 account: Account to get transactions from. 26 split_list=account.GetSplitList()
28 for split
in split_list:
29 if type(split) != Split:
30 split = Split(instance=split)
31 transaction=split.GetParent()
32 if not (transaction
in transaction_list):
33 transaction_list.append(transaction)
34 return transaction_list