INNER CODE UNIT · Python
is_last
DogsTailFarmer/martin-binance · martin_binance/backup.py:128
is_last = idx == len(sorted_keys) - 1
comma = "" if is_last else ","
if key.startswith("orders") and isinstance(value, dict):
lines.append(f' "{key}": {{')
tp_val = orjson.dumps(value.get("tp_order_id")).decode('utf-8')
lines.append(f' "tp_order_id": {tp_val},')
lines.append(' "items": [')
orders_lines = []
for order in value.get("items", []):
order_str = orjson.dumps(order).decode('utf-8')
orders_lines.append(f' {order_str}')
lines.append(",\n".join(orders_lines))
lines.append(' ]')
lines.append(f' }}{comma}')