from pathlib import Path from typing import List from src.models import Transaction, Config LEDGER_TRANSACTION_TEMPLATE = """ {t.date} {t.description} ; {t.row} {t.account2} {t.currency} {t.debit} {t.account1} {t.currency} {t.credit} """ def render_to_file(transactions: List[Transaction], config: Config): content = "".join([LEDGER_TRANSACTION_TEMPLATE.format(t=t) for t in transactions]) with open(config.output_file, 'a') as f: f.write(content)