#NEWLINE# def rehydrate( self , obj , inst = None ) : #NEWLINE# #INDENT# if isinstance ( obj , BoltNode ) : #NEWLINE# #INDENT# return Node . hydrate ( { #NEWLINE# #INDENT# 'self' : ( '%snode/%d' % ( self . graph_uri , obj . id ) ) , #NEWLINE# 'metadata' : { #NEWLINE# #INDENT# 'labels' : list ( obj . labels ) , #NEWLINE# #UNINDENT# } , #NEWLINE# 'data' : obj . properties , #NEWLINE# #UNINDENT# } , inst ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( obj , BoltRelationship ) : #NEWLINE# #INDENT# return Relationship . hydrate ( { #NEWLINE# #INDENT# 'self' : ( '%srelationship/%d' % ( self . graph_uri , obj . id ) ) , #NEWLINE# 'start' : ( '%snode/%d' % ( self . graph_uri , obj . start ) ) , #NEWLINE# 'end' : ( '%snode/%d' % ( self . graph_uri , obj . end ) ) , #NEWLINE# 'type' : obj . type , #NEWLINE# 'data' : obj . properties , #NEWLINE# #UNINDENT# } , inst ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( obj , BoltPath ) : #NEWLINE# #INDENT# return Path . hydrate ( { #NEWLINE# #INDENT# 'nodes' : [ ( '%snode/%d' % ( self . graph_uri , n . id ) ) for n in obj . nodes ] , #NEWLINE# 'relationships' : [ ( '%srelationship/%d' % ( self . graph_uri , r . id ) ) for r in obj . relationships ] , #NEWLINE# 'directions' : [ ( '->' if ( r . start == obj . nodes [ i ] . id ) else '<-' ) for ( i , r ) in enumerate ( obj . relationships ) ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( obj , list ) : #NEWLINE# #INDENT# return list ( map ( self . rehydrate , obj ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( obj , dict ) : #NEWLINE# #INDENT# return { key : self . rehydrate ( value ) for ( key , value ) in obj . items ( ) } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return obj