#!/usr/bin/env python3 with open("redmine_tickets.py") as f: txt = f.read() # Fix the missing ) after no-preview arg old = ''' help="Disable fzf right-hand preview pane.", if add_tui_parser is not None:''' new = ''' help="Disable fzf right-hand preview pane.", ) if add_tui_parser is not None:''' if old in txt: txt = txt.replace(old, new, 1) print("Replaced missing ) block") else: print("Old not found, trying looser fixes") # Ensure ) before the if txt = txt.replace('pane.",\n if add', 'pane.",\n )\n\n if add') with open("redmine_tickets.py", "w") as f: f.write(txt) print("Saved")