Convert _config_dict_ into a list of INI formatted strings.

    Args:
        config_dict (dict): Configuration dictionary to be flattened.

    Returns:
        (list) Lines to be written to a file in the format of KEY1_KEY2=value.
174545
def convert_ini(config_dict):
    
    config_lines = []

    for env, configs in sorted(config_dict.items()):
        for resource, app_properties in sorted(configs.items()):
            try:
                for app_property, value in sorted(app_properties.items()):
                    variable = '{env}_{resource}_{app_property}'.format(
                        env=env, resource=resource, app_property=app_property).upper()

                    if isinstance(value, (dict, DeepChainMap)):
                        safe_value = "'{0}'".format(json.dumps(dict(value)))
                    else:
                        safe_value = json.dumps(value)

                    line = "{variable}={value}".format(variable=variable, value=safe_value)

                    LOG.debug('INI line: %s', line)
                    config_lines.append(line)
            except AttributeError:
                resource = resource.upper()
                app_properties = "'{}'".format(json.dumps(app_properties))
                line = '{0}={1}'.format(resource, app_properties)

                LOG.debug('INI line: %s', line)
                config_lines.append(line)
    return config_lines
21395
def _config_parser_to_defaultdict(config_parser):
    
    config = defaultdict(defaultdict)
    for section, section_content in config_parser.items():
        if section != 'DEFAULT':
            for option, option_value in section_content.items():
                config[section][option] = option_value
    return config
1243304
def config():
    # type: () -> dict[str, Any]
    
    out = shell.run(
        'git config --list',
        capture=True,
        never_pretend=True
    ).stdout.strip()

    result = {}
    for line in out.splitlines():
        name, value = line.split('=', 1)
        result[name.strip()] = value.strip()

    return result
170810
def config_keys(self, sortkey = False):
        
        if sortkey:
            items = sorted(self.items())
        else:
            items = self.items()
        for k,v in items:
            if isinstance(v, ConfigTree):
                for k2 in v.config_keys(sortkey):
                    yield k + '.' + k2
            else:
                yield k
933299
def _sift_and_init_configs(self, input_dict):
        
        configs = {}
        for k, v in iteritems(input_dict):
            if (k not in map(str.lower, self.format_order) and
                    any([f_order.lower() in k for f_order in self.format_order])):
                try:
                    self.CFG.get(self.CONFIG_PATH + [k])
                except errors.ResourceNotFoundError:
                    pass
                finally:
                    configs[k] = v

        for key, val in iteritems(configs):
            input_dict.pop(key, None)
        if configs:
            self.initialize_overall_config_settings(input_dict=configs)
109404
def write_out_config(self, config_file):
        
        with open(config_file, 'w') as f:
            json.dump(self.params, f, indent=2,
                      separators=(',', ': '))
1098336
def dump_dict(cfg, f, indent=0):
    ''''''

    for key in cfg:
        if not isstr(key):
            raise ConfigSerializeError("Dict keys must be strings: %r" %
                                       (key,))
        dump_value(key, cfg[key], f, indent)
        f.write(u';\n')
974997
def parse(raw_config):
    

    # Convert any applicable dictionaries back into lists
    # This is necessary due to the move from lists for these top level config
    # values to either lists or OrderedDicts.
    # Eventually we should probably just make them OrderedDicts only.
    config_dict = yaml_to_ordered_dict(raw_config)
    if config_dict:
        for top_level_key in ['stacks', 'pre_build', 'post_build',
                              'pre_destroy', 'post_destroy']:
            top_level_value = config_dict.get(top_level_key)
            if isinstance(top_level_value, dict):
                tmp_list = []
                for key, value in top_level_value.items():
                    tmp_dict = copy.deepcopy(value)
                    if top_level_key == 'stacks':
                        tmp_dict['name'] = key
                    tmp_list.append(tmp_dict)
                config_dict[top_level_key] = tmp_list

    # Top-level excess keys are removed by Config._convert, so enabling strict
    # mode is fine here.
    try:
        return Config(config_dict, strict=True)
    except SchematicsError as e:
        raise exceptions.InvalidConfig(e.errors)
345919
def configuration_to_dict(handlers):
    
    config_dict = defaultdict(dict)

    for handler in handlers:
        for option in handler.set_options:
            value = _get_option(handler.target_obj, option)
            config_dict[handler.section_prefix][option] = value

    return config_dict
1292045
def read_config(config):
    
    for line in config.splitlines():
        line = line.lstrip()
        if line and not line.startswith("#"):
            return line
    return ""
614254
def str2dict_keys(str_in):
    '''
    
    '''
    tmp_dict = str2dict(str_in)
    if tmp_dict is None:
        return None
    return sorted([k for k in tmp_dict])
1154693
def get_config(self):
        
        # Fill this dict with config data
        return {
            'hash_name': self.hash_name,
            'dim': self.dim,
            'bin_width': self.bin_width,
            'projection_count': self.projection_count,
            'normals': self.normals
        }
235221
def config_to_string(config):
    
    output = []
    for section, section_content in config.items():
        output.append("[{}]".format(section))
        for option, option_value in section_content.items():
            output.append("{} = {}".format(option, option_value))
    return "\n".join(output)
1031882
def config(settings):
    
    parameter_settings = Parameter()
    for k, v in settings.items():
        if isinstance(v, OrderedDict):
            k_settings = Parameter()
            for ki, vi in v.items():
                k_settings[ki] = vi
        else:
            k_settings = v
        parameter_settings[k] = k_settings

    return parameter_settings
788730
def as_dict(self, use_preliminary=False):
        
        config = dict()
        for key in self.config.keys:
            if use_preliminary and key in self.preliminary_config:
                value = self.preliminary_config[key]
            else:
                value = self.config.get_config_value(key)
            config[key] = value
        return config
701617
def dict_conf(filename):
  

  f, ext = os.path.splitext(filename)
  ext = ext.lower()

  if ext == "conf" or ext == "ini":
    # python config via config parser

    config = ConfigParser()
    config.optionxform=str
    config.read(filename)
    rv = {}
    for section in config.sections():
      rv[section] = {}
      for key,value in config.items(section):
        rv[section][key] = value.strip('"').strip("'").decode("string_escape")
    return rv
  else:
    # other type of config, use munge
    if munge_config:
      src = munge_config.parse_url(filename)
      return src.cls().load(open(filename)).get("vodka")
    else:
      raise Exception("'%s' type of config encountered, install munge" % ext)
1258049
def _get_config_dict_from_file(config_path=None):
    
    if config_path is None:
        config_path = DEFAULT_CONFIG_PATH

    # Default (empty) content will be used if config file does not exist.
    config_content = {}

    # If the config file exists we use that content.
    if os.path.isfile(config_path):
        with open(config_path) as fh:
            config_content = json.load(fh)

    return config_content