6.13.2. Sink Drivers

Sink drivers support the standard Python file protocol for output of text. They supply the standard python file methods:
write
Write text to output device. Repeatedly raw_write characters upto either the end of the string, or a newline character. If a newline character is found, increment the line count amd call raw_eol. Precondition: no control characters other than newline in the input.
writelines
Accepts a list of strings which are concatenated and passed to the write method. No newline characters are added. Precondition: no control characters other than newline in the input.
close
If the sink is not flagged as closed, flag the sink as closed for access to the device and call raw_close. Note this need not close the underlying device.
flush
May flush data to the device.
isatty
May return 1 if the underlying device is a tty type device.

The methods read, readline and readlines are note provided because a sink need not support read operations. The methods seek and tell are not provided because sinks need not support positioning. The method truncate is not provided because a sink need not be storage device. There is no mode attribute, sinks support writing, but need not be files.

The following methods augment the standard python methods.

writeline
Append a newline character to the argument and pass to write method.
raw_writelines
Accepts a list of strings which are written in turn using writeline. Use with a list of printable strings; that is, without trailing newlines.
The following methods should be provided by subclass derivers, if the default implementation (if it exists) is inappropriate. They are intended as private implementation details, not to be called by the user.
raw_write
Write raw text to the device. Precondition: only printable characters in the input (space is allowed). [All characters are written verbatim to the underlying device without incrementing the line count.]
raw_close
May close the underlying device. Called by the close method if the closed flag is false.
raw_flush
May flush the underlying device device.
raw_eol
Ends a line on the underlying device.
In addition, the following attributes are available:
lines_written
The total number of calls to writeline.
last_source_file
Provided for the client to store the name of the original source of the last line written.
last_source_line
Provided for the client to store the line number of the last line written in the original source file.
last_inhibit_sref
Provided for the client to store whether source referencing was disabled on the last write.
closed
Indicates if close was called.
Start python section to interscript/drivers/sinks/__init__.py[1 /1 ]
     1: #line 96 "sink_drivers.ipk"
     2: #--- sink package ---
     3: class sink_open_error(Exception): pass
     4: 
     5: 
End python section to interscript/drivers/sinks/__init__.py[1]


6.13.2.1. Sink Base Class
6.13.2.2. Null Sink
6.13.2.3. Tee Sink
6.13.2.4. Simple Disk File Sink
6.13.2.5. Complex Disk File Sink
6.13.2.6. Standard Output Sink
6.13.2.7. Persistent Storage Sink