stream_reader¶
Module provides class TelnetReader and TelnetReaderUnicode.
-
class
TelnetReader
(*args, **kwargs)[source]¶ A reader interface for the telnet protocol.
-
readline
()[source]¶ Read one line.
Where “line” is a sequence of characters ending with CR LF, LF, or CR NUL. This readline function is a strict interpretation of Telnet Protocol RFC 854.
The sequence “CR LF” must be treated as a single “new line” character and used whenever their combined action is intended; The sequence “CR NUL” must be used where a carriage return alone is actually desired; and the CR character must be avoided in other contexts.
And therefor, a line does not yield for a stream containing a CR if it is not succeeded by NUL or LF.
Given stream
readline() yields
--\r\x00---
--\r
,---
…--\r\n---
--\r\n
,---
…--\n---
--\n
,---
…--\r---
--\r
,---
…If EOF is received before the termination of a line, the method will yield the partially read string.
This method is a
coroutine()
.
-
-
class
TelnetReaderUnicode
(fn_encoding, *, limit=65536, loop=None, encoding_errors='replace')[source]¶ A Unicode StreamReader interface for Telnet protocol.
- Parameters
fn_encoding¶ (Callable) – function callback, receiving boolean keyword argument,
incoming=True
, which is used by the callback to determine what encoding should be used to decode the value in the direction specified.
-
readline
()[source]¶ Read one line.
See ancestor method,
readline()
for details.This method is a
coroutine()
.
-
read
(n=- 1)[source]¶ Read up to n bytes.
If the EOF was received and the internal buffer is empty, return an empty string.
- Parameters
n¶ (int) – If n is not provided, or set to -1, read until EOF and return all characters as one large string.
- Return type
This method is a
coroutine()
.
-
readexactly
(n)[source]¶ Read exactly n unicode characters.
- Raises
asyncio.IncompleteReadError – if the end of the stream is reached before n can be read. the
asyncio.IncompleteReadError.partial
attribute of the exception contains the partial read characters.- Return type
This method is a
coroutine()
.