Open the file in text mode, write to it, and close the file.
(self, data, encoding=None, errors=None)
| 1414 | return f.write(data) |
| 1415 | |
| 1416 | def write_text(self, data, encoding=None, errors=None): |
| 1417 | """ |
| 1418 | Open the file in text mode, write to it, and close the file. |
| 1419 | """ |
| 1420 | if not isinstance(data, pycompat.text_type): |
| 1421 | raise TypeError( |
| 1422 | 'data must be %s, not %s' % |
| 1423 | (pycompat.text_type.__name__, data.__class__.__name__)) |
| 1424 | with self.open(mode='w', encoding=encoding, errors=errors) as f: |
| 1425 | return f.write(data) |
| 1426 | |
| 1427 | def touch(self, mode=0o666, exist_ok=True): |
| 1428 | """ |