I noticed already and I’ve been using that documentation :). I’m finding both the documentation and code to be great: clean, easily understood, well thought out, and behaves exactly as expected. Thank you for sharing!
A couple thoughts:
For the benefit of anyone following along: with the new context manager, the example gist above becomes nice and simple:
#!/usr/bin/env python3 from autobean_refactor import editor, models e = editor.Editor() def format_double_payee(file): """ A brokerage at some point started repeating their memo strings in some of their ofx files, so they look like this: 'DIVIDEND REINVESTMENTDIVIDEND REINVESTMENT'. This function fixes that. """ for d in file.directives: if isinstance(d, models.Transaction): if d.payee: if d.payee[:int(len(d.payee)/2)] == d.payee[int(len(d.payee)/2):]: d.payee = d.payee[:int(len(d.payee)/2)] with e.edit_file_recursive('/home/user/accounts/main.bc') as files: for f in files: print(f"Processing: {f}") format_double_payee(files[f])