(self)
Save breakpoints when file is saved
Save breakpoints when file is saved
Save breakpoints when file is saved
def store_file_breaks(self):
        "Save breakpoints when file is saved"
        # XXX 13 Dec 2002 KBK Currently the file must be saved before it can
        #     be run.  The breaks are saved at that time.  If we introduce
        #     a temporary file save feature the save breaks functionality
        #     needs to be re-verified, since the breaks at the time the
        #     temp file is created may differ from the breaks at the last
        #     permanent save of the file.  Currently, a break introduced
        #     after a save will be effective, but not persistent.
        #     This is necessary to keep the saved breaks synched with the
        #     saved file.
        #
        #     Breakpoints are set as tagged ranges in the text.
        #     Since a modified file has to be saved before it is
        #     run, and since self.breakpoints (from which the subprocess
        #     debugger is loaded) is updated during the save, the visible
        #     breaks stay synched with the subprocess even if one of these
        #     unexpected breakpoint deletions occurs.
        breaks = self.breakpoints
        filename = self.io.filename
        try:
            with open(self.breakpointPath, "r") as fp:
                lines = fp.readlines()
        except OSError:
            lines = []
        try:
            with open(self.breakpointPath, "w") as new_file:
                for line in lines:
                    if not line.startswith(filename + '='):
                        new_file.write(line)
                self.update_breakpoints()
                breaks = self.breakpoints
                if breaks:
                    new_file.write(filename + '=' + str(breaks) + '\n')
        except OSError as err:
            if not getattr(self.root, "breakpoint_error_displayed", False):
                self.root.breakpoint_error_displayed = True
                messagebox.showerror(title='IDLE Error',
                    message='Unable to update breakpoint list:\n%s'
                        % str(err),
                    parent=self.text)
def store_file_breaks ( self ) : # XXX 13 Dec 2002 KBK Currently the file must be saved before it can #     be run.  The breaks are saved at that time.  If we introduce #     a temporary file save feature the save breaks functionality #     needs to be re-verified, since the breaks at the time the #     temp file is created may differ from the breaks at the last #     permanent save of the file.  Currently, a break introduced #     after a save will be effective, but not persistent. #     This is necessary to keep the saved breaks synched with the #     saved file. # #     Breakpoints are set as tagged ranges in the text. #     Since a modified file has to be saved before it is #     run, and since self.breakpoints (from which the subprocess #     debugger is loaded) is updated during the save, the visible #     breaks stay synched with the subprocess even if one of these #     unexpected breakpoint deletions occurs. breaks = self . breakpoints filename = self . io . filename try : with open ( self . breakpointPath , "r" ) as fp : lines = fp . readlines ( ) except OSError : lines = [ ] try : with open ( self . breakpointPath , "w" ) as new_file : for line in lines : if not line . startswith ( filename + '=' ) : new_file . write ( line ) self . update_breakpoints ( ) breaks = self . breakpoints if breaks : new_file . write ( filename + '=' + str ( breaks ) + '\n' ) except OSError as err : if not getattr ( self . root , "breakpoint_error_displayed" , False ) : self . root . breakpoint_error_displayed = True messagebox . showerror ( title = 'IDLE Error' , message = 'Unable to update breakpoint list:\n%s' % str ( err ) , parent = self . text )