Alternate helper function to map string class names to module classes.
191754
def str_to_class(s):
    """"""
    lst = s.split(".")
    klass = lst[-1]
    mod_list = lst[:-1]
    module = ".".join(mod_list)
    try:
        mod = __import__(module)
        if hasattr(mod, klass):
            return getattr(mod, klass)
        else:
            return None
    except ImportError:
        return None
655717
def import_from_string(full_class_name):
        """"""
        s = full_class_name.split('.')
        class_name = s[-1]
        module_name = full_class_name[:-len(class_name)-1]
        module = importlib.import_module(module_name)
        # the class, it's common to spell with k as class is reserved
        klass = getattr(module, class_name)
        return klass
1166135
def import_class(import_str):
    """"""
    mod_str, _sep, class_str = import_str.rpartition(".")
    __import__(mod_str)
    return getattr(sys.modules[mod_str], class_str)
1006572
def from_dict(cls, d):
        
        conf = {}
        for k in d["config"]:
            v = d["config"][k]
            if isinstance(v, dict):
                if u"type" in v:
                    typestr = v[u"type"]
                else:
                    typestr = v["type"]
                conf[str(k)] = classes.get_dict_handler(typestr)(v)
            else:
                conf[str(k)] = v
        return classes.get_class(d["class"])(name=d["name"], config=conf)
1128476
def _str_to_type(cls, context_class, string):
        

        if string in cls._TYPE_NAMES_BUILTIN:
            return eval(string)

        module_ = sys.modules[context_class.__module__]

        if hasattr(module_, string):
            return getattr(module_, string)

        return cls._str_to_type_from_member_module(module_, string)
938331
def module2md(self, module):
        
        modname = module.__name__
        path = self.get_src_path(module, append_base=False)
        path = "[{}]({})".format(path, os.path.join(self.github_link, path))
        found = set()

        classes = []
        line_nos = []
        for name, obj in getmembers(module, inspect.isclass):
            # handle classes
            found.add(name)
            if not name.startswith("_") and hasattr(obj, "__module__") and obj.__module__ == modname:
                classes.append(self.class2md(obj))
                line_nos.append(self.get_line_no(obj) or 0)
        classes = order_by_line_nos(classes, line_nos)

        # Since functions can have multiple aliases.
        func2names = defaultdict(list)
        for name, obj in getmembers(module, inspect.isfunction):
            func2names[obj].append(name)

        functions = []
        line_nos = []
        for obj in func2names:
            names = func2names[obj]
            found.update(names)

            # Include if within module or included modules within __init__.py and exclude from global variables
            is_module_within_init = '__init__.py' in path and obj.__module__.startswith(modname)
            if is_module_within_init:
                found.add(obj.__module__.replace(modname + '.', ''))

            if hasattr(obj, "__module__") and (obj.__module__ == modname or is_module_within_init):
                names = list(filter(lambda name: not name.startswith("_"), names))
                if len(names) > 0:
                    functions.append(self.func2md(obj, names=names))
                    line_nos.append(self.get_line_no(obj) or 0)
        functions = order_by_line_nos(functions, line_nos)

        variables = []
        line_nos = []
        for name, obj in module.__dict__.items():
            if not name.startswith("_") and name not in found:
                if hasattr(obj, "__module__") and obj.__module__ != modname:
                    continue
                if hasattr(obj, "__name__") and not obj.__name__.startswith(modname):
                    continue

                comments = inspect.getcomments(obj)
                comments = ": %s" % comments if comments else ""
                variables.append("- **%s**%s" % (name, comments))
                line_nos.append(self.get_line_no(obj) or 0)

        variables = order_by_line_nos(variables, line_nos)
        if variables:
            new_list = ["**Global Variables**", "---------------"]
            new_list.extend(variables)
            variables = new_list

        string = MODULE_TEMPLATE.format(path=path,
                                        global_vars="\n".join(variables) if variables else "",
                                        functions="\n".join(functions) if functions else "",
                                        classes="".join(classes) if classes else "")
        return string
444222
def get_classes(modName):
    """"""
    classNames = []
    for name, obj in inspect.getmembers(sys.modules[modName]):
        if inspect.isclass(obj):
            classNames.append(name)

    return classNames
147903
private Map<String, String> buildShortNameToFullNameMap(Set<String> classSet) {
        Map<String, String> result = new HashMap<>();
        for (String className : classSet) {
            String shortClassName = getShortClassName(className);
            result.put(shortClassName, className);
        }
        return result;
    }
