#NEWLINE# def _GetChunkForWriting( self , chunk ) : #NEWLINE# #INDENT# "Opens a chunk for writing, creating a new one if it doesn't exist yet." #NEWLINE# try : #NEWLINE# #INDENT# chunk = self . chunk_cache . Get ( fd ) #NEWLINE# chunk . dirty = True #NEWLINE# return chunk #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# chunk = self . _ReadChunk ( chunk ) #NEWLINE# chunk . dirty = True #NEWLINE# return chunk #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# fd = StringIO . StringIO ( ) #NEWLINE# fd . chunk = chunk #NEWLINE# fd . dirty = True #NEWLINE# self . chunk_cache . Put ( chunk , fd ) #NEWLINE# return fd