Return an ordered dictionary with the available classes in the
    scalerel submodule with classes that derives from `base_class`,
    keyed by class name.
970040
def _get_available_class(base_class):
    '''
    
    '''
    gsims = {}
    for fname in os.listdir(os.path.dirname(__file__)):
        if fname.endswith('.py'):
            modname, _ext = os.path.splitext(fname)
            mod = importlib.import_module(
                'openquake.hazardlib.scalerel.' + modname)
            for cls in mod.__dict__.values():
                if inspect.isclass(cls) and issubclass(cls, base_class) \
                        and cls != base_class \
                        and not inspect.isabstract(cls):
                    gsims[cls.__name__] = cls
    return dict((k, gsims[k]) for k in sorted(gsims))
122245
def iter_subclasses(class_):
    
    ensure_class(class_)

    classes = set()

    def descend(class_):
        subclasses = set(class_.__subclasses__()) - classes
        classes.update(subclasses)
        return subclasses

    result = breadth_first(class_, descend)
    next(result)  # omit ``class_`` itself
    return result
173829
def es_get_class_defs(cls_def, cls_name):
    
    rtn_dict = {key: value for key, value in cls_def.items() \
                if key.startswith("kds_es")}
    for key in rtn_dict:
        del cls_def[key]
    return rtn_dict
1257195
def add_metaclass(metaclass):
    """"""
    def wrapper(cls):
        orig_vars = cls.__dict__.copy()
        orig_vars.pop('__dict__', None)
        orig_vars.pop('__weakref__', None)
        return metaclass(cls.__name__, cls.__bases__, orig_vars)
    return wrapper
627647
def get_superclass(self, class_):
        
        if not class_.is_loaded or class_.superclass_name is None:
            return None
        return self.get_class(class_.superclass_name)
593404
def as_dict(self):
        
        d = {"@module": self.__class__.__module__,
             "@class": self.__class__.__name__,
             "name": self.name, "options": self.options}
        if len(self.subkeys) > 0:
            subkeys = []
            for subkey in self.subkeys:
                subkeys.append(subkey.as_dict())
            d.update({"subkeys": subkeys})
        return d
1312361
def configured_class(cls):
        # type: () -> type
        """"""
        base = cls.configurable_base()
        # Manually mangle the private name to see whether this base
        # has been configured (and not another base higher in the
        # hierarchy).
        if base.__dict__.get('_Configurable__impl_class') is None:
            base.__impl_class = cls.configurable_default()
        return base.__impl_class
1118182
def inheritance_tree(include_mods = false)
      list = (include_mods ? mixins(:instance, :class) : [])
      if superclass.is_a?(Proxy) || superclass.respond_to?(:inheritance_tree)
        list += [superclass] unless superclass == P(:Object) || superclass == P(:BasicObject)
      end
      [self] + list.map do |m|
        next m if m == self
        next m unless m.respond_to?(:inheritance_tree)
        m.inheritance_tree(include_mods)
      end.flatten.uniq
    end
392737
def with_metaclass(Type, skip_attrs=set(('__dict__', '__weakref__'))):
    

    def _clone_with_metaclass(Class):
        attrs = dict((key, value) for key, value in items(vars(Class))
                     if key not in skip_attrs)
        return Type(Class.__name__, Class.__bases__, attrs)

    return _clone_with_metaclass
522329
def _subclassed(base, *classes):
        
        return all(map(lambda obj: isinstance(obj, base), classes))
964881
def getClassInModuleFromName(className, module):
    
    n = getAvClassNamesInModule(module)
    i = n.index(className)
    c = getAvailableClassesInModule(module)
    return c[i]
444222
def get_classes(modName):
    """"""
    classNames = []
    for name, obj in inspect.getmembers(sys.modules[modName]):
        if inspect.isclass(obj):
            classNames.append(name)

    return classNames
884564
def _index_classes(self) -> Dict[Text, Type[Platform]]:
        

        out = {}

        for p in get_platform_settings():
            cls: Type[Platform] = import_class(p['class'])

            if 'name' in p:
                out[p['name']] = cls
            else:
                out[cls.NAME] = cls

        return out
83293
def _get_bases(type_):
        # type: (type) -> Tuple[type, type]
        
        try:

            class _(type_):  # type: ignore
                """Check if type_ is subclassable."""

            BaseClass = type_
        except TypeError:
            BaseClass = object

        class MetaClass(_ValidationMeta, BaseClass.__class__):  # type: ignore
            """Use the type_ meta and include base validation functionality."""

        return BaseClass, MetaClass
1292134
def _iter_module_subclasses(package, module_name, base_cls):
    
    module = importlib.import_module('.' + module_name, package)
    for name, obj in inspect.getmembers(module):
        if inspect.isclass(obj) and issubclass(obj, base_cls):
            yield obj
426530
def get_curent_module_classes(module):
    
    classes = []
    for name, obj in inspect.getmembers(module):
        if inspect.isclass(obj):
            classes.append(obj)
    return classes
443674
def get_module_classes(module):
    

    clslst = get_module_members(module, type=inspect.isclass)
    return list(filter(lambda cls: not issubclass(cls, Exception),
                       clslst))