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

Method write_text

Lib/pathlib/__init__.py:799–810  ·  view source on GitHub ↗

Open the file in text mode, write to it, and close the file.

(self, data, encoding=None, errors=None, newline=None)

Source from the content-addressed store, hash-verified

797 return f.write(view)
798
799 def write_text(self, data, encoding=None, errors=None, newline=None):
800 """
801 Open the file in text mode, write to it, and close the file.
802 """
803 # Call io.text_encoding() here to ensure any warning is raised at an
804 # appropriate stack level.
805 encoding = io.text_encoding(encoding)
806 if not isinstance(data, str):
807 raise TypeError('data must be str, not %s' %
808 data.__class__.__name__)
809 with self.open(mode='w', encoding=encoding, errors=errors, newline=newline) as f:
810 return f.write(data)
811
812 _remove_leading_dot = operator.itemgetter(slice(2, None))
813 _remove_trailing_slash = operator.itemgetter(slice(-1))

Callers 15

scriptMethod · 0.95
test_files_listMethod · 0.95
generate_slicesFunction · 0.45
auto_mark_fileFunction · 0.45
auto_mark_directoryFunction · 0.45
patch_fileFunction · 0.45
patch_directoryFunction · 0.45

Calls 3

openMethod · 0.95
isinstanceFunction · 0.85
writeMethod · 0.45