class LazyStream:
The LazyStream wrapper allows one to get and "unget" bytes from a stream.
Given a producer object (an iterator that yields bytestrings), the LazyStream object will support iteration, reading, and keeping a "look-back" variable in case you need to "unget" some bytes.
Method | __init__ |
Every LazyStream must have a producer when instantiated. |
Method | __iter__ |
Undocumented |
Method | __next__ |
Used when the exact number of bytes to read is unimportant. |
Method | _update_unget_history |
No summary |
Method | close |
Used to invalidate/disable this lazy stream. |
Method | read |
Undocumented |
Method | tell |
Undocumented |
Method | unget |
Place bytes back onto the front of the lazy stream. |
Instance Variable | _empty |
Undocumented |
Instance Variable | _leftover |
Undocumented |
Instance Variable | _producer |
Undocumented |
Instance Variable | _remaining |
Undocumented |
Instance Variable | _unget_history |
Undocumented |
Instance Variable | length |
Undocumented |
Instance Variable | position |
Undocumented |
Every LazyStream must have a producer when instantiated.
A producer is an iterable that returns a string each time it is called.
Used when the exact number of bytes to read is unimportant.
Return whatever chunk is conveniently returned from the iterator. Useful to avoid unnecessary bookkeeping if performance is an issue.
Used to invalidate/disable this lazy stream.
Replace the producer with an empty list. Any leftover bytes that have already been read will still be reported upon read() and/or next().