blob: 4ef6370beeacac84e957a59f87b251f39873cebc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import logging
# Handle efficient operations on a non-fixed length buffer like appending,
# replacing, reading chunks, etc
class ChunkBuffer:
def __init__( self, data = '' ):
logging.debug( "Creating chunkbuffer: %s" % data )
self.chunk = list( data )
def append( self, s ):
self.chunk.extend( list( s ) )
def replace( self, s, start, end ):
self.chunk
def length( self ):
return len( self.chunk )
def string(self):
logging.debug( "Stringifying: %s" % self.chunk )
return ''.join( self.chunk )
|