For the benefit of anyone following along: with the new context manager, 
the example gist 
<https://gist.github.com/redstreet/251e3c886c74093881e836941e839ed8> 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]) 
​

-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/c62ab247-615a-4c42-9c67-21e3589e0667n%40googlegroups.com.

Reply via email to