b.i.IterableFile(object) : class documentation

Part of bzrlib.iterablefile View In Hierarchy

This class supplies all File methods that can be implemented cheaply.
Method __init__ Undocumented
Method close
>>> f = IterableFile(['This ', 'is ', 'a ', 'test.'])
Method flush No-op for standard compliance.
Method next Implementation of the iterator protocol's next()
Method __iter__
>>> list(IterableFile(['Th\nis ', 'is \n', 'a ', 'te\nst.']))
Method read
>>> IterableFile(['This ', 'is ', 'a ', 'test.']).read()
Method read_to Read characters until a sequence is found, with optional max size.
Method readline
>>> f = IterableFile(['Th\nis ', 'is \n', 'a ', 'te\nst.'])
Method readlines
>>> f = IterableFile(['Th\nis ', 'is \n', 'a ', 'te\nst.'])
Method _make_iterator Undocumented
Method _check_closed Undocumented
def __init__(self, iterable):
Undocumented
def _make_iterator(self):
Undocumented
def _check_closed(self):
Undocumented
def close(self):
>>> f = IterableFile(['This ', 'is ', 'a ', 'test.'])
>>> f.closed
False
>>> f.close()
>>> f.closed
True
def flush(self):
No-op for standard compliance. >>> f = IterableFile([]) >>> f.close() >>> f.flush() Traceback (most recent call last): ValueError: File is closed.
def next(self):

Implementation of the iterator protocol's next()

>>> f = IterableFile(['This \n', 'is ', 'a ', 'test.'])
>>> f.next()
'This \n'
>>> f.close()
>>> f.next()
Traceback (most recent call last):
ValueError: File is closed.
>>> f = IterableFile(['This \n', 'is ', 'a ', 'test.\n'])
>>> f.next()
'This \n'
>>> f.next()
'is a test.\n'
>>> f.next()
Traceback (most recent call last):
StopIteration
def __iter__(self):
>>> list(IterableFile(['Th\nis ', 'is \n', 'a ', 'te\nst.']))
['Th\n', 'is is \n', 'a te\n', 'st.']
>>> f = IterableFile(['Th\nis ', 'is \n', 'a ', 'te\nst.'])
>>> f.close()
>>> list(f)
Traceback (most recent call last):
ValueError: File is closed.
def read(self, length=None):
>>> IterableFile(['This ', 'is ', 'a ', 'test.']).read()
'This is a test.'
>>> f = IterableFile(['This ', 'is ', 'a ', 'test.'])
>>> f.read(10)
'This is a '
>>> f = IterableFile(['This ', 'is ', 'a ', 'test.'])
>>> f.close()
>>> f.read(10)
Traceback (most recent call last):
ValueError: File is closed.
def read_to(self, sequence, size=None):

Read characters until a sequence is found, with optional max size. The specified sequence, if found, will be included in the result

>>> f = IterableFile(['Th\nis ', 'is \n', 'a ', 'te\nst.'])
>>> f.read_to('i')
'Th\ni'
>>> f.read_to('i')
's i'
>>> f.close()
>>> f.read_to('i')
Traceback (most recent call last):
ValueError: File is closed.
def readline(self, size=None):
>>> f = IterableFile(['Th\nis ', 'is \n', 'a ', 'te\nst.'])
>>> f.readline()
'Th\n'
>>> f.readline(4)
'is i'
>>> f.close()
>>> f.readline()
Traceback (most recent call last):
ValueError: File is closed.
def readlines(self, sizehint=None):
>>> f = IterableFile(['Th\nis ', 'is \n', 'a ', 'te\nst.'])
>>> f.readlines()
['Th\n', 'is is \n', 'a te\n', 'st.']
>>> f = IterableFile(['Th\nis ', 'is \n', 'a ', 'te\nst.'])
>>> f.close()
>>> f.readlines()
Traceback (most recent call last):
ValueError: File is closed.
API Documentation for Bazaar, generated by pydoctor at 2019-10-20 00:34:54.