Only finally-write around the ledger yield up

lifo_pps_ib
Tyler Goodlet 2022-06-16 10:52:43 -04:00
parent fbee33b00d
commit 3dcb72d429
1 changed files with 4 additions and 4 deletions

View File

@ -69,10 +69,10 @@ def open_trade_ledger(
) )
with open(tradesfile, 'w') as cf: with open(tradesfile, 'w') as cf:
pass # touch pass # touch
try:
with open(tradesfile, 'r') as cf: with open(tradesfile, 'r') as cf:
ledger = toml.load(tradesfile) ledger = toml.load(tradesfile)
cpy = ledger.copy() cpy = ledger.copy()
try:
yield cpy yield cpy
finally: finally:
if cpy != ledger: if cpy != ledger: