#NEWLINE# def _uri_for( self , resource , * segments , **kwargs ) : #NEWLINE# #INDENT# ' Return a relative URI in string format for the entity specified\n        plus extra path segments.\n        ' #NEWLINE# if isinstance ( resource , int ) : #NEWLINE# #INDENT# uri = '{{{0}}}' . format ( resource ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( resource , NodePointer ) : #NEWLINE# #INDENT# uri = '{{{0}}}' . format ( resource . address ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( resource , Job ) : #NEWLINE# #INDENT# uri = '{{{0}}}' . format ( self . find ( resource ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# remote_resource = remote ( resource ) #NEWLINE# remote_graph = remote ( remote_resource . graph ) #NEWLINE# graph_uri = remote_graph . uri . string #NEWLINE# entity_uri = remote_resource . uri . string #NEWLINE# uri = entity_uri [ len ( graph_uri ) : ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if segments : #NEWLINE# #INDENT# if ( not uri . endswith ( '/' ) ) : #NEWLINE# #INDENT# uri += '/' #NEWLINE# #UNINDENT# uri += '/' . join ( map ( percent_encode , segments ) ) #NEWLINE# #UNINDENT# query = kwargs . get ( 'query' ) #NEWLINE# if ( query is not None ) : #NEWLINE# #INDENT# uri += ( '?' + query ) #NEWLINE# #UNINDENT# return uri