def get(self, resource):
prefix, path = resource.finder.get_cache_info(resource)<EOL>if prefix is None:<EOL><INDENT>result = path<EOL><DEDENT>else:<EOL><INDENT>result = os.path.join(self.base, self.prefix_to_dir(prefix), path)<EOL>dirname = os.path.dirname(result)<EOL>if not os.path.isdir(dirname):<EOL><INDENT>os.makedirs(dirname)<EOL><DEDENT>if not os.path.exists(result):<EOL><INDENT>stale = True<EOL><DEDENT>else:<EOL><INDENT>stale = self.is_stale(resource, path)<EOL><DEDENT>if stale:<EOL><INDENT>with open(result, '<STR_LIT:wb>') as f:<EOL><INDENT>f.write(resource.bytes)<EOL><DEDENT><DEDENT><DEDENT>return result<EOL>
Get a resource into the cache,

:param resource: A :class:`Resource` instance.
:return: The pathname of the resource in the cache.