Builds a configuration reader function
971028
def _read_options(paths,fname_def=None):
    """"""
    def reader_func(fname=fname_def, sect=None, sett=None, default=None):
        """Reads the configuration for trump"""

        cur_dir = os.path.dirname(os.path.realpath(__file__))
        config_dir = os.path.join(cur_dir, *paths)

        config_files = [(f[:-4], f)
                        for f in os.listdir(config_dir) if f[-4:] == ".cfg"]
        sample_files = [(f[:-11], f)
                        for f in os.listdir(config_dir) if f[-11:] == ".cfg_sample"]

        if fname:
            config_files = [f for f in config_files if f[0] == fname]
            sample_files = [f for f in sample_files if f[0] == fname]


        config_files = dict(config_files)
        sample_files = dict(sample_files)

        cfg_files = sample_files
        for fn, f in config_files.iteritems():
            cfg_files[fn] = f

        sample_files_exposed = []

        confg = {}

        for src, fil in cfg_files.iteritems():
            confg[src] = {}
            cfpr = ConfigParser.ConfigParser()
            cfpr.read(os.path.join(config_dir, fil))
            for sec in cfpr.sections():
                confg[src][sec] = dict(cfpr.items(sec))

            if ".cfg_sample" in fil:
                sample_files_exposed.append(fil)


        if len(sample_files_exposed) > 0:
            msg = ", ".join(sample_files_exposed)
            body = "{} sample configuration files have been exposed. " \
                  "Rename *.cfg_sample to *.cfg, and populate the " \
                  "correct settings in the config and settings " \
                  "directories to avoid this warning."
            msg = body.format(msg)
            warnings.warn(msg)

        keys = []

        if fname:
            keys.append(fname)
            if sect:
                keys.append(sect)
                if sett:
                    keys.append(sett)
        try:
            return get_from_nested(keys, confg)
        except KeyError:
            if default is not None:
                return default
            else:
                raise

    return reader_func
1078270
def read(self, config_dir=None, config_name=None, clear=False):
        

# TODO should probably allow config_dir to be a list as well
        # get name of config directory
        if not config_dir:
            config_dir = self._defaults.get('config_dir', None)
        if not config_dir:
            raise KeyError('config_dir not set')

        # get name of config file
        if not config_name:
            config_name = self._defaults.get('config_name', None)
        if not config_name:
            raise KeyError('config_name not set')

        conf_path = os.path.expanduser(config_dir)
        if not os.path.exists(conf_path):
            raise IOError("config dir not found at %s" % (conf_path,))

        config = munge.load_datafile(config_name, conf_path, default=None)

        if not config:
            raise IOError("config file not found in %s" % (conf_path,))

        if clear:
            self.clear()

        munge.util.recursive_update(self.data, config)
        self._meta_config_dir = conf_path
        return self
439311
def config_collection_for_built(self, throw_error=True,silent=False):
		
		shutit_global.shutit_global_object.yield_to_draw()
		self.log('In config_collection_for_built',level=logging.DEBUG)
		cfg = self.cfg
		for module_id in self.module_ids():
			# Get the config even if installed or building (may be needed in other hooks, eg test).
			if (self.is_to_be_built_or_is_installed(self.shutit_map[module_id]) and
				not self.shutit_map[module_id].get_config(self)):
				self.fail(module_id + ' failed on get_config') # pragma: no cover
			# Collect the build.cfg if we are building here.
			# If this file exists, process it.
			if cfg[module_id]['shutit.core.module.build'] and not self.build['have_read_config_file']:
				# TODO: __module_file not accessible when within object - look to get this elsewhere and re-read in, then move this function into shutit object.
				cfg_file = os.path.dirname(self.shutit_file_map[module_id]) + '/configs/build.cnf'
				if os.path.isfile(cfg_file):
					self.build['have_read_config_file'] = True
					# use self.get_config, forcing the passed-in default
					config_parser = ConfigParser.ConfigParser()
					config_parser.read(cfg_file)
					for section in config_parser.sections():
						if section == module_id:
							for option in config_parser.options(section):
								override = False
								for mod, opt, val in self.build['config_overrides']:
									val = val # pylint
									# skip overrides
									if mod == module_id and opt == option:
										override = True
								if override:
									continue
								is_bool = isinstance(cfg[module_id][option], bool)
								if is_bool:
									value = config_parser.getboolean(section,option)
								else:
									value = config_parser.get(section,option)
								if option == 'shutit.core.module.allowed_images':
									value = json.loads(value)
								self.get_config(module_id, option, value, forceask=True)
		# Check the allowed_images against the base_image
		passed = True
		for module_id in self.module_ids():
			if (cfg[module_id]['shutit.core.module.build'] and
			   (cfg[module_id]['shutit.core.module.allowed_images'] and
			    self.target['docker_image'] not in cfg[module_id]['shutit.core.module.allowed_images'])):
				if not self.allowed_image(module_id):
					passed = False
					if not silent:
						shutit_global.shutit_global_object.shutit_print('\n\nWARNING!\n\nAllowed images for ' + module_id + ' are: ' + str(cfg[module_id]['shutit.core.module.allowed_images']) + ' but the configured image is: ' + self.target['docker_image'] + '\n\nIs your shutit_module_path set correctly?\n\nIf you want to ignore this, pass in the --ignoreimage flag to shutit.\n\n')
		if not passed:
			if not throw_error:
				return False
			if self.build['imageerrorok']:
				# useful for test scripts
				shutit_global.shutit_global_object.shutit_print('Exiting on allowed images error, with return status 0')
				shutit_global.shutit_global_object.handle_exit(exit_code=1)
			else:
				raise ShutItFailException('Allowed images checking failed') # pragma: no cover
		return True
