Output for single, simple file-like objects.
| docutils.io.FileOutput.__init__ |
( |
|
self, |
|
|
|
destination = None, |
|
|
|
destination_path = None, |
|
|
|
encoding = None, |
|
|
|
error_handler = 'strict', |
|
|
|
autoclose = True, |
|
|
|
handle_io_errors = None, |
|
|
|
mode = None |
|
) |
| |
:Parameters:
- `destination`: either a file-like object (which is written
directly) or `None` (which implies `sys.stdout` if no
`destination_path` given).
- `destination_path`: a path to a file, which is opened and then
written.
- `encoding`: the text encoding of the output file.
- `error_handler`: the encoding error handler to use.
- `autoclose`: close automatically after write (except when
`sys.stdout` or `sys.stderr` is the destination).
- `handle_io_errors`: ignored, deprecated, will be removed.
- `mode`: how the file is to be opened (see standard function
`open`). The default is 'w', providing universal newline
support for text files.
Reimplemented from docutils.io.Output.
Reimplemented in sphinx.util.docutils.SphinxFileOutput.
| docutils.io.FileOutput.write |
( |
|
self, |
|
|
|
data |
|
) |
| |
Write `data` to a single file, also return it.
`data` can be a `str` or `bytes` instance.
If writing `bytes` fails, an attempt is made to write to
the low-level interface ``self.destination.buffer``.
If `data` is a `str` instance and `self.encoding` and
`self.destination.encoding` are set to different values, `data`
is encoded to a `bytes` instance using `self.encoding`.
Provisional: future versions may raise an error if `self.encoding`
and `self.destination.encoding` are set to different values.
Reimplemented from docutils.io.Output.
Reimplemented in sphinx.util.docutils.SphinxFileOutput.