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

Method fixnewlines

Lib/idlelib/iomenu.py:254–268  ·  view source on GitHub ↗

Return text with os eols. Add prompts if shell else final \n if missing.

(self)

Source from the content-addressed store, hash-verified

252 return False
253
254 def fixnewlines(self):
255 """Return text with os eols.
256
257 Add prompts if shell else final \n if missing.
258 """
259
260 if hasattr(self.editwin, "interp"): # Saving shell.
261 text = self.editwin.get_prompt_text('1.0', self.text.index('end-1c'))
262 else:
263 if self.text.get("end-2c") != '\n':
264 self.text.insert("end-1c", "\n") # Changes 'end-1c' value.
265 text = self.text.get('1.0', "end-1c")
266 if self.eol_convention != "\n":
267 text = text.replace("\n", self.eol_convention)
268 return text
269
270 def encode(self, chars):
271 if isinstance(chars, bytes):

Callers 1

writefileMethod · 0.95

Calls 5

get_prompt_textMethod · 0.80
indexMethod · 0.45
getMethod · 0.45
insertMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected