Reads, parses and creates plugins specified in config.yaml.
503814
def _load_plugins(self):
        
        plugins = ait.config.get('server.plugins')

        if plugins is None:
            log.warn('No plugins specified in config.')
        else:
            for index, p in enumerate(plugins):
                try:
                    plugin = self._create_plugin(p['plugin'])
                    self.plugins.append(plugin)
                    log.info('Added plugin {}'.format(plugin))

                except Exception:
                    exc_type, value, tb = sys.exc_info()
                    log.error('{} creating plugin {}: {}'.format(exc_type,
                                                                 index,
                                                                 value))
            if not self.plugins:
                log.warn('No valid plugin configurations found. No plugins will be added.')
233788
function loadYAMLConfig(configPath) {
  try {
    return safeLoad(readFileSync(configPath, 'utf8'))
  } catch (e) {
    if (e.constructor.name === 'YAMLException') {
      throw e
    }
    log.error({
      message: chalk.red(`Unable to find YML config at "${configPath}".`),
      ref: 'unable-to-find-config',
    })
    return undefined
  }
}
536446
def _load_yaml_config(self):
        
        try:
            config = self._read_config()
        except OSError as error:
            raise ValueError('Could not read configuration file: %s' % error)
        try:
            return yaml.safe_load(config)
        except yaml.YAMLError as error:
            message = '\n'.join(['    > %s' % line
                                 for line in str(error).split('\n')])
            sys.stderr.write('\n\n  Error in the configuration file:\n\n'
                             '{}\n\n'.format(message))
            sys.stderr.write('  Configuration should be a valid YAML file.\n')
            sys.stderr.write('  YAML format validation available at '
                             'http://yamllint.com\n')
            raise ValueError(error)
942894
def create_app_from_yml(path):
    """"""

    try:
        with open(path, "rt", encoding="UTF-8") as f:
            try:
                # Substitute ALL occurrences of '%(here)s' with a path to a
                # directory with '.holocron.yml'. Please note, we also want
                # wrap the result into 'io.StringIO' in order to preserve
                # original filename in 'yaml.safe_load()' errors.
                interpolated = io.StringIO(f.read() % {
                    "here": os.path.abspath(os.path.dirname(path))})
                interpolated.name = f.name

                conf = yaml.safe_load(interpolated)
            except yaml.YAMLError as exc:
                raise RuntimeError(
                    "Cannot parse a configuration file. Context: " + str(exc))

    except FileNotFoundError:
        conf = {"metadata": None, "pipes": {}}

    return core.create_app(conf["metadata"], pipes=conf["pipes"])
809633
def get_config(config_file):
    """"""
    def load(fp):
        try:
            return yaml.safe_load(fp)
        except yaml.YAMLError as e:
            sys.stderr.write(text_type(e))
            sys.exit(1)  # TODO document exit codes

    if config_file == '-':
        return load(sys.stdin)
    if not os.path.exists(config_file):
        sys.stderr.write('ERROR: Must either run next to config.yaml or'
            ' specify a config file.\n' + __doc__)
        sys.exit(2)
    with open(config_file) as fp:
        return load(fp)
14994
def load_configuration(conf_path):
    
    with open(conf_path) as f:
        conf_dict = yaml.load(f)
    validate_config(conf_dict)
    return conf_dict
1110620
def configuration(self, plugin):
        
        conf = self.config.get(plugin, "default;").split(';')
        if len(conf) == 1:
            conf.append('')
        return tuple(conf)
1128325
def parse_config(config_file):
    """"""
    try:
        with open(config_file, 'r') as f:
            return yaml.load(f)
    except IOError:
        print "Configuration file {} not found or not readable.".format(config_file)
        raise
65179
def _parse_yaml_config(config_data=None):
    
    data_map = default_config()

    # If we were given config data to use, use it.  Otherwise, see if there is
    # a furious.yaml to read the config from.  Note that the empty string will
    # result in the default config being used.
    if config_data is None:
        config_data = _load_yaml_config()

    if not config_data:
        logging.debug("No custom furious config, using default config.")
        return data_map

    # TODO: validate the yaml contents
    config = yaml.safe_load(config_data)

    # If there was a valid custom config, it will be a dict.  Otherwise,
    # ignore it.
    if isinstance(config, dict):
        # Apply the custom config over the default config.  This allows us to
        # extend functionality without breaking old stuff.
        data_map.update(config)
    elif not None:
        raise InvalidYamlFile("The furious.yaml file "
                              "is invalid yaml")

    return data_map
