Import's object from given Python path.
1786
def get_object_from_path(path):
    
    try:
        return sys.IMPORT_CACHE[path]
    except KeyError:
        _path = path.split('.')
        module_path = '.'.join(_path[:-1])
        class_name = _path[-1]
        module = importlib.import_module(module_path)
        sys.IMPORT_CACHE[path] = getattr(module, class_name)
        return sys.IMPORT_CACHE[path]
705817
def import_attr(path):
    
    module_path, attr_name = path.rsplit(".", 1)
    return getattr(import_module(module_path), attr_name)
1230327
def import_module(path):
    
    mod = __import__(path, locals={}, globals={})
    for item in path.split('.')[1:]:
        try:
            mod = getattr(mod, item)
        except AttributeError:
            raise ImportError('No module named %s' % path)
    return mod
850197
def load_module(module_name, module_path):
    """"""
    if sys.version_info >= (3,0):
        import pyximport
        pyximport.install()
        sys.path.append(module_path)
        return __import__(module_name)
    else:
        import imp
        module_info = imp.find_module(module_name, [module_path])
        return imp.load_module(module_name, *module_info)
1079831
def load(cls, file_path):
        

        # convert back to numpy
        data = helper.read_json(file_path)
        return Concise.from_dict(data)
1125561
def import_class(path):
    
    components = path.split(".")
    module = components[:-1]
    module = ".".join(module)
    mod = __import__(module, fromlist=[native_str(components[-1])])
    return getattr(mod, native_str(components[-1]))
542326
def _load_class(class_path):
    """"""
    parts = class_path.rsplit('.', 1)
    module = __import__(parts[0], fromlist=parts[1])
    return getattr(module, parts[1])
1241945
def import_recursive(path):
    
    results = {}
    obj = importlib.import_module(path)
    results[path] = obj
    path = getattr(obj, '__path__', os.path.dirname(obj.__file__))
    for loader, name, is_pkg in pkgutil.walk_packages(path):
        full_name = obj.__name__ + '.' + name
        results[full_name] = importlib.import_module(full_name)
        if is_pkg:
            results.update(import_recursive(full_name))
    return results
101901
def import_as(module, name):
    
    dir = os.path.split(__file__)[0]
    return imp.load_module(name, *imp.find_module(module, [dir]))
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
982485
def from_file(cls, path, environ):
        
        instance = cls()
        instance.read(path, environ)
        return instance
1135129
def import_object(name):
    
    parts = name.split('.')
    if len(parts) < 2:
        raise ValueError("Invalid name '%s'" % name)
    module_name = ".".join(parts[:-1])
    obj_name = parts[-1]
    module = importlib.import_module(module_name)
    return getattr(module, obj_name)
763031
def from_file(cls, path):

        

        with open(path, 'r', errors='replace') as f:
            return cls(f.read())
53688
def _load_module(self, module_path):
        """"""
        # __import__ will fail on unicode,
        # so we ensure module path is a string here.
        module_path = str(module_path)

        try:
            module_name, attr_name = module_path.split(':', 1)
        except ValueError:  # noqa
            raise self.error(
                '"{}" is not of format "module:parser"'.format(module_path))

        try:
            mod = __import__(module_name, globals(), locals(), [attr_name])
        except (Exception, SystemExit) as exc:  # noqa
            err_msg = 'Failed to import "{}" from "{}". '.format(
                attr_name, module_name)
            if isinstance(exc, SystemExit):
                err_msg += 'The module appeared to call sys.exit()'
            else:
                err_msg += 'The following exception was raised:\n{}'.format(
                    traceback.format_exc())

            raise self.error(err_msg)

        if not hasattr(mod, attr_name):
            raise self.error('Module "{}" has no attribute "{}"'.format(
                module_name, attr_name))

        parser = getattr(mod, attr_name)

        if not isinstance(parser, click.BaseCommand):
            raise self.error('"{}" of type "{}" is not derived from '
                             '"click.BaseCommand"'.format(
                                 type(parser), module_path))
        return parser
269703
def load_class_by_path(taskpath):
    

    return getattr(
        importlib.import_module(
            re.sub(
                r"\.[^.]+$",
                "",
                taskpath)),
        re.sub(
            r"^.*\.",
            "",
            taskpath))
1057265
def import_object(object_name):
    """"""
    package, name = object_name.rsplit('.', 1)
    return getattr(importlib.import_module(package), name)
173053
def load(self):
        """"""
        module = importlib.import_module(self.import_path)
        if self.attr:
            return getattr(module, self.attr)
        return module