'Get the class for the package out of its module.
First loads (or fetches from cache) a module for the
package. Then extracts the package class from the module
according to Spack\'s naming convention.'

def get_pkg_class(self, pkg_name):

    (namespace, _, pkg_name) = pkg_name.rpartition('.')
    if (namespace and (namespace != self.namespace)):
        raise InvalidNamespaceError(('Invalid    namespace    for    %s    repo:    %s' % (self.namespace, namespace)))
    class_name = mod_to_class(pkg_name)
    module = self._get_pkg_module(pkg_name)
    cls = getattr(module, class_name)
    if (not inspect.isclass(cls)):
        tty.die(('%s.%s    is    not    a    class' % (pkg_name, class_name)))
    return cls
