b.i.IterableFileBase(object) : class documentation

Part of bzrlib.iterablefile View In Hierarchy

Create a file-like object from any iterable
Method __init__ Undocumented
Method read_n
>>> IterableFileBase(['This ', 'is ', 'a ', 'test.']).read_n(8)
Method read_to
>>> f = IterableFileBase(['Th\nis ', 'is \n', 'a ', 'te\nst.'])
Method read_all
>>> IterableFileBase(['This ', 'is ', 'a ', 'test.']).read_all()
Method push_back
>>> f = IterableFileBase(['Th\nis ', 'is \n', 'a ', 'te\nst.'])
Method _read Read data until result satisfies the condition result_length.
def __init__(self, iterable):
Undocumented
def read_n(self, length):
>>> IterableFileBase(['This ', 'is ', 'a ', 'test.']).read_n(8)
'This is '
def read_to(self, sequence, length=None):
>>> f = IterableFileBase(['Th\nis ', 'is \n', 'a ', 'te\nst.'])
>>> f.read_to('\n')
'Th\n'
>>> f.read_to('\n')
'is is \n'
def _read(self, result_length):
Read data until result satisfies the condition result_length. result_length is a callable that returns None until the condition is satisfied, and returns the length of the result to use when the condition is satisfied. (i.e. it returns the length of the subset of the first condition match.)
def read_all(self):
>>> IterableFileBase(['This ', 'is ', 'a ', 'test.']).read_all()
'This is a test.'
def push_back(self, contents):
>>> f = IterableFileBase(['Th\nis ', 'is \n', 'a ', 'te\nst.'])
>>> f.read_to('\n')
'Th\n'
>>> f.push_back("Sh")
>>> f.read_all()
'Shis is \na te\nst.'
API Documentation for Bazaar, generated by pydoctor at 2022-06-16 00:25:16.