Adapter to dump/load YAML format strings and files.
        
        Returns:
            ConfigPersistenceAdapter
163272
def yaml(self):
        
        if self._yaml_adapter is None:
            self._yaml_adapter = ConfigPersistenceAdapter(
                config=self,
                reader_writer=YamlReaderWriter(),
            )
        return self._yaml_adapter
1359010
def dump_yaml(data, clean_up=False, long_form=False):
    

    return yaml.dump(
        data,
        Dumper=get_dumper(clean_up, long_form),
        default_flow_style=False,
        allow_unicode=True
    )
748604
def load_args(args):
    
    config = kaptan.Kaptan(handler='yaml')
    conf_parent = os.path.expanduser('~')
    conf_app = '.clancy'
    conf_filename = 'config.yaml'

    conf_dir = os.path.join(conf_parent, conf_app)
    for loc in [os.curdir, conf_dir]:
        configpath = os.path.join(loc, conf_filename)
        try:
            if os.path.isfile(configpath):
                config.import_config(configpath)
                break
        except (ValueError, ParserError, ScannerError):
            warn("Ignoring invalid valid yaml file {}".format(configpath))

    config = (config.configuration_data
              if config.configuration_data is not None else {})

    # Prepend '--' to conf file keys so it matches docopt. This is the dumbest
    # thing in the world.
    for key, val in config.items():
        config['--'+key] = val
        del config[key]

    return validate(merge(args, config))
14994
def load_configuration(conf_path):
    
    with open(conf_path) as f:
        conf_dict = yaml.load(f)
    validate_config(conf_dict)
    return conf_dict
10830
def load_configuration(path)
      config = YAML.load_file(path)

      unless config.kind_of?(Hash)
        raise(InvalidConfig,"DeploYML file #{path.dump} does not contain a Hash",caller)
      end

      return config
    end
859874
def load_config(filepath)
      return {} if filepath.nil? || !File.exist?(filepath)

      config_file = File.open(filepath).read

      # Replace environment variables
      config_file = parse_environment_variables(config_file)

      YAML.safe_load(config_file)
    end
1116842
public static void dumpYaml(Map conf, String file) {
        Yaml yaml = new Yaml();
        try {
            Writer writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
            yaml.dump(conf, writer);
        } catch (Exception ex) {
            LOG.error("Error:", ex);
        }
    }
1155519
def as_yaml(self):
        
        dumped = dump(self.as_marked_up(), Dumper=StrictYAMLDumper, allow_unicode=True)
        return dumped if sys.version_info[0] == 3 else dumped.decode("utf8")
980892
def _load_yaml_config(cls, config_data, filename="(unknown)"):
        """"""

        try:
            config = yaml.safe_load(config_data)
        except yaml.YAMLError as err:
            if hasattr(err, 'problem_mark'):
                mark = err.problem_mark
                errmsg = ("Invalid YAML syntax in Configuration file "
                          "%(file)s at line: %(line)s, column: %(column)s."
                          % dict(file=filename,
                                 line=mark.line + 1,
                                 column=mark.column + 1))
            else:
                errmsg = ("YAML error reading Configuration file "
                          "%(file)s"
                          % dict(file=filename))
            logger.error(errmsg)
            raise

        logger.info("Configuration: %s", config)
        return config
652316
def load_yaml
      yaml_config_files = @filenames[:yaml]
      yaml_config_file = nil

      yaml_config_files.each do |file|
        yaml_config_file = Utils.lookup_file file
        unless yaml_config_file.nil?
          config = Utils.load_yaml(yaml_config_file)
          return config.empty? ? @default_config : @default_config.merge(config)
        end
      end

      @default_config # Return default config when can't load config file
    end
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
220891
def _read_yaml_file(self, yaml_file):
        # type: (CliContext, pathlib.Path) -> None
        
        with yaml_file.open('r') as f:
            if self.config is None:
                self.config = ruamel.yaml.load(
                    f, Loader=ruamel.yaml.RoundTripLoader)
            else:
                self.config = blobxfer.util.merge_dict(
                    ruamel.yaml.load(f, Loader=ruamel.yaml.RoundTripLoader),
                    self.config)
983019
def YamlLoader(string):
  """"""
  representation = yaml.Parse(string)
  result_cls = aff4.FACTORY.AFF4Object(representation["aff4_class"])
  aff4_attributes = {}
  for predicate, values in iteritems(representation["attributes"]):
    attribute = aff4.Attribute.PREDICATES[predicate]
    tmp = aff4_attributes[attribute] = []

    for rdfvalue_cls_name, value, age in values:
      rdfvalue_cls = aff4.FACTORY.RDFValue(rdfvalue_cls_name)
      value = rdfvalue_cls(value, age=rdfvalue.RDFDatetime(age))
      tmp.append(value)

  # Ensure the object is dirty so when we save it, it can be written to the data
  # store.
  result = result_cls(
      urn=representation["_urn"],
      clone=aff4_attributes,
      mode="rw",
      age=representation["age_policy"])

  result.new_attributes, result.synced_attributes = result.synced_attributes, {}

  result._dirty = True  # pylint: disable=protected-access

  return result
1247473
def load_from_file(self, file_path, format=None):
        
        if format is None:
            base_name, file_extension = os.path.splitext(file_path)
            if file_extension in (".yaml", ".yml"):
                format = "yaml"
            elif file_extension in (".json"):
                format = "json"
            else:
                raise ValueError("Config file \"%s\" undetermined" % file_extension)

        if format == "yaml":
            return yaml.load(open(file_path), Loader=yaml.CSafeLoader if yaml.__with_libyaml__ else yaml.SafeLoader)
        elif format == "json":
            return json.load(open(file_path))
        else:
            raise ValueError("Format \"%s\" unknwon" % format)
95206
def get_config(config, default_config):
    ''''''
    if not config:
        logging.warning('Using default config: %s', default_config)
        config = default_config

    try:
        with open(config, 'r') as config_file:
            return yaml.load(config_file)
    except (yaml.reader.ReaderError,
            yaml.parser.ParserError,
            yaml.scanner.ScannerError) as e:
        raise ConfigError('Invalid yaml file: \n %s' % str(e))
1254959
def dump(data, stream=None, **kwargs):
    '''
    
    '''
    if 'allow_unicode' not in kwargs:
        kwargs['allow_unicode'] = True
    return yaml.dump(data, stream, **kwargs)
1011613
def _load_yaml_config(path=None):
    """"""
    countour_yaml_path = path or find_contour_yaml()

    if countour_yaml_path is None:
        logging.debug("countour.yaml not found.")
        return None

    with open(countour_yaml_path) as yaml_file:
        return yaml_file.read()