Parse a raw yaml formatted stacker config.

    Args:
        raw_config (str): the raw stacker configuration string in yaml format.

    Returns:
        :class:`Config`: the parsed stacker config.
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)
600952
def read_raw_parser_conf(data: str) -> dict:
    
    config = configparser.ConfigParser(allow_no_value=True)
    config.read_string(data)
    try:
        _data: dict = dict(config["commitizen"])
        if "files" in _data:
            files = _data["files"]
            _f = json.loads(files)
            _data.update({"files": _f})

        return _data

    except KeyError:
        return {}
1230906
def do_raw_get_config(self, line):
        

        def f(p, args):
            try:
                source = args[0]
            except:
                print("argument error")
                return
            result = p.raw_get_config(source)
            tree = ET.fromstring(result)
            validate(tree)
            print(et_tostring_pp(tree))

        self._request(line, f)
370791
def _get_config():
    
    conf_file = os.path.join(_get_config_dir(), 'log_config.toml')
    if os.path.exists(conf_file):
        with open(conf_file) as fd:
            raw_config = fd.read()
        log_config = toml.loads(raw_config)
        return log_config

    conf_file = os.path.join(_get_config_dir(), 'log_config.yaml')
    if os.path.exists(conf_file):
        with open(conf_file) as fd:
            raw_config = fd.read()
        log_config = yaml.safe_load(raw_config)
        return log_config

    return None
726580
def get_raw_default_config_and_read_file_list():
    """"""
    global _CONFIG, _READ_DEFAULT_FILES
    if _CONFIG is not None:
        return _CONFIG, _READ_DEFAULT_FILES
    with _CONFIG_LOCK:
        if _CONFIG is not None:
            return _CONFIG, _READ_DEFAULT_FILES
        try:
            # noinspection PyCompatibility
            from ConfigParser import SafeConfigParser
        except ImportError:
            # noinspection PyCompatibility,PyUnresolvedReferences
            from configparser import ConfigParser as SafeConfigParser  # pylint: disable=F0401
        cfg = SafeConfigParser()
        read_files = cfg.read(get_default_config_filename())
        _CONFIG, _READ_DEFAULT_FILES = cfg, read_files
        return _CONFIG, _READ_DEFAULT_FILES
954473
def parse_config_list(config_list):
  
  if config_list is None:
    return {}
  else:
    mapping = {}
    for pair in config_list:
      if (constants.CONFIG_SEPARATOR not in pair) or (pair.count(constants.CONFIG_SEPARATOR) != 1):
        raise ValueError("configs must be passed as two strings separted by a %s", constants.CONFIG_SEPARATOR)
      (config, value) = pair.split(constants.CONFIG_SEPARATOR)
      mapping[config] = value
    return mapping
975488
def _parse_config(self):
        
        config = self.get_block('mlag configuration')
        cfg = dict()
        cfg.update(self._parse_domain_id(config))
        cfg.update(self._parse_local_interface(config))
        cfg.update(self._parse_peer_address(config))
        cfg.update(self._parse_peer_link(config))
        cfg.update(self._parse_shutdown(config))
        return dict(config=cfg)
1362789
def get_parser(cfg_file=cfg_file):
    
    if not os.path.exists(cfg_file):
        generate_configfile(cfg_file=cfg_file, defaults=defaults)
    config = ConfigParser.ConfigParser()
    config.read(cfg_file)
    return config
1263490
def load_config(self):
        
        self.__config = {}

        # Parse sections, its options and put it in self.config.
        for section in self.sections:

            self.__config[section] = {}
            options = self.parser.options(section)

            # Parse options of each section
            for option in options:

                try:
                    opt = self.parser \
                        .get(section, option)
                    try:
                        self.__config[section][option] = literal_eval(opt)
                    except (SyntaxError, ValueError):
                        self.__config[section][option] = opt
                        self.log_output.append(
                            {"level": "debug",
                             "msg": "Option not literal_eval-parsable"
                                    " (maybe string): [{0}] {1}"
                                 .format(section, option)})

                    if self.__config[section][option] == -1:
                        self.log_output.append(
                            {"level": "debug",
                             "msg": "Skipping: [%s] %s" % (section, option)}
                        )
                except ConfigParser.NoOptionError as exc:
                    self.log_output.append(
                        {"level": "error",
                         "msg": "Exception on [%s] %s: %s"
                                % (section, option, exc)}
                    )
                    self.__config[section][option] = None
787602
def create_build_configuration_set_raw(**kwargs):
    
    config_set = _create_build_config_set_object(**kwargs)
    response = utils.checked_api_call(pnc_api.build_group_configs, 'create_new', body=config_set)
    if response:
        return response.content
297668
def load_config():
    
    configuration = MyParser()
    configuration.read(_config)

    d = configuration.as_dict()

    if 'jira' not in d:
        raise custom_exceptions.NotConfigured

    # Special handling of the boolean for error reporting
    d['jira']['error_reporting'] = configuration.getboolean('jira', 'error_reporting')

    return d
1235760
def load_manifest(raw_manifest, namespace=None, **kwargs):
    
    if isinstance(raw_manifest, configparser.RawConfigParser):
        return Manifest(raw_manifest)

    manifest = create_configparser()

    if not manifest.has_section('config'):
        manifest.add_section('config')

    _load_manifest_interpret_source(manifest,
                                    raw_manifest,
                                    **kwargs)
    return Manifest(manifest, namespace=namespace)
1225478
def load(raw_bytes):
        
        try:
            return yaml.load(raw_bytes)
        except yaml.scanner.ScannerError as e:
            raise SerializationException(str(e))
1153551
def mqc_load_config(yaml_config):
    
    if os.path.isfile(yaml_config):
        try:
            with open(yaml_config) as f:
                new_config = yaml.safe_load(f)
                logger.debug("Loading config settings from: {}".format(yaml_config))
                mqc_add_config(new_config, yaml_config)
        except (IOError, AttributeError) as e:
            logger.debug("Config error: {}".format(e))
        except yaml.scanner.ScannerError as e:
            logger.error("Error parsing config YAML: {}".format(e))
            sys.exit(1)
    else:
        logger.debug("No MultiQC config found: {}".format(yaml_config))
181561
def load_config(configfile):
    
    try:
        with open(configfile, 'r') as ymlfile:
            try:
                config = yaml.load(ymlfile)
                return config
            except yaml.parser.ParserError:
                raise PyYAMLConfigError(
                    'Could not parse config file: {}'.format(configfile),
                )
    except IOError:
        raise PyYAMLConfigError(
            'Could not open config file: {}'.format(configfile),
        )
1196662
def _parse_config(self, config):
        
        self._batch_size = config['batch_size']
        self._im_height = config['im_height']
        self._im_width = config['im_width']
        self._num_channels = config['channels']
        self._output_layer = config['out_layer']
        self._feature_layer = config['feature_layer']
        self._out_size = None
        if 'out_size' in config.keys():
            self._out_size = config['out_size']
        self._input_arr = np.zeros([self._batch_size, self._im_height,
                                    self._im_width, self._num_channels])

        if self._model_dir is None:
            self._net_data = np.load(config['caffe_weights']).item()
            self._mean = np.load(config['mean_file'])
            self._model_filename = None
        else:
            self._net_data = None
            self._mean = np.load(os.path.join(self._model_dir, 'mean.npy'))
            self._model_filename = os.path.join(self._model_dir, 'model.ckpt')
1259346
def raw_value(self) -> typing.Optional[object]:
        
        raw_value = self._from_environ()
        if raw_value is None:
            raw_value = self._from_config_file()
        if raw_value is None:
            raw_value = self._from_default()
        return raw_value