1329428
def qualified_class_name(o):
    """"""
    module = o.__class__.__module__
    if module is None or module == str.__class__.__module__:
        return o.__class__.__name__
    return module + '.' + o.__class__.__name__
545759
def resolve(str_or_obj):
    """"""
    from rope.base.utils.pycompat import string_types
    if not isinstance(str_or_obj, string_types):
        return str_or_obj
    if '.' not in str_or_obj:
        str_or_obj += '.'
    mod_name, obj_name = str_or_obj.rsplit('.', 1)
    __import__(mod_name)
    mod = sys.modules[mod_name]
    return getattr(mod, obj_name) if obj_name else mod
637545
def obj_classes_from_module(module):
    """"""
    for name in dir(module):
        if not name.startswith('_'):
            cls = getattr(module, name)
            if getattr(cls, 'classID', None):
                yield (name, cls)
568674
def match_modules(allowed_modules):
    """"""
    cleaned_allowed_modules = [
        utils.mod_to_mod_name(tmp_mod)
        for tmp_mod in allowed_modules
    ]
    cleaned_split_allowed_modules = [
        tmp_mod.split(".")
        for tmp_mod in cleaned_allowed_modules
    ]
    cleaned_allowed_modules = []
    del cleaned_allowed_modules

    def matcher(cause):
        cause_cls = None
        cause_type_name = cause.exception_type_names[0]
        # Rip off the class name (usually at the end).
        cause_type_name_pieces = cause_type_name.split(".")
        cause_type_name_mod_pieces = cause_type_name_pieces[0:-1]
        # Do any modules provided match the provided causes module?
        mod_match = any(
            utils.array_prefix_matches(mod_pieces,
                                       cause_type_name_mod_pieces)
            for mod_pieces in cleaned_split_allowed_modules)
        if mod_match:
            cause_cls = importutils.import_class(cause_type_name)
            cause_cls = ensure_base_exception(cause_type_name, cause_cls)
        return cause_cls

    return matcher
46270
def get_injected_modules(classname):
    
    """
    modname_list = __CLASSNAME_CLASSKEY_REGISTER__[classname]

    injected_modules = []
    for modstr in modname_list:
        parts = modstr.split('.')
        pkgname = '.'.join(parts[:-1])
        modname = parts[-1]
        try:
            exec('from %s import %s' % (pkgname, modname, ), globals(), locals())
            module = eval(modname)
            injected_modules.append(module)
        except ImportError as ex:
            ut.printex(ex, 'Cannot load package=%r, module=%r' % (pkgname, modname, ))
    return injected_modules
499483
def get_plugin_from_string(plugin_name):
    
    modulename, classname = plugin_name.rsplit('.', 1)
    module = import_module(modulename)
    return getattr(module, classname)
442698
def for_name(modpath, classname):
    '''
    
    '''
    module = __import__(modpath, fromlist=[classname])
    classobj = getattr(module, classname)
    return classobj()
857007
def import_classes(name, currmodule):
    # type: (unicode, unicode) -> Any
    """"""
    target = None

    # import class or module using currmodule
    if currmodule:
        target = try_import(currmodule + '.' + name)

    # import class or module without currmodule
    if target is None:
        target = try_import(name)

    if target is None:
        raise InheritanceException(
            'Could not import class or module %r specified for '
            'inheritance diagram' % name)

    if inspect.isclass(target):
        # If imported object is a class, just return it
        return [target]
    elif inspect.ismodule(target):
        # If imported object is a module, return classes defined on it
        classes = []
        for cls in target.__dict__.values():
            if inspect.isclass(cls) and cls_is_in_module(cls, mod=target):
                classes.append(cls)
        return classes
    raise InheritanceException('%r specified for inheritance diagram is '
                               'not a class or module' % name)
1242729
def get_import_for_type(t):
    """"""
    t_as_string = to_str(t)
    if not is_identifier(t_as_string):
        # this class expanded into something other than a single identifier
        # we can ignore it.  This is the case when we encounter something
        # like the configman.converter.str_to_classes_in_namespaces
        # InnerClassList.  We can safely ignore these things here.
        return (None, None)
    if '.' in t_as_string:
        parts = t_as_string.split('.')
        return ('.'.join(parts[:-1]), parts[-1])
    else:
        if t_as_string in known_mapping_str_to_type:
            return (None, None)
        return (None, t_as_string)