Applies changes from a YAML file to configuration

    :param data: configuration datastructure
    :param filename: name of the YAML file, - is taken to mean standard input
    :returns tuple of human readable and parsed datastructure after changes
167283
def apply_yaml_file(data, filename):
    
    changed_data = copy.deepcopy(data)

    if filename == '-':
        new_options = yaml.safe_load(sys.stdin)
    else:
        with open(filename) as fd:
            new_options = yaml.safe_load(fd)

    patch_config(changed_data, new_options)

    return format_config_for_editing(changed_data), changed_data
102711
def load_configuration(yaml: yaml.ruamel.yaml.YAML, filename: str) -> DictLike:
    
    with open(filename, "r") as f:
        config = yaml.load(f)

    return config
41753
def parse_yaml(self, y):
        '''

        '''
        self.name = y['name']
        if 'data' in y:
            self.data = y['data']
        else:
            self.data = ''
        return self
1352171
def parse_config_file
      unless file? config_file
        logger.debug "Configuration file not found: #{config_file}"
        return {}
      end

      logger.debug "Reading configuration file: #{config_file}."
      symbolise YAML.load_file(config_file)
    rescue StandardError => error
      raise CONFIG_FILE_ERROR.new(config_file, error)
    end
400656
def load(self, filename):
        
        # print ("LOAD CONFIGDICT", filename)

        self.data = BaseConfigDict(filename=Config.path_expand(filename))
        try:
            version = str(self.data["meta"]["version"])
            if version not in self.versions:
                Console.error("The yaml file version must be {}".format(
                    ', '.join(self.versions)))
                sys.exit(1)
        except Exception as e:
            Console.error(
                "Your yaml file ~/.cloudmesh/cloudmesh.yaml is not up to date.",
                traceflag=False)
            Console.error(e.message, traceflag=False)
            sys.exit(1)
1011209
def add_file(self, path, yaml):
        

        if is_job_config(yaml):
            name = self.get_job_name(yaml)

            file_data = FileData(path=path, yaml=yaml)
            self.files[path] = file_data
            self.jobs[name] = file_data
        else:
            self.files[path] = FileData(path=path, yaml=yaml)
1000196
def configToJson(self, fileName):
        
        config = self.getConfig()
        with open(fileName, "w") as outfile:
            dump(config, outfile, indent=4, sort_keys=True)
982519
def _get_config(filename):
    
    i = interpolation.Interpolator(interpolation.TemplateWithDefaults,
                                   os.environ)

    with open(filename, 'r') as stream:
        try:
            interpolated_config = i.interpolate(stream.read())
            return yaml.safe_load(interpolated_config)
        except yaml.parser.ParserError as e:
            msg = 'Error parsing gilt config: {0}'.format(e)
            raise ParseError(msg)
841562
def load(cls, filename, name=None):
        
        if not os.path.exists(filename):
            return {}
        name = name or filename

        if name not in cls._conffiles:
            with open(filename) as fdesc:
                content = yaml.load(fdesc, YAMLLoader)
                # in case the file is empty
                if content is None:
                    content = {}
                cls._conffiles[name] = content

        return cls._conffiles[name]
207409
function yamlTransform (filename) {
  if (!/\.yml|\.yaml$/i.test(filename)) {
    return through()
  }

  return through(function (buf, enc, next) {
    this.push(
      'module.exports=' + JSON.stringify(YAML.parse(buf.toString('utf8')))
    )
    next()
  })
}
371564
def merge_config_files(fnames):
    
    def _load_yaml(fname):
        with open(fname) as in_handle:
            config = yaml.safe_load(in_handle)
        return config
    out = _load_yaml(fnames[0])
    for fname in fnames[1:]:
        cur = _load_yaml(fname)
        for k, v in cur.items():
            if k in out and isinstance(out[k], dict):
                out[k].update(v)
            else:
                out[k] = v
    return out
586647
def load(self):
        
        data = self.dict_class()
        
        for path in self.paths:
            if path in self.paths_loaded: continue
            
            try:
                with open(path, 'r') as file:
                    path_data = yaml.load(file.read())
                    data = dict_merge(data, path_data)
                self.paths_loaded.add(path)
            except IOError:
                # TODO: Log this correctly once logging is implemented
                if not path.endswith('.local.yml'):
                    print 'CONFIG NOT FOUND: %s' % (path)

        self.data = data
949918
public function read(string $filename = null, string $data = null): Interfaces\Yaml
    {
        try {
            $yaml = !empty($data)
                ? Import::fromData($data)
                : Import::fromFile($filename);

            $this->set($yaml);

        } catch (YamlException $e) {
            !$this->_strict ?: die();
        }

        return $this;
    }
896854
def read_yaml(self, filename):
        '''
        
        '''
        with open(filename, 'r') as f:
            d = re.sub(r'\{\{ *([^ ]+) *\}\}', r'\1', f.read())
            y = yaml.safe_load(d)
            return y if y else {}
486221
def cfg_from_file(self, yaml_filename, config_dict):
        """"""
        import yaml
        from easydict import EasyDict as edict
        with open(yaml_filename, 'r') as f:
            yaml_cfg = edict(yaml.load(f))

        return self._merge_a_into_b(yaml_cfg, config_dict)
1103016
def set_from_file(file_name):
    
    if type(file_name) != str:
        raise TypeError('file_name must be str')
    global _config_file_name
    _config_file_name = file_name
    # Try to open the file and get the json data into a dictionary
    with open(file_name, "r") as file:
        data = yaml.load(file)
    # each value found will overwrite the same value in the config
    _list_merge(data, _config)
974696
def yaml_encode(data):
    '''
    
    '''
    yrepr = yaml.representer.SafeRepresenter()
    ynode = yrepr.represent_data(data)
    if not isinstance(ynode, yaml.ScalarNode):
        raise TypeError(
            "yaml_encode() only works with YAML scalar data;"
            " failed for {0}".format(type(data))
        )

    tag = ynode.tag.rsplit(':', 1)[-1]
    ret = ynode.value

    if tag == "str":
        ret = yaml_dquote(ynode.value)

    return ret