Package qbuf :: Class BufferQueue

Class BufferQueue

source code

object --+
         |
        BufferQueue

BufferQueue([delimiter])

Initialize a new buffer. If the delimiter is provided, it can be used to pop lines off instead of just bytes.

Iterating over a BufferQueue is the same as repeatedly calling .popline() on it, except that the delimiter is included in the string yielded. An empty BufferQueue evaluates to boolean false.

Instance Methods
 
__init__(delimiter=...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__iter__(x)
iter(x)
source code
 
__len__(x)
len(x)
source code
a new object with type S, a subtype of T
__new__(T, S, ...) source code
 
__repr__(x)
repr(x)
source code
 
__str__(x)
str(x)
source code
None
clear()
Clear the buffer.
source code
the next value, or raise StopIteration
next(x) source code
str
pop(length=...)
Pop some bytes out of the buffer.
source code
str
pop_atmost(length)
Pop at most some number of bytes from the buffer.
source code
tuple
pop_struct(format)
Pop some bytes from the buffer and unpack them using the 'struct' module, returning the resulting tuple.
source code
buffer
pop_view(length=...)
Pop some bytes from the buffer and return it as a python 'buffer' object.
source code
str
popline(delimiter=...)
Pop one line of data from the buffer.
source code
list
poplines(delimiter=...)
Pop as many lines off of the buffer as is possible.
source code
None
push(string)
Push a string into the buffer.
source code
None
push_many(iterable)
Push each string in the provided iterable into the buffer.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Properties
  delimiter
delimiter string

Inherited from object: __class__

Method Details

__init__(delimiter=...)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__

__new__(T, S, ...)

source code 
Returns: a new object with type S, a subtype of T
Overrides: object.__new__

__repr__(x)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__

__str__(x)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__

pop(length=...)

source code 

Pop some bytes out of the buffer. If no argument is provided, pop the entire buffer out. Raises a BufferUnderflow exception if the buffer would underflow.

Returns: str

pop_atmost(length)

source code 

Pop at most some number of bytes from the buffer. The returned string will have a length anywhere between 0 and the length provided.

Returns: str

pop_struct(format)

source code 

Pop some bytes from the buffer and unpack them using the 'struct' module, returning the resulting tuple. The format string passed is the same as the 'struct' module format.

Returns: tuple

pop_view(length=...)

source code 

Pop some bytes from the buffer and return it as a python 'buffer' object. If possible, no new strings will be constructed and the buffer returned will just be a view of one of the strings pushed into the buffer.

Returns: buffer

popline(delimiter=...)

source code 

Pop one line of data from the buffer. This scans the buffer for the next occurrence of the provided delimiter, or the buffer's delimiter if none was provided, and then returns everything up to and including the delimiter. If the delimiter was not found or there was no delimiter set, a ValueError is raised. The delimiter is not included in the string returned.

Returns: str

poplines(delimiter=...)

source code 

Pop as many lines off of the buffer as is possible. This will collect and return a list of all of the lines that were in the buffer. If there was no delimiter set and no delimiter was provided, a ValueError is raised. The delimiter is not included in the strings returned.

Returns: list