load and return the module/attribute.
173053
def load(self):
        """"""
        module = importlib.import_module(self.import_path)
        if self.attr:
            return getattr(module, self.attr)
        return module
1243466
def get_attr(name):
    
    i = name.rfind('.')
    cls = str(name[i+1:])
    module = str(name[:i])

    mod = __import__(module, fromlist=[cls])
    return getattr(mod, cls)
990864
def load_object(path):
    """"""
    i = path.rfind('.')
    module_name, object_name = path[:i], path[i + 1:]
    # Load module.
    try:
        module = import_module(module_name)
    except ImportError:
        raise ImproperlyConfigured('Module %r not found' % module_name)
    except ValueError:
        raise ImproperlyConfigured('Invalid module %r' % module_name)
    # Load object.
    try:
        return getattr(module, object_name)
    except AttributeError:
        msg = 'Module %r does not define an object named %r'
        raise ImproperlyConfigured(msg % (module_name, object_name))
1180296
def get_object(self):
        """"""

        from ..util import AttrDict

        c = self.record.unpacked_contents

        if not c:
            c = yaml.safe_load(self.default)

        return AttrDict(c)
924147
def _load_symbol(name):
    
    module_name, key = name.rsplit('.', 1)
    try:
        module = importlib.import_module(module_name)
    except ImportError as err:
        # it's possible the symbol is a class method
        module_name, class_name = module_name.rsplit('.', 1)
        module = importlib.import_module(module_name)
        cls = getattr(module, class_name, None)
        if cls:
            attr = getattr(cls, key, None)
        else:
            raise err
    else:
        attr = getattr(module, key, None)
    if not callable(attr):
        raise ValueError('%s is not callable (was %r)' % (name, attr))
    return attr
738741
def load_module(self, mod):
        
        try:
            return sys.modules[mod]
        except KeyError:
            pass

        lib = ExtensionImporter.extension_modules[mod]
        m = imp.load_dynamic(mod, lib)
        sys.modules[mod] = m
        return m
1088347
def _load_module(module):
    
    modclass = type(module)
    # We only take care of our own LazyModule instances
    if not issubclass(modclass, LazyModule):
        raise TypeError("Passed module is not a LazyModule instance.")
    with _ImportLockContext():
        parent, _, modname = module.__name__.rpartition('.')
        logger.debug("loading module {}".format(modname))
        # We first identify whether this is a loadable LazyModule, then we
        # strip as much of lazy_import behavior as possible (keeping it cached,
        # in case loading fails and we need to reset the lazy state).
        if not hasattr(modclass, '_lazy_import_error_msgs'):
            # Alreay loaded (no _lazy_import_error_msgs attr). Not reloading.
            return
        # First, ensure the parent is loaded (using recursion; *very* unlikely
        # we'll ever hit a stack limit in this case).
        modclass._LOADING = True
        try:
            if parent:
                logger.debug("first loading parent module {}".format(parent))
                setattr(sys.modules[parent], modname, module)
            if not hasattr(modclass, '_LOADING'):
                logger.debug("Module {} already loaded by the parent"
                             .format(modname))
                # We've been loaded by the parent. Let's bail.
                return
            cached_data = _clean_lazymodule(module)
            try:
                # Get Python to do the real import!
                reload_module(module)           
            except:
                # Loading failed. We reset our lazy state.
                logger.debug("Failed to load module {}. Resetting..."
                             .format(modname))
                _reset_lazymodule(module, cached_data)
                raise
            else:
                # Successful load
                logger.debug("Successfully loaded module {}".format(modname))
                delattr(modclass, '_LOADING')
                _reset_lazy_submod_refs(module)

        except (AttributeError, ImportError) as err:
            logger.debug("Failed to load {}.\n{}: {}"
                         .format(modname, err.__class__.__name__, err))
            logger.lazy_trace()
            # Under Python 3 reloading our dummy LazyModule instances causes an
            # AttributeError if the module can't be found. Would be preferrable
            # if we could always rely on an ImportError. As it is we vet the
            # AttributeError as thoroughly as possible.
            if ((six.PY3 and isinstance(err, AttributeError)) and not
                err.args[0] == "'NoneType' object has no attribute 'name'"):
                # Not the AttributeError we were looking for.
                raise
            msg = modclass._lazy_import_error_msgs['msg']
            raise_from(ImportError(
                msg.format(**modclass._lazy_import_error_strings)), None)
