def _relative_object_uri(resource_name, object_uri):
 obj_parts = object_uri.split('/')
 for length in range((len(obj_parts) + 1)):
  parent_uri = '/'.join(obj_parts[:length])
  (parent_resource_name, _) = _resource_endpoint(parent_uri)
  if (resource_name == parent_resource_name):
   return parent_uri
 error_msg = 'Cannot get URL of resource %r from parent %r.'
 raise ValueError((error_msg % (resource_name, object_uri)))

def _relative_object_uri ( resource_name , object_uri ) : obj_parts = object_uri . split ( '/' ) for length in range ( ( len ( obj_parts ) + 1 ) ) : parent_uri = '/' . join ( obj_parts [ : length ] ) ( parent_resource_name , _ ) = _resource_endpoint ( parent_uri ) if ( resource_name == parent_resource_name ) : return parent_uri error_msg = 'Cannot get URL of resource %r from parent %r.' raise ValueError ( ( error_msg % ( resource_name , object_uri ) ) )
returns object_uri .