def finder(package):
if package in _finder_cache:<EOL><INDENT>result = _finder_cache[package]<EOL><DEDENT>else:<EOL><INDENT>if package not in sys.modules:<EOL><INDENT>__import__(package)<EOL><DEDENT>module = sys.modules[package]<EOL>path = getattr(module, '<STR_LIT>', None)<EOL>if path is None:<EOL><INDENT>raise DistlibException('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>loader = getattr(module, '<STR_LIT>', None)<EOL>finder_maker = _finder_registry.get(type(loader))<EOL>if finder_maker is None:<EOL><INDENT>raise DistlibException('<STR_LIT>' % package)<EOL><DEDENT>result = finder_maker(module)<EOL>_finder_cache[package] = result<EOL><DEDENT>return result<EOL>
Return a resource finder for a package.
:param package: The name of the package.
:return: A :class:`ResourceFinder` instance for the package.