def __resource_descriptor(self, resource_path, methods):
descriptor = {}<EOL>method_map = {}<EOL>sub_resource_index = collections.defaultdict(list)<EOL>sub_resource_map = {}<EOL>resource_path_tokens = resource_path.split('<STR_LIT:.>')<EOL>for service, protorpc_meth_info in methods:<EOL><INDENT>method_info = getattr(protorpc_meth_info, '<STR_LIT>', None)<EOL>path = method_info.get_path(service.api_info)<EOL>method_id = method_info.method_id(service.api_info)<EOL>canonical_method_id = self._get_canonical_method_id(method_id)<EOL>current_resource_path = self._get_resource_path(method_id)<EOL>if (current_resource_path[:len(resource_path_tokens)] !=<EOL>resource_path_tokens):<EOL><INDENT>raise api_exceptions.ToolError(<EOL>'<STR_LIT>'.format(<EOL>current_resource_path))<EOL><DEDENT>effective_resource_path = current_resource_path[<EOL>len(resource_path_tokens):]<EOL>if effective_resource_path:<EOL><INDENT>sub_resource_name = effective_resource_path[<NUM_LIT:0>]<EOL>new_resource_path = '<STR_LIT:.>'.join([resource_path, sub_resource_name])<EOL>sub_resource_index[new_resource_path].append(<EOL>(service, protorpc_meth_info))<EOL><DEDENT>else:<EOL><INDENT>method_map[canonical_method_id] = self.__method_descriptor(<EOL>service, method_info, protorpc_meth_info)<EOL><DEDENT><DEDENT>for sub_resource, sub_resource_methods in sub_resource_index.items():<EOL><INDENT>sub_resource_name = sub_resource.split('<STR_LIT:.>')[-<NUM_LIT:1>]<EOL>sub_resource_map[sub_resource_name] = self.__resource_descriptor(<EOL>sub_resource, sub_resource_methods)<EOL><DEDENT>if method_map:<EOL><INDENT>descriptor['<STR_LIT>'] = method_map<EOL><DEDENT>if sub_resource_map:<EOL><INDENT>descriptor['<STR_LIT>'] = sub_resource_map<EOL><DEDENT>return descriptor<EOL>
Describes a resource.

        Args:
          resource_path: string, the path of the resource (e.g., 'entries.items')
          methods: list of tuples of type
            (endpoints.Service, protorpc.remote._RemoteMethodInfo), the methods
            that serve this resource.

        Returns:
          Dictionary describing the resource.