MCPcopy Index your code
hub / github.com/RustPython/RustPython / write_history_file

Method write_history_file

Lib/_pyrepl/readline.py:450–458  ·  view source on GitHub ↗
(self, filename: str = gethistoryfile())

Source from the content-addressed store, hash-verified

448 history.append(line)
449
450 def write_history_file(self, filename: str = gethistoryfile()) -> None:
451 maxlength = self.saved_history_length
452 history = self.get_reader().get_trimmed_history(maxlength)
453 f = open(os.path.expanduser(filename), "w",
454 encoding="utf-8", newline="\n")
455 with f:
456 for entry in history:
457 entry = entry.replace("\n", "\r\n") # multiline history support
458 f.write(entry + "\n")
459
460 def clear_history(self) -> None:
461 del self.get_reader().history[:]

Callers 1

write_historyFunction · 0.80

Calls 7

get_readerMethod · 0.95
gethistoryfileFunction · 0.90
get_trimmed_historyMethod · 0.80
expanduserMethod · 0.80
openFunction · 0.50
replaceMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected