<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> import document <EOL> import logging <EOL> import model <EOL> import util <EOL> WAVELET_APPEND_BLIP = '<STR_LIT>' <EOL> WAVELET_ADD_PARTICIPANT = '<STR_LIT>' <EOL> WAVELET_CREATE = '<STR_LIT>' <EOL> WAVELET_REMOVE_SELF = '<STR_LIT>' <EOL> WAVELET_DATADOC_SET = '<STR_LIT>' <EOL> WAVELET_SET_TITLE = '<STR_LIT>' <EOL> BLIP_CREATE_CHILD = '<STR_LIT>' <EOL> BLIP_DELETE = '<STR_LIT>' <EOL> DOCUMENT_ANNOTATION_DELETE = '<STR_LIT>' <EOL> DOCUMENT_ANNOTATION_SET = '<STR_LIT>' <EOL> DOCUMENT_ANNOTATION_SET_NORANGE = '<STR_LIT>' <EOL> DOCUMENT_APPEND = '<STR_LIT>' <EOL> DOCUMENT_APPEND_MARKUP = '<STR_LIT>' <EOL> DOCUMENT_APPEND_STYLED_TEXT = '<STR_LIT>' <EOL> DOCUMENT_INSERT = '<STR_LIT>' <EOL> DOCUMENT_DELETE = '<STR_LIT>' <EOL> DOCUMENT_REPLACE = '<STR_LIT>' <EOL> DOCUMENT_ELEMENT_APPEND = '<STR_LIT>' <EOL> DOCUMENT_ELEMENT_DELETE = '<STR_LIT>' <EOL> DOCUMENT_ELEMENT_MODIFY_ATTRS = '<STR_LIT>' <EOL> DOCUMENT_ELEMENT_INSERT = '<STR_LIT>' <EOL> DOCUMENT_ELEMENT_INSERT_AFTER = '<STR_LIT>' <EOL> DOCUMENT_ELEMENT_INSERT_BEFORE = '<STR_LIT>' <EOL> DOCUMENT_ELEMENT_REPLACE = '<STR_LIT>' <EOL> DOCUMENT_INLINE_BLIP_APPEND = '<STR_LIT>' <EOL> DOCUMENT_INLINE_BLIP_DELETE = '<STR_LIT>' <EOL> DOCUMENT_INLINE_BLIP_INSERT = '<STR_LIT>' <EOL> DOCUMENT_INLINE_BLIP_INSERT_AFTER_ELEMENT = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> class Operation ( object ) : <EOL> """<STR_LIT>""" <EOL> java_class = '<STR_LIT>' <EOL> def __init__ ( self , op_type , wave_id , wavelet_id , blip_id = '<STR_LIT>' , index = - <NUM_LIT:1> , <EOL> prop = None ) : <EOL> """<STR_LIT>""" <EOL> self . type = op_type <EOL> self . wave_id = wave_id <EOL> self . wavelet_id = wavelet_id <EOL> self . blip_id = blip_id <EOL> self . index = index <EOL> self . property = prop <EOL> class OpBasedWave ( model . Wave ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , json , context ) : <EOL> """<STR_LIT>""" <EOL> super ( OpBasedWave , self ) . __init__ ( json ) <EOL> self . __context = context <EOL> def CreateWavelet ( self , participants = None ) : <EOL> """<STR_LIT>""" <EOL> return self . __context . builder . WaveletCreate ( <EOL> self . GetId ( ) , '<STR_LIT>' , participants ) <EOL> class OpBasedWavelet ( model . Wavelet ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , json , context ) : <EOL> """<STR_LIT>""" <EOL> super ( OpBasedWavelet , self ) . __init__ ( json ) <EOL> self . __context = context <EOL> def CreateBlip ( self ) : <EOL> """<STR_LIT>""" <EOL> blip_data = self . __context . builder . WaveletAppendBlip ( self . GetWaveId ( ) , <EOL> self . GetId ( ) ) <EOL> return self . __context . AddBlip ( blip_data ) <EOL> def AddParticipant ( self , participant_id ) : <EOL> """<STR_LIT>""" <EOL> self . __context . builder . WaveletAddParticipant ( self . GetWaveId ( ) , self . GetId ( ) , <EOL> participant_id ) <EOL> self . participants . add ( participant_id ) <EOL> def RemoveSelf ( self ) : <EOL> """<STR_LIT>""" <EOL> self . __context . builder . WaveletRemoveSelf ( self . GetWaveId ( ) , self . GetId ( ) ) <EOL> def SetDataDocument ( self , name , data ) : <EOL> """<STR_LIT>""" <EOL> self . __context . builder . WaveletSetDataDoc ( self . GetWaveId ( ) , self . GetId ( ) , <EOL> name , data ) <EOL> self . dataDocuments [ name ] = data <EOL> def SetTitle ( self , title ) : <EOL> """<STR_LIT>""" <EOL> self . __context . builder . WaveletSetTitle ( self . GetWaveId ( ) , self . GetId ( ) , <EOL> title ) <EOL> self . title = title <EOL> class OpBasedBlip ( model . Blip ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , json , context ) : <EOL> """<STR_LIT>""" <EOL> super ( OpBasedBlip , self ) . __init__ ( json ) <EOL> self . __context = context <EOL> self . document = OpBasedDocument ( self , context ) <EOL> def CreateChild ( self ) : <EOL> """<STR_LIT>""" <EOL> blip_data = self . __context . builder . BlipCreateChild ( self . GetWaveId ( ) , <EOL> self . GetWaveletId ( ) , <EOL> self . GetId ( ) ) <EOL> return self . __context . AddBlip ( blip_data ) <EOL> def Delete ( self ) : <EOL> """<STR_LIT>""" <EOL> self . __context . builder . BlipDelete ( self . GetWaveId ( ) , <EOL> self . GetWaveletId ( ) , <EOL> self . GetId ( ) ) <EOL> return self . __context . RemoveBlip ( self . GetId ( ) ) <EOL> class OpBasedDocument ( model . Document ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , blip , context ) : <EOL> """<STR_LIT>""" <EOL> super ( OpBasedDocument , self ) . __init__ ( blip ) <EOL> self . __context = context <EOL> def HasAnnotation ( self , name ) : <EOL> """<STR_LIT>""" <EOL> for annotation in self . _blip . annotations : <EOL> if annotation . name == name : <EOL> return True <EOL> return False <EOL> def RangesForAnnotation ( self , name ) : <EOL> """<STR_LIT>""" <EOL> for annotation in self . _blip . annotations : <EOL> if annotation . name == name : <EOL> yield annotation . range <EOL> def SetText ( self , text ) : <EOL> """<STR_LIT>""" <EOL> self . Clear ( ) <EOL> self . __context . builder . DocumentInsert ( self . _blip . waveId , <EOL> self . _blip . waveletId , <EOL> self . _blip . blipId , <EOL> text ) <EOL> self . _blip . content = text <EOL> def SetTextInRange ( self , r , text ) : <EOL> """<STR_LIT>""" <EOL> self . DeleteRange ( r ) <EOL> self . InsertText ( r . start , text ) <EOL> def InsertText ( self , start , text ) : <EOL> """<STR_LIT>""" <EOL> self . __context . builder . DocumentInsert ( self . _blip . waveId , <EOL> self . _blip . waveletId , <EOL> self . _blip . blipId , <EOL> text , index = start ) <EOL> left = self . _blip . content [ : start ] <EOL> right = self . _blip . content [ start : ] <EOL> self . _blip . content = left + text + right <EOL> def AppendText ( self , text ) : <EOL> """<STR_LIT>""" <EOL> self . __context . builder . DocumentAppend ( self . _blip . waveId , <EOL> self . _blip . waveletId , <EOL> self . _blip . blipId , <EOL> text ) <EOL> self . _blip . content += text <EOL> def Clear ( self ) : <EOL> """<STR_LIT>""" <EOL> self . __context . builder . DocumentDelete ( self . _blip . waveId , <EOL> self . _blip . waveletId , <EOL> self . _blip . blipId ) <EOL> self . _blip . content = '<STR_LIT>' <EOL> def DeleteRange ( self , r ) : <EOL> """<STR_LIT>""" <EOL> self . __context . builder . DocumentDelete ( self . _blip . waveId , <EOL> self . _blip . waveletId , <EOL> self . _blip . blipId , <EOL> r . start , r . end ) <EOL> left = self . _blip . content [ : r . start ] <EOL> right = self . _blip . content [ r . end + <NUM_LIT:1> : ] <EOL> self . _blip . content = left + right <EOL> def AnnotateDocument ( self , name , value ) : <EOL> """<STR_LIT>""" <EOL> b = self . __context . builder <EOL> b . DocumentAnnotationSetNoRange ( self . _blip . waveId , <EOL> self . _blip . waveletId , <EOL> self . _blip . blipId , <EOL> name , value ) <EOL> r = document . Range ( <NUM_LIT:0> , len ( self . _blip . content ) ) <EOL> self . _blip . annotations . append ( document . Annotation ( name , value , r ) ) <EOL> def SetAnnotation ( self , r , name , value ) : <EOL> """<STR_LIT>""" <EOL> self . __context . builder . DocumentAnnotationSet ( self . _blip . waveId , <EOL> self . _blip . waveletId , <EOL> self . _blip . blipId , <EOL> r . start , r . end , <EOL> name , value ) <EOL> self . _blip . annotations . append ( document . Annotation ( name , value , r ) ) <EOL> def DeleteAnnotationsByName ( self , name ) : <EOL> """<STR_LIT>""" <EOL> size = len ( self . _blip . content ) <EOL> self . __context . builder . DocumentAnnotationDelete ( self . _blip . waveId , <EOL> self . _blip . waveletId , <EOL> self . _blip . blipId , <EOL> <NUM_LIT:0> , size , name ) <EOL> self . _blip . annotations = [ a <EOL> for a in self . _blip . annotations if a . name != name ] <EOL> def DeleteAnnotationsInRange ( self , r , name ) : <EOL> """<STR_LIT>""" <EOL> self . __context . builder . DocumentAnnotationDelete ( self . _blip . waveId , <EOL> self . _blip . waveletId , <EOL> self . _blip . blipId , <EOL> r . start , r . end , <EOL> name ) <EOL> res = [ ] <EOL> for a in self . _blip . annotations : <EOL> if a . name != name or r . start > a . range . end or r . end < a . range . start : <EOL> res . append ( a ) <EOL> elif r . start < a . range . start and r . end > a . range . end : <EOL> continue <EOL> else : <EOL> if a . range . start < r . start : <EOL> res . append ( document . Annotation ( <EOL> name , a . value , document . Range ( a . range . start , r . start ) ) ) <EOL> if a . range . end > r . end : <EOL> a . range . start = r . end <EOL> res . append ( a ) <EOL> self . _blip . annotations = res <EOL> def AppendInlineBlip ( self ) : <EOL> """<STR_LIT>""" <EOL> blip_data = self . __context . builder . DocumentInlineBlipAppend ( <EOL> self . _blip . waveId , self . _blip . waveletId , <EOL> self . _blip . blipId ) <EOL> return self . __context . AddBlip ( blip_data ) <EOL> def DeleteInlineBlip ( self , inline_blipId ) : <EOL> """<STR_LIT>""" <EOL> self . __context . builder . DocumentInlineBlipDelete ( self . _blip . waveId , <EOL> self . _blip . waveletId , <EOL> self . _blip . blipId , <EOL> inline_blipId ) <EOL> self . __context . RemoveBlip ( inline_blipId ) <EOL> def InsertInlineBlip ( self , position ) : <EOL> """<STR_LIT>""" <EOL> blip_data = self . __context . builder . DocumentInlineBlipInsert ( <EOL> self . _blip . waveId , <EOL> self . _blip . waveletId , <EOL> self . _blip . blipId , <EOL> position ) <EOL> return self . __context . AddBlip ( blip_data ) <EOL> def DeleteElement ( self , position ) : <EOL> """<STR_LIT>""" <EOL> self . __context . builder . DocumentElementDelete ( self . _blip . waveId , <EOL> self . _blip . waveletId , <EOL> self . _blip . blipId , <EOL> position ) <EOL> def InsertElement ( self , position , element ) : <EOL> """<STR_LIT>""" <EOL> self . __context . builder . DocumentElementInsert ( self . _blip . waveId , <EOL> self . _blip . waveletId , <EOL> self . _blip . blipId , <EOL> position , element ) <EOL> def ReplaceElement ( self , position , element ) : <EOL> """<STR_LIT>""" <EOL> self . __context . builder . DocumentElementReplace ( self . _blip . waveId , <EOL> self . _blip . waveletId , <EOL> self . _blip . blipId , <EOL> position , element ) <EOL> def AppendElement ( self , element ) : <EOL> self . __context . builder . DocumentElementAppend ( self . _blip . waveId , <EOL> self . _blip . waveletId , <EOL> self . _blip . blipId , <EOL> element ) <EOL> def GadgetSubmitDelta ( self , gadget , delta ) : <EOL> """<STR_LIT>""" <EOL> dummy = document . Gadget ( url = gadget . url , props = delta ) <EOL> self . __context . builder . DocumentModifyAttributes ( self . _blip . waveId , <EOL> self . _blip . waveletId , <EOL> self . _blip . blipId , <EOL> dummy ) <EOL> gadget . SubmitDelta ( delta ) <EOL> class _ContextImpl ( model . Context ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> super ( _ContextImpl , self ) . __init__ ( ) <EOL> self . builder = OpBuilder ( self ) <EOL> def AddOperation ( self , op ) : <EOL> """<STR_LIT>""" <EOL> self . _operations . append ( op ) <EOL> def AddWave ( self , wave_data ) : <EOL> """<STR_LIT>""" <EOL> wave = OpBasedWave ( wave_data , self ) <EOL> self . waves [ wave . GetId ( ) ] = wave <EOL> return wave <EOL> def AddWavelet ( self , wavelet_data ) : <EOL> """<STR_LIT>""" <EOL> wavelet = OpBasedWavelet ( wavelet_data , self ) <EOL> self . wavelets [ wavelet . GetId ( ) ] = wavelet <EOL> return wavelet <EOL> def AddBlip ( self , blip_data ) : <EOL> """<STR_LIT>""" <EOL> blip = OpBasedBlip ( blip_data , self ) <EOL> self . blips [ blip . GetId ( ) ] = blip <EOL> return blip <EOL> def RemoveWave ( self , wave_id ) : <EOL> """<STR_LIT>""" <EOL> if wave_id in self . waves : <EOL> del self . waves [ wave_id ] <EOL> def RemoveWavelet ( self , wavelet_id ) : <EOL> """<STR_LIT>""" <EOL> if wavelet_id in self . wavelets : <EOL> del self . wavelets [ wavelet_id ] <EOL> def RemoveBlip ( self , blip_id ) : <EOL> """<STR_LIT>""" <EOL> if blip_id in self . blips : <EOL> del self . blips [ blip_id ] <EOL> def Serialize ( self ) : <EOL> """<STR_LIT>""" <EOL> data = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : util . Serialize ( self . _operations ) <EOL> } <EOL> return data <EOL> def CreateContext ( data ) : <EOL> """<STR_LIT>""" <EOL> context = _ContextImpl ( ) <EOL> for raw_blip_data in data [ '<STR_LIT>' ] . values ( ) : <EOL> context . AddBlip ( raw_blip_data ) <EOL> context . AddWavelet ( data [ '<STR_LIT>' ] ) <EOL> wave_wavelet_map = { } <EOL> wavelets = context . GetWavelets ( ) <EOL> for wavelet in wavelets : <EOL> wave_id = wavelet . GetWaveId ( ) <EOL> wavelet_id = wavelet . GetId ( ) <EOL> if wave_id not in wave_wavelet_map : <EOL> wave_wavelet_map [ wave_id ] = [ ] <EOL> wave_wavelet_map [ wave_id ] . append ( wavelet_id ) <EOL> for wave_id , wavelet_ids in wave_wavelet_map . iteritems ( ) : <EOL> wave_data = { <EOL> '<STR_LIT>' : wave_id , <EOL> '<STR_LIT>' : wavelet_ids , <EOL> } <EOL> context . AddWave ( wave_data ) <EOL> return context <EOL> class BlipData ( dict ) : <EOL> """<STR_LIT>""" <EOL> java_class = '<STR_LIT>' <EOL> def __init__ ( self , wave_id , wavelet_id , blip_id ) : <EOL> super ( BlipData , self ) . __init__ ( ) <EOL> self . waveId = wave_id <EOL> self . waveletId = wavelet_id <EOL> self . blipId = blip_id <EOL> self [ '<STR_LIT>' ] = wave_id <EOL> self [ '<STR_LIT>' ] = wavelet_id <EOL> self [ '<STR_LIT>' ] = blip_id <EOL> class WaveletData ( dict ) : <EOL> """<STR_LIT>""" <EOL> java_class = '<STR_LIT>' <EOL> def __init__ ( self , wave_id , wavelet_id , participants ) : <EOL> super ( WaveletData , self ) . __init__ ( ) <EOL> self . waveId = wave_id <EOL> self . waveletId = wavelet_id <EOL> self . participants = participants <EOL> self [ '<STR_LIT>' ] = wave_id <EOL> self [ '<STR_LIT>' ] = wavelet_id <EOL> self [ '<STR_LIT>' ] = participants <EOL> def SetRootBlipId ( self , blip_id ) : <EOL> self [ '<STR_LIT>' ] = blip_id <EOL> self . rootBlipId = blip_id <EOL> class OpBuilder ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , context ) : <EOL> """<STR_LIT>""" <EOL> self . __context = context <EOL> self . __nextBlipId = <NUM_LIT:1> <EOL> self . __nextWaveId = <NUM_LIT:1> <EOL> def __CreateNewBlipData ( self , wave_id , wavelet_id ) : <EOL> """<STR_LIT>""" <EOL> temp_blip_id = '<STR_LIT>' + wavelet_id + '<STR_LIT:_>' + str ( self . __nextBlipId ) <EOL> self . __nextBlipId += <NUM_LIT:1> <EOL> return BlipData ( wave_id , wavelet_id , temp_blip_id ) <EOL> def __CreateNewWaveletData ( self , participants ) : <EOL> """<STR_LIT>""" <EOL> wave_id = '<STR_LIT>' + str ( self . __nextWaveId ) <EOL> self . __nextWaveId += <NUM_LIT:1> <EOL> wavelet_id = "<STR_LIT>" <EOL> participants = set ( participants ) <EOL> return WaveletData ( wave_id , wavelet_id , participants ) <EOL> def AddNewOperation ( self , op_type , wave_id , wavelet_id , blip_id = '<STR_LIT>' , index = - <NUM_LIT:1> , <EOL> prop = None ) : <EOL> """<STR_LIT>""" <EOL> self . __context . AddOperation ( <EOL> Operation ( op_type , wave_id , wavelet_id , <EOL> blip_id = blip_id , <EOL> index = index , <EOL> prop = prop ) ) <EOL> def WaveletAppendBlip ( self , wave_id , wavelet_id ) : <EOL> """<STR_LIT>""" <EOL> blip_data = self . __CreateNewBlipData ( wave_id , wavelet_id ) <EOL> self . AddNewOperation ( WAVELET_APPEND_BLIP , wave_id , wavelet_id , <EOL> prop = blip_data ) <EOL> return blip_data <EOL> def WaveletAddParticipant ( self , wave_id , wavelet_id , participant_id ) : <EOL> """<STR_LIT>""" <EOL> self . AddNewOperation ( WAVELET_ADD_PARTICIPANT , wave_id , wavelet_id , <EOL> prop = participant_id ) <EOL> def WaveletCreate ( self , wave_id , wavelet_id , participants = None ) : <EOL> """<STR_LIT>""" <EOL> if participants is None : <EOL> participants = [ ] <EOL> wavelet_data = self . __CreateNewWaveletData ( participants ) <EOL> blip_data = self . __CreateNewBlipData ( <EOL> wavelet_data . waveId , wavelet_data . waveletId ) <EOL> self . __context . AddBlip ( blip_data ) <EOL> wavelet_data . SetRootBlipId ( blip_data . blipId ) <EOL> logging . info ( '<STR_LIT>' + blip_data . blipId ) <EOL> wavelet = self . __context . AddWavelet ( wavelet_data ) <EOL> op = Operation ( WAVELET_CREATE , wave_id , wavelet_id , prop = wavelet_data ) <EOL> self . __context . AddOperation ( op ) <EOL> return wavelet <EOL> def WaveletRemoveSelf ( self , wave_id , wavelet_id ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def WaveletSetDataDoc ( self , wave_id , wavelet_id , name , data ) : <EOL> """<STR_LIT>""" <EOL> self . AddNewOperation ( WAVELET_DATADOC_SET , wave_id , wavelet_id , <EOL> blip_id = name , prop = data ) <EOL> def WaveletSetTitle ( self , wave_id , wavelet_id , title ) : <EOL> """<STR_LIT>""" <EOL> self . AddNewOperation ( WAVELET_SET_TITLE , wave_id , wavelet_id , <EOL> prop = title ) <EOL> def BlipCreateChild ( self , wave_id , wavelet_id , blip_id ) : <EOL> """<STR_LIT>""" <EOL> blip_data = self . __CreateNewBlipData ( wave_id , wavelet_id ) <EOL> self . AddNewOperation ( BLIP_CREATE_CHILD , wave_id , wavelet_id , <EOL> blip_id = blip_id , <EOL> prop = blip_data ) <EOL> return blip_data <EOL> def BlipDelete ( self , wave_id , wavelet_id , blip_id ) : <EOL> """<STR_LIT>""" <EOL> self . AddNewOperation ( BLIP_DELETE , wave_id , wavelet_id , blip_id = blip_id ) <EOL> def DocumentAnnotationDelete ( self , wave_id , wavelet_id , blip_id , start , end , <EOL> name ) : <EOL> """<STR_LIT>""" <EOL> self . AddNewOperation ( DOCUMENT_ANNOTATION_DELETE , wave_id , wavelet_id , <EOL> blip_id = blip_id , prop = document . Range ( start , end ) ) <EOL> def DocumentAnnotationSet ( self , wave_id , wavelet_id , blip_id , start , end , <EOL> name , value ) : <EOL> """<STR_LIT>""" <EOL> annotation = document . Annotation ( name , value , document . Range ( start , end ) ) <EOL> self . AddNewOperation ( DOCUMENT_ANNOTATION_SET , wave_id , wavelet_id , <EOL> blip_id = blip_id , <EOL> prop = annotation ) <EOL> def DocumentAnnotationSetNoRange ( self , wave_id , wavelet_id , blip_id , <EOL> name , value ) : <EOL> """<STR_LIT>""" <EOL> annotation = document . Annotation ( name , value , None ) <EOL> self . AddNewOperation ( DOCUMENT_ANNOTATION_SET_NORANGE , wave_id , wavelet_id , <EOL> blip_id = blip_id , <EOL> prop = annotation ) <EOL> def DocumentAppend ( self , wave_id , wavelet_id , blip_id , content ) : <EOL> """<STR_LIT>""" <EOL> self . AddNewOperation ( DOCUMENT_APPEND , wave_id , wavelet_id , <EOL> blip_id = blip_id , <EOL> prop = content ) <EOL> def DocumentAppendMarkup ( self , wave_id , wavelet_id , blip_id , content ) : <EOL> """<STR_LIT>""" <EOL> op = Operation ( DOCUMENT_APPEND_MARKUP , wave_id , wavelet_id , <EOL> blip_id = blip_id , <EOL> prop = content ) <EOL> self . __context . AddOperation ( op ) <EOL> def DocumentAppendStyledText ( self , wave_id , wavelet_id , blip_id , text , style ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def DocumentDelete ( self , wave_id , wavelet_id , blip_id , start = None , end = None ) : <EOL> """<STR_LIT>""" <EOL> if start is None or end is None : <EOL> range = None <EOL> else : <EOL> range = document . Range ( start , end ) <EOL> self . AddNewOperation ( DOCUMENT_DELETE , wave_id , wavelet_id , blip_id , <EOL> prop = range ) <EOL> def DocumentInsert ( self , wave_id , wavelet_id , blip_id , content , index = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> self . AddNewOperation ( DOCUMENT_INSERT , wave_id , wavelet_id , blip_id , <EOL> index = index , prop = content ) <EOL> def DocumentReplace ( self , wave_id , wavelet_id , blip_id , content ) : <EOL> """<STR_LIT>""" <EOL> self . AddNewOperation ( DOCUMENT_REPLACE , wave_id , wavelet_id , blip_id , <EOL> prop = content ) <EOL> def DocumentElementAppend ( self , wave_id , wavelet_id , blip_id , element ) : <EOL> """<STR_LIT>""" <EOL> self . AddNewOperation ( DOCUMENT_ELEMENT_APPEND , wave_id , wavelet_id , blip_id , <EOL> prop = element ) <EOL> def DocumentElementDelete ( self , wave_id , wavelet_id , blip_id , position ) : <EOL> """<STR_LIT>""" <EOL> self . AddNewOperation ( DOCUMENT_ELEMENT_DELETE , wave_id , wavelet_id , blip_id , <EOL> index = position ) <EOL> def DocumentElementInsert ( self , wave_id , wavelet_id , blip_id , position , <EOL> element ) : <EOL> """<STR_LIT>""" <EOL> self . AddNewOperation ( DOCUMENT_ELEMENT_INSERT , wave_id , wavelet_id , blip_id , <EOL> index = position , <EOL> prop = element ) <EOL> def DocumentElementInsertAfter ( self ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def DocumentElementInsertBefore ( self ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def DocumentElementReplace ( self , wave_id , wavelet_id , blip_id , position , <EOL> element ) : <EOL> """<STR_LIT>""" <EOL> self . AddNewOperation ( DOCUMENT_ELEMENT_REPLACE , wave_id , wavelet_id , blip_id , <EOL> index = position , <EOL> prop = element ) <EOL> def DocumentModifyAttributes ( self , wave_id , wavelet_id , blip_id , <EOL> element ) : <EOL> """<STR_LIT>""" <EOL> self . AddNewOperation ( DOCUMENT_ELEMENT_MODIFY_ATTRS , wave_id , wavelet_id , blip_id , <EOL> index = - <NUM_LIT:1> , <EOL> prop = element ) <EOL> def DocumentInlineBlipAppend ( self , wave_id , wavelet_id , blip_id ) : <EOL> """<STR_LIT>""" <EOL> inline_blip_data = self . __CreateNewBlipData ( wave_id , wavelet_id ) <EOL> self . AddNewOperation ( DOCUMENT_INLINE_BLIP_APPEND , wave_id , wavelet_id , <EOL> blip_id = blip_id , <EOL> prop = inline_blip_data ) <EOL> inline_blip_data [ '<STR_LIT>' ] = blip_id <EOL> return inline_blip_data <EOL> def DocumentInlineBlipDelete ( self , wave_id , wavelet_id , blip_id , <EOL> inline_blip_id ) : <EOL> """<STR_LIT>""" <EOL> self . AddNewOperation ( DOCUMENT_INLINE_BLIP_DELETE , wave_id , wavelet_id , <EOL> blip_id = blip_id , <EOL> prop = inline_blip_id ) <EOL> def DocumentInlineBlipInsert ( self , wave_id , wavelet_id , blip_id , position ) : <EOL> """<STR_LIT>""" <EOL> inline_blip_data = self . __CreateNewBlipData ( wave_id , wavelet_id ) <EOL> inline_blip_data [ '<STR_LIT>' ] = blip_id <EOL> self . AddNewOperation ( DOCUMENT_INLINE_BLIP_INSERT , wave_id , wavelet_id , <EOL> blip_id = blip_id , <EOL> index = position , <EOL> prop = inline_blip_data ) <EOL> return inline_blip_data <EOL> def DocumentInlineBlipInsertAfterElement ( self ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) </s>
