<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> import logging <EOL> import document <EOL> ROOT_WAVELET_ID_SUFFIX = '<STR_LIT>' <EOL> class Wave ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , json ) : <EOL> """<STR_LIT>""" <EOL> self . waveId = json . get ( '<STR_LIT>' ) <EOL> self . waveletIds = set ( json . get ( '<STR_LIT>' , [ ] ) ) <EOL> self . raw_data = json <EOL> def GetId ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . waveId <EOL> def GetWaveletIds ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . waveletIds <EOL> class Wavelet ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , json ) : <EOL> """<STR_LIT>""" <EOL> self . creator = json . get ( '<STR_LIT>' ) <EOL> self . creationTime = json . get ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> self . dataDocuments = json . get ( '<STR_LIT>' , { } ) <EOL> self . lastModifiedTime = json . get ( '<STR_LIT>' ) <EOL> self . participants = set ( json . get ( '<STR_LIT>' , [ ] ) ) <EOL> self . rootBlipId = json . get ( '<STR_LIT>' ) <EOL> self . title = json . get ( '<STR_LIT:title>' , '<STR_LIT>' ) <EOL> self . waveId = json . get ( '<STR_LIT>' ) <EOL> self . waveletId = json . get ( '<STR_LIT>' ) <EOL> self . raw_data = json <EOL> def GetCreator ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . creator <EOL> def GetCreationTime ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . creationTime <EOL> def GetDataDocument ( self , name , default = None ) : <EOL> """<STR_LIT>""" <EOL> if self . dataDocuments : <EOL> return self . dataDocuments . get ( name , default ) <EOL> return default <EOL> def GetId ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . waveletId <EOL> def GetLastModifiedTime ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . lastModifiedTime <EOL> def GetParticipants ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . participants <EOL> def GetRootBlipId ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . rootBlipId <EOL> def GetTitle ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . title <EOL> def GetWaveId ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . waveId <EOL> class Blip ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , json ) : <EOL> """<STR_LIT>""" <EOL> self . blipId = json . get ( '<STR_LIT>' ) <EOL> self . childBlipIds = set ( json . get ( '<STR_LIT>' , [ ] ) ) <EOL> self . content = json . get ( '<STR_LIT:content>' , '<STR_LIT>' ) <EOL> self . contributors = set ( json . get ( '<STR_LIT>' , [ ] ) ) <EOL> self . creator = json . get ( '<STR_LIT>' ) <EOL> self . lastModifiedTime = json . get ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> self . parentBlipId = json . get ( '<STR_LIT>' ) <EOL> self . waveId = json . get ( '<STR_LIT>' ) <EOL> self . waveletId = json . get ( '<STR_LIT>' ) <EOL> self . annotations = [ ] <EOL> for annotation in json . get ( '<STR_LIT>' , [ ] ) : <EOL> r = document . Range ( annotation [ '<STR_LIT>' ] [ '<STR_LIT:start>' ] , <EOL> annotation [ '<STR_LIT>' ] [ '<STR_LIT:end>' ] ) <EOL> self . annotations . append ( document . Annotation ( <EOL> annotation [ '<STR_LIT:name>' ] , annotation [ '<STR_LIT:value>' ] , r = r ) ) <EOL> self . document = Document ( self ) <EOL> self . elements = { } <EOL> json_elements = json . get ( '<STR_LIT>' , { } ) <EOL> for elem in json_elements : <EOL> self . elements [ elem ] = document . ElementFromJson ( json_elements [ elem ] ) <EOL> self . raw_data = json <EOL> def GetChildBlipIds ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . childBlipIds <EOL> def GetContributors ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . contributors <EOL> def GetCreator ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . creator <EOL> def GetDocument ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . document <EOL> def GetId ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . blipId <EOL> def GetLastModifiedTime ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . lastModifiedTime <EOL> def GetParentBlipId ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . parentBlipId <EOL> def GetWaveId ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . waveId <EOL> def GetWaveletId ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . waveletId <EOL> def IsRoot ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . parentBlipId is None <EOL> def GetAnnotations ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . annotations <EOL> def GetElements ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . elements <EOL> def GetGadgetByUrl ( self , url ) : <EOL> """<STR_LIT>""" <EOL> for el in self . elements . values ( ) : <EOL> if ( el . type == document . ELEMENT_TYPE . GADGET <EOL> and getattr ( el , '<STR_LIT:url>' , None ) == url ) : <EOL> return el <EOL> return None <EOL> class Document ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , blip ) : <EOL> """<STR_LIT>""" <EOL> self . _blip = blip <EOL> def GetText ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _blip . content <EOL> class Event ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , json ) : <EOL> """<STR_LIT>""" <EOL> self . modifiedBy = json . get ( '<STR_LIT>' ) <EOL> self . properties = json . get ( '<STR_LIT>' , { } ) <EOL> self . timestamp = json . get ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> self . type = json . get ( '<STR_LIT:type>' ) <EOL> self . raw_data = json <EOL> class Context ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . blips = { } <EOL> self . wavelets = { } <EOL> self . waves = { } <EOL> self . _operations = [ ] <EOL> def GetBlipById ( self , blip_id ) : <EOL> """<STR_LIT>""" <EOL> return self . blips . get ( blip_id , None ) <EOL> def GetWaveletById ( self , wavelet_id ) : <EOL> """<STR_LIT>""" <EOL> return self . wavelets . get ( wavelet_id , None ) <EOL> def GetWaveById ( self , wave_id ) : <EOL> """<STR_LIT>""" <EOL> return self . waves . get ( wave_id , None ) <EOL> def GetRootWavelet ( self ) : <EOL> """<STR_LIT>""" <EOL> for wavelet_id , wavelet in self . wavelets . items ( ) : <EOL> if wavelet_id . endswith ( ROOT_WAVELET_ID_SUFFIX ) : <EOL> return wavelet <EOL> logging . warning ( '<STR_LIT>' ) <EOL> return None <EOL> def GetWaves ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . waves . values ( ) <EOL> def GetWavelets ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . wavelets . values ( ) <EOL> def GetBlips ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . blips . values ( ) </s>