639879
def _load_plugins(self):
        '''
        
        '''
        plugins = self.settings['PLUGINS']

        self.plugins_dict = {}
        for key in plugins:
            # skip loading the plugin if its value is None
            if plugins[key] is None:
                continue
            # valid plugin, import and setup
            self.logger.debug("Trying to load plugin {cls}".format(cls=key))
            the_class = self._import_class(key)
            instance = the_class()
            instance._set_logger(self.logger)
            if not self.unit_test:
                instance.setup(self.settings)
            the_schema = None
            with open(self.settings['PLUGIN_DIR'] + instance.schema) as the_file:
                the_schema = json.load(the_file)

            mini = {}
            mini['instance'] = instance
            mini['schema'] = the_schema
            self.logger.debug("Successfully loaded plugin {cls}".format(cls=key))
            self.plugins_dict[plugins[key]] = mini

        self.plugins_dict = OrderedDict(sorted(list(self.plugins_dict.items()),
                                               key=lambda t: t[0]))
537224
def _load(self, config):
        
        if isstring(config):
            self.filename = config
            params = yaml.load(open(config))
        elif isinstance(config, Config):
            # This is the copy constructor...
            self.filename = config.filename
            params = copy.deepcopy(config)
        elif isinstance(config, dict):
            params = copy.deepcopy(config)
        elif config is None:
            params = {}
        else:
            raise Exception('Unrecognized input')

        return params
185469
def from_file(cls, config_path=None, *args, **kwargs):
        

        config_reader = kaptan.Kaptan()

        config = {}

        if config_path:
            if not os.path.exists(config_path):
                raise exc.CihaiException(
                    '{0} does not exist.'.format(os.path.abspath(config_path))
                )
            if not any(
                config_path.endswith(ext) for ext in ('json', 'yml', 'yaml', 'ini')
            ):
                raise exc.CihaiException(
                    '{0} does not have a yaml,yml,json,ini extend.'.format(
                        os.path.abspath(config_path)
                    )
                )
            else:
                custom_config = config_reader.import_config(config_path).get()
                config = merge_dict(config, custom_config)

        return cls(config)
815864
def includeme(configurator):
    
    settings = configurator.registry.settings

    # lets default it to running path
    yaml_locations = settings.get('yaml.location',
                                  settings.get('yml.location', os.getcwd()))

    configurator.add_directive('config_defaults', config_defaults)

    configurator.config_defaults(yaml_locations)

    # reading yml configuration

    if configurator.registry['config']:
        config = configurator.registry['config']
        log.debug('Yaml config created')

        # extend settings object
        if 'configurator' in config and config.configurator:
            _extend_settings(settings, config.configurator)

        # run include's
        if 'include' in config:
            _run_includemes(configurator, config.include)

    # let's calla a convenience request method
    configurator.add_request_method(
        lambda request: request.registry['config'],
        name='config', property=True
    )
764485
def load_plugins(self, ):
        
        for p in self.__plugins.values():
            try:
                self.load_plugin(p)
            except errors.PluginInitError:
                log.exception('Initializing the plugin: %s failed.' % p)
921315
def load_writer_configs(writer_configs, ppp_config_dir,
                        **writer_kwargs):
    """"""
    try:
        writer_info = read_writer_config(writer_configs)
        writer_class = writer_info['writer']
    except (ValueError, KeyError, yaml.YAMLError):
        raise ValueError("Invalid writer configs: "
                         "'{}'".format(writer_configs))
    init_kwargs, kwargs = writer_class.separate_init_kwargs(writer_kwargs)
    writer = writer_class(ppp_config_dir=ppp_config_dir,
                          config_files=writer_configs,
                          **init_kwargs)
    return writer, kwargs
844088
def read_object_from_yaml(desired_type: Type[Any], file_object: TextIOBase, logger: Logger,
                          fix_imports: bool = True, errors: str = 'strict', *args, **kwargs) -> Any:
    
    return yaml.load(file_object)
157006
def load_config(cls, configfile="logging.yaml"):
        
        configfile = getenv(cls.CONFIGFILE_ENV_KEY, configfile)
        if isfile(configfile):
            with open(configfile, "r") as cf:
                # noinspection PyBroadException
                try:
                    dictConfig(load(cf))
                except ValueError:
                    debug("Learn to config foooo! Improper config at %s", configfile)
                except Exception:
                    exception("Something went wrong while reading %s.", configfile)
        else:
            raise ValueError("Invalid configfile specified: {}".format(configfile))