# Path: budgettracker/data.py
# def update_accounts(old_accounts, new_accounts):
#     old = {acc.id: acc for acc in old_accounts}
#     new_ids = [acc.id for acc in new_accounts]
#     final = []
#     for acc in new_accounts:
#         if acc.id in old:
#             final.append(old[acc.id].update(amount=acc.amount))
#         else:
#             final.append(acc)
#     for acc in old_accounts:
#         if acc.id not in new_ids:
#             final.append(acc)
#     return final
# 
# def update_transactions(old_transactions, new_transactions):
#     old = {tx.id: tx for tx in old_transactions}
#     final = []
#     for tx in new_transactions:
#         if tx.id in old:
#             final.append(tx.update(
#                 categories=list(set(old[tx.id].categories or []) | set(tx.categories or [])),
#                 goal=old[tx.id].goal
#             ))
#             old.pop(tx.id)
#         else:
#             final.append(tx)
#     return old.values() + final


from base import *
from ..data import update_accounts, update_transactions


class MultiAdapter(BankAdapter):
    name = 'Multiple adapters'

    @property
    def adapters(self):
        for name in self.config.get('bank_adapters', []):
            yield get_bank_adapter(name)(self.config, self.filename)


# Path: budgettracker/data.py
# def update_accounts(old_accounts, new_accounts):
#     old = {acc.id: acc for acc in old_accounts}
#     new_ids = [acc.id for acc in new_accounts]
#     final = []
#     for acc in new_accounts:
#         if acc.id in old:
#             final.append(old[acc.id].update(amount=acc.amount))
#         else:
#             final.append(acc)
#     for acc in old_accounts:
#         if acc.id not in new_ids:
#             final.append(acc)
#     return final
# 
# def update_transactions(old_transactions, new_transactions):
#     old = {tx.id: tx for tx in old_transactions}
#     final = []
#     for tx in new_transactions:
#         if tx.id in old:
#             final.append(tx.update(
#                 categories=list(set(old[tx.id].categories or []) | set(tx.categories or [])),
#                 goal=old[tx.id].goal
#             ))
#             old.pop(tx.id)
#         else:
#             final.append(tx)
#     return old.values() + final


# Path: budgettracker/bank_adapters/multi.py
from base import *
from ..data import update_accounts, update_transactions



class MultiAdapter(BankAdapter):
    name = 'Multiple adapters'

    @property
    def adapters(self):
        for name in self.config.get('bank_adapters', []):
            yield get_bank_adapter(name)(self.config, self.filename)


    @property