Part of bzrlib.iterablefile View In Hierarchy
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 |
>>> f = IterableFile(['This ', 'is ', 'a ', 'test.']) >>> f.closed False >>> f.close() >>> f.closed True
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
>>> 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.
>>> 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.
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.
>>> 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.
>>> 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.