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

Method getfilename

Lib/idlelib/runscript.py:169–194  ·  view source on GitHub ↗

Get source filename. If not saved, offer to save (or create) file The debugger requires a source file. Make sure there is one, and that the current version of the source buffer has been saved. If the user declines to save or cancels the Save As dialog, return None.

(self)

Source from the content-addressed store, hash-verified

167 return 'break'
168
169 def getfilename(self):
170 """Get source filename. If not saved, offer to save (or create) file
171
172 The debugger requires a source file. Make sure there is one, and that
173 the current version of the source buffer has been saved. If the user
174 declines to save or cancels the Save As dialog, return None.
175
176 If the user has configured IDLE for Autosave, the file will be
177 silently saved if it already exists and is dirty.
178
179 """
180 filename = self.editwin.io.filename
181 if not self.editwin.get_saved():
182 autosave = idleConf.GetOption('main', 'General',
183 'autosave', type='bool')
184 if autosave and filename:
185 self.editwin.io.save(None)
186 else:
187 confirm = self.ask_save_dialog()
188 self.editwin.text.focus_set()
189 if confirm:
190 self.editwin.io.save(None)
191 filename = self.editwin.io.filename
192 else:
193 filename = None
194 return filename
195
196 def ask_save_dialog(self):
197 msg = "Source Must Be Saved\n" + 5*' ' + "OK to Save?"

Callers 2

check_module_eventMethod · 0.95
run_module_eventMethod · 0.95

Calls 5

ask_save_dialogMethod · 0.95
GetOptionMethod · 0.80
get_savedMethod · 0.45
saveMethod · 0.45
focus_setMethod · 0.45

Tested by

no test coverage detected