<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def __resource_descriptor(self, resource_path, methods):
 """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. """

    descriptor = {}
    method_map = {}
    sub_resource_index = collections.defaultdict(list)
    sub_resource_map = {}

    resource_path_tokens = resource_path.split('.')
    for service, protorpc_meth_info in methods:
      method_info = getattr(protorpc_meth_info, 'method_info', None)
      path = method_info.get_path(service.api_info)
      method_id = method_info.method_id(service.api_info)
      canonical_method_id = self._get_canonical_method_id(method_id)

      current_resource_path = self._get_resource_path(method_id)

      # Sanity-check that this method belongs to the resource path
      if (current_resource_path[:len(resource_path_tokens)] !=
          resource_path_tokens):
        raise api_exceptions.ToolError(
            'Internal consistency error in resource path {0}'.format(
                current_resource_path))

      # Remove the portion of the current method's resource path that's already
      # part of the resource path at this level.
      effective_resource_path = current_resource_path[
          len(resource_path_tokens):]

      # If this method is part of a sub-resource, note it and skip it for now
      if effective_resource_path:
        sub_resource_name = effective_resource_path[0]
        new_resource_path = '.'.join([resource_path, sub_resource_name])
        sub_resource_index[new_resource_path].append(
            (service, protorpc_meth_info))
      else:
        method_map[canonical_method_id] = self.__method_descriptor(
            service, method_info, protorpc_meth_info)

    # Process any sub-resources
    for sub_resource, sub_resource_methods in sub_resource_index.items():
      sub_resource_name = sub_resource.split('.')[-1]
      sub_resource_map[sub_resource_name] = self.__resource_descriptor(
          sub_resource, sub_resource_methods)

    if method_map:
      descriptor['methods'] = method_map

    if sub_resource_map:
      descriptor['resources'] = sub_resource_map

    return descriptor