imports and returns module class from ``path.to.module.Class``
    argument
179173
def get_module_class(class_path):
    
    mod_name, cls_name = class_path.rsplit('.', 1)

    try:
        mod = import_module(mod_name)
    except ImportError as e:
        raise ImproperlyConfigured(('Error importing module %s: "%s"' % (mod_name, e)))

    return getattr(mod, cls_name)
371724
def import_module(dotted_path):
    
    import importlib

    module_parts = dotted_path.split('.')
    module_path = '.'.join(module_parts[:-1])
    module = importlib.import_module(module_path)

    return getattr(module, module_parts[-1])
159506
def get_class(class_string):
    
    split_string = class_string.encode('ascii').split('.')
    import_path = '.'.join(split_string[:-1])
    class_name = split_string[-1]

    if class_name:
        try:
            if import_path:
                mod = __import__(import_path, globals(), {}, [class_name])
                cls = getattr(mod, class_name)
            else:
                cls = __import__(class_name, globals(), {})
            if cls:
                return cls
        except (ImportError, AttributeError):
            pass

    return None
757980
def import_class(klass):
    
    path = klass.rfind(".")
    class_name = klass[path + 1: len(klass)]
    try:
        module = __import__(klass[0:path], globals(), locals(), [class_name])
        klass = getattr(module, class_name)
    except ImportError as e:
        raise ImportError('%s: %s' % (klass, str(e)))
    except AttributeError:
        raise ImportError(klass)
    else:
        return klass
1296361
def import_class(self, import_name):
        
        module_name, class_name = import_name.rsplit(".", 1)
        mod = import_module(module_name)
        check_class = getattr(mod, class_name)
        self.mapping[check_class.name] = check_class
        logger.info("successfully loaded class %s", check_class)
        return check_class
318248
def import_namespaced_class(path):
    
    parts = path.split('.')
    return getattr(importlib.import_module('.'.join(parts[0:-1])), parts[-1])
904077
def _import_module_from_path(module_name, plugin_path):
    
    module = None
    try:
        if PY2:
            info = imp.find_module(module_name, [plugin_path])
            if info:
                module = imp.load_module(module_name, *info)
        else:  # Python 3.4+
            spec = importlib.machinery.PathFinder.find_spec(
                module_name,
                [plugin_path])
            if spec:
                module = spec.loader.load_module(module_name)
    except Exception:
        pass

    return module
933806
def get_class(class_path):
        
        module_path, class_name = class_path.rsplit(".", 1)

        try:
            module = __import__(class_path, fromlist=[class_name])
        except ImportError:
            raise ValueError('Class {0} could not be imported'.format(class_path))

        try:
            cls = getattr(module, class_name)
        except AttributeError:
            raise ValueError("Module '%s' has no class '%s'" % (module_path, class_name,))

        try:
            instance = cls()
        except TypeError as type_error:
            raise ValueError('Failed to instantiate class {0}. Error: {1}'.format(class_name, type_error.message))

        return instance
528765
def helper_import(module_name, class_name=None):
    
    try:
        module = __import__(module_name, globals(), locals(), [class_name])
    except (BlackbirdError, ImportError) as error:
        raise BlackbirdError(
            'can not load {0} module [{1}]'
            ''.format(module_name, str(error))
        )

    if not class_name:
        return module
    else:
        try:
            return getattr(module, class_name)
        except:
            return False
1022236
def get_class_by_path(class_path: str, is_module: Optional[bool] = False) -> type:
    

    if is_module:
        try:
            backend_module = importlib.import_module(class_path)
        except ImportError:
            logger.warning("Can't import backend with name `%s`", class_path)
            raise
        else:
            return backend_module

    module_name, class_name = class_path.rsplit('.', 1)

    try:
        backend_module = importlib.import_module(module_name)
    except ImportError:
        logger.error("Can't import backend with name `%s`", module_name)
        raise

    try:
        backend_class = getattr(backend_module, class_name)
    except AttributeError:
        logger.error("Can't get backend class `%s` from `%s`", class_name, module_name)
        raise

    return backend_class
1029041
def get_class(import_path=None):
    
    from django.core.exceptions import ImproperlyConfigured
    if import_path is None:
        raise ImproperlyConfigured('No class path specified.')
    try:
        dot = import_path.rindex('.')
    except ValueError:
        raise ImproperlyConfigured("%s isn't a module." % import_path)
    module, classname = import_path[:dot], import_path[dot+1:]
    try:
        mod = import_module(module)
    except ImportError as e:
        raise ImproperlyConfigured('Error importing module %s: "%s"' % (module, e))
    try:
        return getattr(mod, classname)
    except AttributeError:
        raise ImproperlyConfigured('Module "%s" does not define a "%s" class.' % (module, classname))
771697
def resolve_import(import_path, from_module):
    '''
    '''
    if not import_path or not import_path.startswith('.'):
        return import_path

    from_module = from_module.split('.')
    dots = 0
    for c in import_path:
        if c == '.':
            dots += 1
        else:
            break

    if dots:
        from_module = from_module[:-dots]
        import_path = import_path[dots:]

    if import_path:
        from_module.append(import_path)

    return '.'.join(from_module)
107979
def str_to_class(class_name):
    
    mod_str, cls_str = class_name.rsplit('.', 1)
    mod = __import__(mod_str, globals(), locals(), [''])
    cls = getattr(mod, cls_str)
    return cls
505150
def _import(module, cls):
    
    global Scanner

    try:
        cls = str(cls)
        mod = __import__(str(module), globals(), locals(), [cls], 1)
        Scanner = getattr(mod, cls)
    except ImportError:
        pass
199774
def get_class_from_settings_full_path(settings_key):
    
    cls_path = getattr(settings, settings_key, None)

    if not cls_path:
        raise NotImplementedError()

    try:
        module_name, class_name = cls_path.rsplit('.', 1)
    except ValueError:
        raise ImproperlyConfigured("{0} must be of the form "
                                   "'some.path.module.MyClass'".format(
                                                                settings_key))

    manager_module = importlib.import_module(module_name)

    if not manager_module:
        raise ImproperlyConfigured("{0} refers to a module that has not been "
                                   "installed".format(settings_key))

    return getattr(manager_module, class_name)
652553
def import_class(import_path):
    
    if not '.' in import_path:
        raise IncorrectImportPath(
            "Invalid Python-style import path provided: {0}.".format(
                import_path
            )
        )

    path_bits = import_path.split('.')
    mod_path = '.'.join(path_bits[:-1])
    klass_name = path_bits[-1]

    try:
        mod = importlib.import_module(mod_path)
    except ImportError:
        raise IncorrectImportPath(
            "Could not import module '{0}'.".format(mod_path)
        )

    try:
        klass = getattr(mod, klass_name)
    except AttributeError:
        raise IncorrectImportPath(
            "Imported module '{0}' but could not find class '{1}'.".format(
                mod_path,
                klass_name
            )
        )

    return klass
77848
def _path_to_module(path):
    
    # Split of preceeding path elements:
    path = "rapport" + path.split("rapport")[1]
    # Split of ending and replace os.sep with dots:
    path = path.replace(os.sep, ".").rsplit(".", 1)[0]
    return path