1127042
function readConfigs() {
    const configsRoot = path.resolve(__dirname, "../../lib/configs")
    const result = fs.readdirSync(configsRoot)
    const configs = []
    for (const name of result) {
        const configName = name.replace(/\.js$/u, "")
        const configId = `plugin:lodash-template/${configName}`
        const configPath = require.resolve(path.join(configsRoot, name))

        const config = require(configPath)
        configs.push({
            name: configName,
            configId,
            config,
            path: configPath,
        })
    }
    return configs
}
974658
def get_config(filename, *search_dirs, **kwargs):
    """"""
    config = kwargs.get("config_reader_class", configparser.ConfigParser)()

    paths = config_search_paths(filename, *search_dirs)
    successes = config.read(reversed(paths))
    if successes:
        LOG.debug("Read config from %s", str(successes))
        return config, successes

    LOG.warning("Couldn't file any config file matching %s", filename)
    return None, []
865405
def config_load(ctx, param, value):
    """"""
    if ctx.obj is None:
        ctx.obj = {}

    ctx.obj['config_path'] = value
    ctx.obj['config'] = read_config(value)
    return value
30038
def read_writer_config(config_files, loader=UnsafeLoader):
    """"""

    conf = {}
    LOG.debug('Reading %s', str(config_files))
    for config_file in config_files:
        with open(config_file) as fd:
            conf.update(yaml.load(fd.read(), Loader=loader))

    try:
        writer_info = conf['writer']
    except KeyError:
        raise KeyError(
            "Malformed config file {}: missing writer 'writer'".format(
                config_files))
    writer_info['config_files'] = config_files
    return writer_info
627196
def read_config(conf_dir=DEFAULT_CONFIG_DIR):
    ""

    conf_path = os.path.expanduser(conf_dir)
    if not os.path.exists(conf_path):
        # only throw if not default
        if conf_dir != DEFAULT_CONFIG_DIR:
            raise IOError("Config directory not found at %s" % (conf_path, ))

    return munge.load_datafile('config', conf_path, default=None)
1170859
def run_configurations(callback, sections_reader):
    """"""
    base = dict(OPTIONS)
    sections = sections_reader()
    if sections is None:
        logger.info("Configuration not found in .ini files. "
                    "Running with default settings")
        recompile()
    elif sections == []:
        logger.info("Configuration does not match current runtime. "
                    "Exiting")
    results = []
    for section, options in sections:
        OPTIONS.clear()
        OPTIONS.update(base)
        OPTIONS.update(options)
        logger.debug("Running configuration from section \"%s\". OPTIONS: %r",
                     section, OPTIONS)
        results.append(callback())
    return results
1197080
def parser():

    """"""

    parser = argparse.ArgumentParser()
    parser.add_argument('-c', '--config_paths', default=[], action='append',
                        help='path to a configuration directory')
    return parser
192450
function buildConfig (_config) {
  _config.datastore = Object.assign({}, defaultDatastore, _get(_config, 'datastore', {}))

  return _config
}
1310558
def build_config(config_file=get_system_config_directory()):
    
    config = Config(config_file, allow_no_value=True)
    application_versions = find_applications_on_system()

    # Add found versions to config if they don't exist. Versions found
    # in the config file takes precedence over versions found in PATH.
    for item in application_versions.iteritems():
        if not config.has_option(Config.EXECUTABLES, item[0]):
            config.set(Config.EXECUTABLES, item[0], item[1])
    return config
449429
def _read_config(cls):
        

        cls._config_parser = configparser.ConfigParser()
        cls._config_parser.read(cls._default_attribute_values_configuration_file_path)
114966
public Reader create(Reader input, String configuration, String defaultConfiguration) throws IOException {
    if(defaultConfiguration==null) {
      defaultConfiguration = defaultArgument;
    }
    if (configs != null && configs.size() > 0) {
      if (configuration == null && defaultConfiguration == null) {
        throw new IOException("no (default)configuration");
      } else if (configuration == null) {
        if (configs.get(defaultConfiguration) != null) {
          return create(input, configs.get(defaultConfiguration));
        } else {
          throw new IOException(
              "default configuration " + defaultConfiguration + " not available");
        }
      } else {
        MtasConfiguration config = configs.get(configuration);
        if (config == null) {
          if (defaultConfiguration != null) {
            if (configs.get(defaultConfiguration) != null) {
              return create(input, configs.get(defaultConfiguration));
            } else {
              throw new IOException("configuration " + configuration
                  + " not found and default configuration " + defaultConfiguration
                  + " not available");
            }
          } else {
            throw new IOException("configuration " + configuration
                + " not available and no default configuration");
          }
        } else {
          return create(input, config);
        }
      }
    } else if (config != null) {
      return create(input, config);
    } else {
      throw new IOException("no configuration");
    }

  }
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)
381355
public final static String process(final Reader reader, final Decorator decorator) throws IOException
    {
        return process(reader, Configuration.builder().setDecorator(decorator).build());
    }
918875
public static ConfigDocument parseReader(Reader reader, ConfigParseOptions options) {
        return Parseable.newReader(reader, options).parseConfigDocument();
    }