BufGen¶
A generator class with a buffer. This allows multiple inspections of the stream issued by a generator. For example this is used by MaxMunchGen.
-
class
cpip.util.BufGen.BufGen(theGen)¶ A generator class with a buffer.
-
__getitem__(key)¶ Implements indexing and slicing. Negative indexes will raise an IndexError.
Parameters: key ( int) – The index.Returns: str– The buffer corresponding to the key.Raises: IndexError, StopIteration
-
__init__(theGen)¶ Constructor with a generator as an argument.
Parameters: theGen ( generator) – The generator to use.Returns: NoneType
-
__weakref__¶ list of weak references to the object (if defined)
-
gen()¶ Yield objects from the generator via the buffer.
-
lenBuf¶ Returns the length of the existing buffer. NOTE: This may not be the final length as the generator might not be exhausted just yet.
-
replace(theIdx, theLen, theValueS)¶ Replaces within the buffer starting at theIdx removing theLen objects and replacing them with theValueS.
-
slice(sliceLen)¶ Returns a buffer slice of length sliceLen.
-
-
exception
cpip.util.BufGen.ExceptionBufGen¶ Exception specialisation for BufGen.