def get_class(name, defmod=None):
    """Finds a class.

    Search a class from its fully qualified name, e.g.
    'pyconstruct.domains.predefined.Class'.  If the class name is not fully
    qualified, e.g. 'Class', it is searched inside the default module.

    Parameters
    ----------
    name : str
        The fully qualified name of the class or the name of the class or the
        class name in the default module.
    defmod : str
        The default module where to search the class if not fully qualified.
    """
    ns = name.split('.')
    if len(ns) == 1:
        if not defmod:
            raise ValueError(
                'Provide either the fully qualified name of the class or the '
                'default module where to look for it'
            )
        mod = defmod
    else:
        mod = '.'.join(ns[:-1])
    module = __import__(mod, fromlist=[ns[-1]])
    return getattr(module, ns[-1])