63793
def load_module(path):
    '''
        
    '''
    with add_to_path(os.path.dirname(path)):
        spec    = importlib.util.spec_from_file_location(os.path.basename(path).replace('.py',''), path)
        module  = importlib.util.module_from_spec(spec)
        spec.loader.exec_module(module)
    return module
116502
def _loadable_get_(name, self):
        ""

        func = getattr(self._attr_func_, name)
        ret = func()
        setattr(self._attr_data_, name, ret)
        setattr(
            type(self),
            name,
            property(
                functools.partial(self._simple_get_, name)
            )
        )
        delattr(self._attr_func_, name)
        return ret
1068655
def load_settings(self):
        """"""
        mname = 'loaded_module'
        if six.PY2:
            import imp
            return imp.load_source(mname, self.settings_filename)
        else:
            import importlib.machinery
            loader = importlib.machinery.SourceFileLoader(mname, self.settings_filename)
        return loader.load_module(mname)
296394
def import_object(module_name, attribute_name):
    
    # Py2 compatibility: force str (i.e bytes) when importing.
    module = __import__(str(module_name), {}, {}, [str(attribute_name)], 0)
    return getattr(module, str(attribute_name))
1329584
def load_module(self, module):
        
        if isinstance(module, basestring) and module.find('.') > -1:
            a = module.split('.')
            module = ('.%s' % a[-1], '.'.join(a[:-1]))
        try:
            module = import_module(*module)
        except Exception, e:
            return e
        
        for name in dir(module):
            if name.startswith('_'): continue
            obj = getattr(module, name)
            if callable(obj):
                for tag in settings.TAG_TYPES:
                    if hasattr(obj, tag) and getattr(obj, tag) in (1, True):
                        name = getattr(obj, 'name', obj.__name__)
                        if name in self[tag]:
                            continue
                        if hasattr(obj, 'name'):
                            self.register(tag, getattr(obj, 'name'), obj)
                        else:
                            self.register(tag, obj)
1259557
def load_module(self, name):
        """"""
        if name in sys.modules:
            return sys.modules[name]
        # load the actual import hook module
        module_name = self.mount2name(name)
        __import__(module_name)
        # alias the import hook module to the mount, so both can be used interchangeably
        module = sys.modules[name] = sys.modules[module_name]
        module.install()
        return module
482616
def get():
        """"""
        return {
            attr: getattr(Conf, attr)
            for attr in dir(Conf()) if not callable(getattr(Conf, attr)) and not attr.startswith("__")
        }
166017
def module(self):
        """"""

        if self._module is None:
            if self.library is None:
                raise ValueError(
                    "Backend '%s' doesn't specify a library attribute" % self.__class__)

            try:
                if '.' in self.library:
                    mod_path, cls_name = self.library.rsplit('.', 1)
                    mod = import_module(mod_path)
                    self._module = getattr(mod, cls_name)
                else:
                    self._module = import_module(self.library)
            except (AttributeError, ImportError):
                raise ValueError("Couldn't load %s backend library" % cls_name)

        return self._module
17200
def load_module(self, module):
        
        # pylint: disable=unused-variable
        for name, obj in inspect.getmembers(module,
                                            lambda member: hasattr(member, '__module__')
                                            and member.__module__ == module.__name__
                                            and inspect.isclass):
            self.load_class(obj)
1364091
def load_from_namespace(module_name):
        
        class_inst = None
        name = "py3status.modules.{}".format(module_name)
        py_mod = __import__(name)
        components = name.split(".")
        for comp in components[1:]:
            py_mod = getattr(py_mod, comp)
        class_inst = py_mod.Py3status()
        return class_inst