Package pyamf :: Package util :: Module pure :: Class BufferedByteStream
[hide private]
[frames] | no frames]

Class BufferedByteStream

source code


An extension of StringIO.

Features:

Instance Methods [hide private]
 
__init__(self, buf=None, min_buf_size=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
read(self, length=-1)
Reads up to the specified number of bytes from the stream into the specified byte array of specified length.
source code
 
peek(self, size=1)
Looks size bytes ahead in the stream, returning what it finds, returning the stream pointer to its initial position.
source code
number
remaining(self)
Returns number of remaining bytes.
source code
bool
at_eof(self)
Returns True if the internal pointer is at the end of the stream.
source code
 
append(self, data)
Append data to the end of the stream.
source code
 
__add__(self, other) source code

Inherited from StringIOProxy: __len__, consume, getvalue, seek, tell, truncate, write

Inherited from StringIOProxy (private): _get_len

Inherited from DataTypeMixIn: read_24bit_int, read_24bit_uint, read_char, read_double, read_float, read_long, read_short, read_uchar, read_ulong, read_ushort, read_utf8_string, write_24bit_int, write_24bit_uint, write_char, write_double, write_float, write_long, write_short, write_uchar, write_ulong, write_ushort, write_utf8_string

Inherited from DataTypeMixIn (private): _is_big_endian, _read

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

Class Variables [hide private]

Inherited from DataTypeMixIn: ENDIAN_BIG, ENDIAN_LITTLE, ENDIAN_NATIVE, ENDIAN_NETWORK

Instance Variables [hide private]

Inherited from DataTypeMixIn: endian

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, buf=None, min_buf_size=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • buf (str or StringIO instance) - Initial byte stream.
  • min_buf_size - Ignored in the pure python version.
Raises:
  • TypeError - Unable to coerce buf to StringIO.
Overrides: object.__init__

read(self, length=-1)

source code 

Reads up to the specified number of bytes from the stream into the specified byte array of specified length.

Raises:
  • IOError - Attempted to read past the end of the buffer.
Overrides: StringIOProxy.read

peek(self, size=1)

source code 

Looks size bytes ahead in the stream, returning what it finds, returning the stream pointer to its initial position.

Parameters:
  • size (int) - Default is 1.
Returns:
Bytes.
Raises:
  • ValueError - Trying to peek backwards.

remaining(self)

source code 

Returns number of remaining bytes.

Returns: number
Number of remaining bytes.

append(self, data)

source code 

Append data to the end of the stream. The pointer will not move if this operation is successful.

Parameters:
  • data (str or unicode) - The data to append to the stream.
Raises:
  • TypeError - data is not str or unicode