<s> import json <EOL> from . wkutils import WebkitObject , Command <EOL> def evaluate ( expression , objectGroup = None , returnByValue = None ) : <EOL> params = { } <EOL> params [ '<STR_LIT>' ] = expression <EOL> if ( objectGroup ) : <EOL> params [ '<STR_LIT>' ] = objectGroup <EOL> if ( returnByValue ) : <EOL> params [ '<STR_LIT>' ] = returnByValue <EOL> command = Command ( '<STR_LIT>' , params ) <EOL> return command <EOL> def evaluate_parser ( result ) : <EOL> data = RemoteObject ( result [ '<STR_LIT:result>' ] ) <EOL> return data <EOL> def getProperties ( objectId , ownProperties = False ) : <EOL> params = { } <EOL> params [ '<STR_LIT>' ] = str ( objectId ) <EOL> params [ '<STR_LIT>' ] = ownProperties <EOL> command = Command ( '<STR_LIT>' , params ) <EOL> return command <EOL> def getProperties_parser ( result ) : <EOL> data = [ ] <EOL> for propertyDescriptor in result [ '<STR_LIT:result>' ] : <EOL> data . append ( PropertyDescriptor ( propertyDescriptor ) ) <EOL> return data <EOL> class RemoteObject ( WebkitObject ) : <EOL> def __init__ ( self , value ) : <EOL> self . set ( value , '<STR_LIT>' ) <EOL> self . set ( value , '<STR_LIT:description>' ) <EOL> self . set_class ( value , '<STR_LIT>' , RemoteObjectId ) <EOL> self . set ( value , '<STR_LIT>' ) <EOL> self . set ( value , '<STR_LIT:type>' ) <EOL> self . set ( value , '<STR_LIT:value>' ) <EOL> def __str__ ( self ) : <EOL> if self . type == '<STR_LIT>' : <EOL> return str ( self . value ) <EOL> if self . type == '<STR_LIT:string>' : <EOL> return str ( self . value ) <EOL> if self . type == '<STR_LIT>' : <EOL> return '<STR_LIT>' <EOL> if self . type == '<STR_LIT>' : <EOL> return str ( self . value ) <EOL> if self . type == '<STR_LIT:object>' : <EOL> if not self . objectId : <EOL> return '<STR_LIT:null>' <EOL> else : <EOL> if self . className : <EOL> return self . className <EOL> if self . description : <EOL> return self . description <EOL> return '<STR_LIT>' <EOL> if self . type == '<STR_LIT>' : <EOL> return self . description . split ( '<STR_LIT:\n>' ) [ <NUM_LIT:0> ] <EOL> class PropertyDescriptor ( WebkitObject ) : <EOL> def __init__ ( self , _value ) : <EOL> self . set ( _value , '<STR_LIT>' ) <EOL> self . set ( _value , '<STR_LIT>' ) <EOL> self . set ( _value , '<STR_LIT:name>' ) <EOL> self . set_class ( _value , '<STR_LIT:value>' , RemoteObject ) <EOL> self . set ( _value , '<STR_LIT>' ) <EOL> self . set ( _value , '<STR_LIT>' ) <EOL> def __str__ ( self ) : <EOL> return self . name <EOL> class RemoteObjectId ( WebkitObject ) : <EOL> def __init__ ( self , value ) : <EOL> self . value = value <EOL> def __str__ ( self ) : <EOL> return self . value <EOL> def __call__ ( self ) : <EOL> return self . value <EOL> def dumps ( self ) : <EOL> objid = json . loads ( self . value ) <EOL> return "<STR_LIT>" % ( objid [ '<STR_LIT>' ] , objid [ '<STR_LIT:id>' ] ) <EOL> def loads ( self , text ) : <EOL> parts = text . split ( '<STR_LIT:_>' ) <EOL> self . value = '<STR_LIT>' % ( parts [ <NUM_LIT:1> ] , parts [ <NUM_LIT:2> ] ) <EOL> return self . value </s>
