<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_resource(self, service_name, resource_name, base_class=None):
 """ Retrieves a resource class from the cache, if available. :param service_name: The service a given ``Resource`` talks to. Ex. ``sqs``, ``sns``, ``dynamodb``, etc. :type service_name: string :param resource_name: The name of the ``Resource``. Ex. ``Queue``, ``Notification``, ``Table``, etc. :type resource_name: string :param base_class: (Optional) The base class of the object. Prevents "magically" loading the wrong class (one with a different base). Default is ``default``. :type base_class: class :returns: A <kotocore.resources.Resource> subclass """

        classpath = self.build_classpath(base_class)
        service = self.services.get(service_name, {})
        resources = service.get('resources', {})
        resource_options = resources.get(resource_name, {})
        resource_class = resource_options.get(classpath, None)

        if not resource_class:
            msg = "Resource '{0}' for {1} is not present in the cache."
            raise NotCached(msg.format(
                resource_name,
                service_name
            ))

        return resource_class