Load hook module and register signals.

    :param path: Absolute or relative path to module.
    :return: module
4572
def _load_hooks(path):
    
    module = imp.load_source(os.path.splitext(os.path.basename(path))[0], path)
    if not check_hook_mechanism_is_intact(module):
        # no hooks - do nothing
        log.debug('No valid hook configuration: \'%s\'. Not using hooks!', path)
    else:
        if check_register_present(module):
            # register the template hooks so they listen to gcdt_signals
            module.register()
    return module
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
527502
def _load_mod_ui_libraries(self, path):
        
        path = path / Path('mod')
        sys.path.append(str(path))
413194
def load_rc(self, path=None, system=False):
        
        if os.path.isfile(self.user_rc_path) and not system:
            path = self.user_rc_path
        elif os.path.isfile(self.sys_rc_path):
            path = self.sys_rc_path

        if not path or not os.path.isfile(path):
            return {}

        with open(path) as f:
            return yaml.load(f) or {}
1129684
def load(self, path):
        
        with open(path, 'rb') as f:
            self.data = f.read()
            self.root = et.fromstring(self.data)
476486
def import_by_path(dotted_path, error_prefix=''):
    
    try:
        module_path, class_name = dotted_path.rsplit('.', 1)
    except ValueError:
        raise ImproperlyConfigured("%s%s doesn't look like a module path" % (
            error_prefix, dotted_path))
    try:
        module = import_module(module_path)
    except ImportError as e:
        raise ImproperlyConfigured('%sError importing module %s: "%s"' % (
            error_prefix, module_path, e))
    try:
        attr = getattr(module, class_name)
    except AttributeError:
        raise ImproperlyConfigured(
            '%sModule "%s" does not define a "%s" attribute/class' % (
                error_prefix, module_path, class_name
            )
        )
    return attr
1081372
def load_plugins_dir(path, category=None, overwrite=False):
    
    # get potential plugin python files
    if hasattr(path, 'glob'):
        pypaths = path.glob('*.py')
    else:
        pypaths = glob.glob(os.path.join(path, '*.py'))

    load_errors = []
    for pypath in pypaths:
        # use uuid to ensure no conflicts in name space
        mod_name = str(uuid.uuid4())
        try:
            if hasattr(pypath, 'resolve'):
                # Make the path absolute, resolving any symlinks
                pypath = pypath.resolve()

            with warnings.catch_warnings(record=True):
                warnings.filterwarnings("ignore", category=ImportWarning)

                # for MockPaths
                if hasattr(pypath, 'maketemp'):
                    with pypath.maketemp() as f:
                        module = load_source(mod_name, f.name)
                else:
                    module = load_source(mod_name, str(pypath))

        except Exception as err:
            load_errors.append((str(pypath), 'Load Error: {}'.format(err)))
            continue

        # only get classes that are local to the module
        class_members = inspect.getmembers(module, inspect.isclass)
        classes = [klass for klass_name, klass in class_members if
                   klass.__module__ == mod_name]
        load_errors += load_plugin_classes(classes, category, overwrite)

    return load_errors
933356
def from_path(cls, path):
        
        name = path.name[:-3]
        with logs.debug_time(u'Importing rule: {};'.format(name)):
            rule_module = load_source(name, str(path))
            priority = getattr(rule_module, 'priority', DEFAULT_PRIORITY)
        return cls(name, rule_module.match,
                   rule_module.get_new_command,
                   getattr(rule_module, 'enabled_by_default', True),
                   getattr(rule_module, 'side_effect', None),
                   settings.priority.get(name, priority),
                   getattr(rule_module, 'requires_output', True))
133280
def load(config_path: str):
    
    # we bind the config to _ to keep it alive
    if os.path.splitext(config_path)[1] in ('.yaml', '.yml'):
        _ = load_yaml_configuration(config_path, translator=PipelineTranslator())
    elif os.path.splitext(config_path)[1] == '.py':
        _ = load_python_configuration(config_path)
    else:
        raise ValueError('Unknown configuration extension: %r' % os.path.splitext(config_path)[1])
    yield
1049112
def _run_resources_file(path, stack):
    
    import imp, sys, random, string, copy
    class ContextImporter(object):
        def find_module(self, fullname, path=None):
            if fullname == '_context':
                self.path = path
                return self
            return None
        def load_module(self, name):
            mod = imp.new_module("_context")
            mod.stack = stack
            return mod
    # Temporarily add the context importer into the meta path
    old_meta_path = copy.copy(sys.meta_path)
    old_path = copy.copy(sys.path)
    # Save the modules list, in order to remove modules loaded after this point
    old_sys_modules = sys.modules.keys()
    # Run the module
    # Prepare import environment
    abspath = os.path.abspath(path)
    sys.meta_path.append(ContextImporter())
    sys.path.append(os.path.dirname(abspath))   # Enable importing files within module's folder
    # Perform the importing
    srcf = open(abspath, "r")
    module_name = ''.join(random.choice(string.digits + string.lowercase) for i in range(16))
    srcmodule = imp.load_source("cloudcast._template_" + module_name, abspath, srcf)
    srcf.close()
    # Restore meta path, modules list and return module
    sys.meta_path = old_meta_path
    sys.path = old_path
    for modname in sys.modules.keys():
        if not modname in old_sys_modules:
            del sys.modules[modname]
    return srcmodule
168347
def load_manifest(self, path):
        
        manifest_path = os.path.join(path, "plugin.json")
        self._logger.debug("Attempting to load plugin manifest from {}.".format(manifest_path))
        try:
            with open(manifest_path) as f:
                manifest = json.load(f)
            manifest["path"] = path
            self._manifests.append(manifest)
            self._logger.debug("Loaded plugin manifest from {}.".format(manifest_path))
        except ValueError:
            self._logger.error("Failed to decode plugin manifest at {}.".format(manifest_path))
        except (OSError, IOError) as e:
            self._logger.error("Failed to load plugin manifest at {}.".format(manifest_path))
869792
def _get_from_path(import_path):
    # type: (str) -> Callable
    
    module_name, obj_name = import_path.rsplit('.', 1)
    module = import_module(module_name)
    return getattr(module, obj_name)
269703
def load_class_by_path(taskpath):
    

    return getattr(
        importlib.import_module(
            re.sub(
                r"\.[^.]+$",
                "",
                taskpath)),
        re.sub(
            r"^.*\.",
            "",
            taskpath))
329210
def load(self, path):
        
        with open(path) as f:
            self.config = full_load(f)
            if self.config is None:
                sys.stderr.write("Warning: config file is empty!\n")
                self.config = {}
870935
def install_hook(path):
    
    git = op.join(path, '.git', 'hooks')
    hg = op.join(path, '.hg')
    if op.exists(git):
        install_git(git)
        LOGGER.warn('Git hook has been installed.')

    elif op.exists(hg):
        install_hg(hg)
        LOGGER.warn('Mercurial hook has been installed.')

    else:
        LOGGER.error('VCS has not found. Check your path.')
        sys.exit(1)
1137939
def register_prefix(self, path):
        
        if path not in self._prefixes:
            LOG.debug('%r: registering prefix %r', self, path)
            self._prefixes.add(path)
316097
def load_config(path)
      return unless File.exist?(path)
      buf = File.read(path) 
      eval("#{buf}", binding, path)
    end