Load an item in the toolbar
    :param import_path: the dotted python path to class or function.
    :param args: For classes, any arguments to pass to the constructor.
    :param kwargs: For classes, any keyword arguments to pass to the constructor.
966059
def load_toolbar_item(import_path, *args, **kwargs):
    
    if isinstance(import_path, (tuple, list)):
        children = [load_toolbar_item(path) for path in import_path]
        return Group(*children)
    elif isinstance(import_path, basestring):
        symbol = _import_symbol(import_path, 'STAFF_TOOLBAR_ITEMS')
    else:
        symbol = import_path

    if inspect.isclass(symbol):
        # Instantiate the class.
        symbol = symbol(*args, **kwargs)

    if not callable(symbol):
        raise ImproperlyConfigured("The {0} in {1} is not callable!".format(import_path, 'STAFF_TOOLBAR_ITEMS'))

    return symbol
759655
def load_library(self, path):
        '''
        
        '''
        module = import_module(path)
        self.tags.update(module.register.tags)
        self.helpers.update(module.register.helpers)
399956
async def load(self,
                   file_path,
                   locale=None,
                   key: int = 0,
                   pos: int = 1,
                   neg: Optional[ColRanges] = None):
        

        if neg is None:
            neg: ColRanges = [(2, None)]

        await self.start(file_path, locale, kwargs={
            'key': key,
            'pos': pos,
            'neg': neg,
        })
1346814
def load(self, path: str) -> ClassFile:
        
        # Try to refresh the class from the cache, loading it from disk
        # if not found.
        try:
            r = self.class_cache.pop(path)
        except KeyError:
            with self.open(f'{path}.class') as source:
                r = self.klass(source)

        r.classloader = self
        # Even if it was found re-set the key to update the OrderedDict
        # ordering.
        self.class_cache[path] = r

        # If the cache is enabled remove every item over N started from
        # the least-used.
        if self.max_cache > 0:
            to_pop = max(len(self.class_cache) - self.max_cache, 0)
            for _ in repeat(None, to_pop):
                self.class_cache.popitem(last=False)

        return r
542326
def _load_class(class_path):
    """"""
    parts = class_path.rsplit('.', 1)
    module = __import__(parts[0], fromlist=parts[1])
    return getattr(module, parts[1])
1056401
def get_integration_module(integration_path):
    
    # add custom paths so imports would work
    paths = [
        os.path.join(__file__, "..", ".."),  # to import integrationmanager
        os.path.join(integration_path, ".."),  # to import integration itself
        os.path.join(integration_path, DEPS_DIR),  # to import integration deps
    ]

    for path in paths:
        path = os.path.realpath(path)
        logger.debug("adding %s to path", path)
        sys.path.insert(0, path)

    # get our integration class instance
    integration_name = os.path.basename(integration_path)
    logger.debug("importing %s", ".".join([integration_name, INTEGRATION]))
    return importlib.import_module(".".join([integration_name, INTEGRATION]))
137983
def _path_hooks(cls, path):  # from importlib.PathFinder
        """"""
        if sys.path_hooks is not None and not sys.path_hooks:
            warnings.warn('sys.path_hooks is empty', ImportWarning)
        for hook in sys.path_hooks:
            try:
                return hook(path)
            except ImportError:
                continue
        else:
            return None
1205558
def import_string(dotted_path: str) -> Any:
    
    try:
        module_path, class_name = dotted_path.strip(' ').rsplit('.', 1)
    except ValueError as e:
        raise ImportError(f'"{dotted_path}" doesn\'t look like a module path') from e

    module = import_module(module_path)
    try:
        return getattr(module, class_name)
    except AttributeError as e:
        raise ImportError(f'Module "{module_path}" does not define a "{class_name}" attribute') from e
17887
def get_module(path):
    
    try:
        from importlib import import_module
    except ImportError as e:
        from django.utils.importlib import import_module

    try:
        mod_name, func_name = path.rsplit('.', 1)
        mod = import_module(mod_name)
    except ImportError as e:
        raise ImportError(
            'Error importing alert function {0}: "{1}"'.format(mod_name, e))

    try:
        func = getattr(mod, func_name)
    except AttributeError:
        raise ImportError(
            ('Module "{0}" does not define a "{1}" function'
                            ).format(mod_name, func_name))

    return func
46289
def _load_module(module_name, path):
    ''''''
    # TODO: handle the case that the module is already loaded
    try:
        # First try to find a non-builtin, non-frozen, non-special
        # module using the client's search path
        fd, filename, info = imp.find_module(module_name, path)
    except ImportError:
        # The above will fail for builtin, frozen, or special
        # modules. We search for those now...
        fd, filename, info = imp.find_module(module_name)

    # Now import the module given the info found above
    try:
        return imp.load_module(module_name, fd, filename, info)
    finally:
        if fd is not None:
            fd.close()
811492
def load(self, path):
        
        path = os.path.expandvars(os.path.expanduser(path))

        gdg = cgaddag.gdg_load(path.encode("ascii"))
        if not gdg:
            errno = ctypes.c_int.in_dll(ctypes.pythonapi, "errno").value
            raise OSError(errno, os.strerror(errno), path)

        self.__del__()
        self.gdg = gdg.contents
458599
def import_by_path(path: str) -> Callable:
    

    module_path, _, class_name = path.rpartition('.')
    return getattr(import_module(module_path), class_name)
1344923
def import_tasks(self, path):
        
        for zz in os.walk(path):
            for module in zz[2]:

                if module.endswith('.py'):

                    import importlib

                    # from tasks.message_popup import *



                    importlib.import_module('tasks.' + module[:-3])

                    print 'imported', module
1005353
def load_model_class(model_path):
    
    dot = model_path.rindex('.')
    module_name = model_path[:dot]
    class_name = model_path[dot + 1:]
    try:
        _class = getattr(import_module(module_name), class_name)
        return _class
    except (ImportError, AttributeError):
        raise ImproperlyConfigured('%s cannot be imported' % model_path)
1306641
def load_all_from_path(self, path):
		
		shutit_global.shutit_global_object.yield_to_draw()
		#111: handle expanded paths
		path = os.path.abspath(path)
		#http://stackoverflow.com/questions/301134/dynamic-module-import-in-python
		if os.path.abspath(path) == self.shutit_main_dir:
			return
		if not os.path.exists(path):
			return
		if os.path.exists(path + '/STOPBUILD') and not self.build['ignorestop']:
			self.log('Ignoring directory: ' + path + ' as it has a STOPBUILD file in it. Pass --ignorestop to shutit run to override.',level=logging.DEBUG)
			return
		for sub in glob.glob(os.path.join(path, '*')):
			subpath = os.path.join(path, sub)
			if os.path.isfile(subpath):
				self.load_mod_from_file(subpath)
			elif os.path.isdir(subpath):
				self.load_all_from_path(subpath)
815631
def import_path(mod_path, mod_name):
    
    mod_code = open(mod_path).read()

    mod_obj = import_code(
        mod_code=mod_code,
        mod_name=mod_name,
    )

    if not hasattr(mod_obj, '__file__'):
        mod_obj.__file__ = mod_path

    return mod_obj
554618
def import_(path):
    
    if isinstance(path, str):
        v = path.split(':')
        if len(v) == 1:
            x = path.rsplit('.', 1)
            if len(x) == 2:
                module, func = x
            else:
                module, func = x[0], ''
        else:
            module, func = v
        mod = __import__(module)
        f = mod
        if func:
            for x in func.split('.'):
                f = getattr(f, x)
    else:
        f = path
    return f