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

Method writefile

Lib/idlelib/iomenu.py:240–252  ·  view source on GitHub ↗
(self, filename)

Source from the content-addressed store, hash-verified

238 return "break"
239
240 def writefile(self, filename):
241 text = self.fixnewlines()
242 chars = self.encode(text)
243 try:
244 with open(filename, "wb") as f:
245 f.write(chars)
246 f.flush()
247 os.fsync(f.fileno())
248 return True
249 except OSError as msg:
250 messagebox.showerror("I/O Error", str(msg),
251 parent=self.text)
252 return False
253
254 def fixnewlines(self):
255 """Return text with os eols.

Callers 4

saveMethod · 0.95
save_asMethod · 0.95
save_a_copyMethod · 0.95
print_windowMethod · 0.95

Calls 9

fixnewlinesMethod · 0.95
encodeMethod · 0.95
strFunction · 0.85
openFunction · 0.50
writeMethod · 0.45
flushMethod · 0.45
fsyncMethod · 0.45
filenoMethod · 0.45
showerrorMethod · 0.45

Tested by

no test coverage detected