MCPcopy Index your code
hub / github.com/python/cpython / store_file_breaks

Method store_file_breaks

Lib/idlelib/pyshell.py:224–264  ·  view source on GitHub ↗

Save breakpoints when file is saved

(self)

Source from the content-addressed store, hash-verified

222 pass
223
224 def store_file_breaks(self):
225 "Save breakpoints when file is saved"
226 # XXX 13 Dec 2002 KBK Currently the file must be saved before it can
227 # be run. The breaks are saved at that time. If we introduce
228 # a temporary file save feature the save breaks functionality
229 # needs to be re-verified, since the breaks at the time the
230 # temp file is created may differ from the breaks at the last
231 # permanent save of the file. Currently, a break introduced
232 # after a save will be effective, but not persistent.
233 # This is necessary to keep the saved breaks synched with the
234 # saved file.
235 #
236 # Breakpoints are set as tagged ranges in the text.
237 # Since a modified file has to be saved before it is
238 # run, and since self.breakpoints (from which the subprocess
239 # debugger is loaded) is updated during the save, the visible
240 # breaks stay synched with the subprocess even if one of these
241 # unexpected breakpoint deletions occurs.
242 breaks = self.breakpoints
243 filename = self.io.filename
244 try:
245 with open(self.breakpointPath) as fp:
246 lines = fp.readlines()
247 except OSError:
248 lines = []
249 try:
250 with open(self.breakpointPath, "w") as new_file:
251 for line in lines:
252 if not line.startswith(filename + '='):
253 new_file.write(line)
254 self.update_breakpoints()
255 breaks = self.breakpoints
256 if breaks:
257 new_file.write(filename + '=' + str(breaks) + '\n')
258 except OSError as err:
259 if not getattr(self.root, "breakpoint_error_displayed", False):
260 self.root.breakpoint_error_displayed = True
261 messagebox.showerror(title='IDLE Error',
262 message='Unable to update breakpoint list:\n%s'
263 % str(err),
264 parent=self.text)
265
266 def restore_file_breaks(self):
267 self.text.update() # this enables setting "BREAK" tags to be visible

Callers 2

saveMethod · 0.80
save_asMethod · 0.80

Calls 7

update_breakpointsMethod · 0.95
strFunction · 0.85
openFunction · 0.50
readlinesMethod · 0.45
startswithMethod · 0.45
writeMethod · 0.45
showerrorMethod · 0.45

Tested by

no test coverage detected