Translate dicts/lists and scalar (string/bool/float/int/etc.) values into a
    YAML object which can be dumped out.
512294
def as_document(data, schema=None, label=u"<unicode string>"):
    
    if schema is None:
        schema = Any()

    return schema(YAMLChunk(schema.to_yaml(data), label=label))
733125
def safe_dump(data, stream=None, **kwargs):
    '''
    
    '''
    if 'allow_unicode' not in kwargs:
        kwargs['allow_unicode'] = True
    return yaml.dump(data, stream, Dumper=SafeOrderedDumper, **kwargs)
242531
def to_yaml_file(obj, f):
    
    yaml.dump(rapidjson.loads(to_json(obj)), f)
1107714
def to_yaml(self):
        """"""
        import yaml

        with self.__reference__.open('w') as fp:
            yaml.dump(self.asjsonld(), fp, default_flow_style=False)
1158394
def _convert(self, val):
        
        if isinstance(val, dict) and not isinstance(val, DotDict):
            return DotDict(val), True
        elif isinstance(val, list) and not isinstance(val, DotList):
            return DotList(val), True

        return val, False
1135807
def _preprocess_yml(path):
    """"""
    with open(path) as f:
        tmp_yaml = f.read()
    return re.sub(r"unicode", "str", tmp_yaml)
366324
def to_yaml(cls, dumper, data):
        
        return dumper.represent_yaml_object(cls.yaml_tag, data, cls,
                flow_style=cls.yaml_flow_style)
1362132
def DumpMany(objs):
  
  precondition.AssertIterableType(objs, object)

  text = yaml.safe_dump_all(objs, default_flow_style=False, allow_unicode=True)

  if compatibility.PY2:
    text = text.decode("utf-8")

  return text
1055730
def read_collection_from_yaml(desired_type: Type[Any], file_object: TextIOBase, logger: Logger,
                              conversion_finder: ConversionFinder, fix_imports: bool = True, errors: str = 'strict',
                              **kwargs) -> Any:
    
    res = yaml.load(file_object)

    # convert if required
    return ConversionFinder.convert_collection_values_according_to_pep(res, desired_type, conversion_finder, logger,
                                                                       **kwargs)
818409
def build_values(name, values_mods):
    """"""
    values_file = os.path.join(name, 'values.yaml')

    with open(values_file) as f:
        values = yaml.load(f)

    for key, value in values_mods.items():
        parts = key.split('.')
        mod_obj = values
        for p in parts:
            mod_obj = mod_obj[p]
        print(f"Updating {values_file}: {key}: {value}")

        if isinstance(mod_obj, MutableMapping):
            keys = IMAGE_REPOSITORY_KEYS & mod_obj.keys()
            if keys:
                for key in keys:
                    mod_obj[key] = value['repository']
            else:
                possible_keys = ' or '.join(IMAGE_REPOSITORY_KEYS)
                raise KeyError(
                    f'Could not find {possible_keys} in {values_file}:{key}'
                )

            mod_obj['tag'] = value['tag']
        else:
            raise TypeError(
                f'The key {key} in {values_file} must be a mapping.'
            )


    with open(values_file, 'w') as f:
        yaml.dump(values, f)
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
483127
def to_yaml!
      @body = YAML.dump(to_h)
    rescue => err
      raise ParseError.new(err), err
    end
1003471
def open_and_parse_yaml(yamlfile):
        

        # ??? what if the yaml file does not contain a dict datastructure?
        mapping = dict()
        if os.path.exists(os.path.join(os.path.dirname(__file__), yamlfile)):
            map_file = open(os.path.join(os.path.dirname(__file__), yamlfile), 'r')
            mapping = yaml.safe_load(map_file)
            map_file.close()
        else:
            LOG.warning("file: %s not found", yamlfile)

        return mapping
1202677
def dump_yaml(data):
    
    return yaml.dump(data,
                     indent=2,
                     encoding=None,
                     allow_unicode=True,
                     default_flow_style=False,
                     Dumper=MyDumper)
114581
def save_yamlf(data: Union[list, dict], fpath: str, encoding: str) -> str:
    
    with codecs.open(fpath, mode='w', encoding=encoding) as f:
        f.write(dump_yaml(data))
        return fpath
22524
public static DataAnalysis fromYaml(String yaml) {
        try{
            return new YamlSerializer().getObjectMapper().readValue(yaml, DataAnalysis.class);
        } catch (Exception e){
            //Legacy format
            ObjectMapper om = new YamlSerializer().getObjectMapper();
            return fromMapper(om, yaml);
        }
    }
365079
def yaml_to_job_list(yaml_file, base_dir):
    """"""
    yaml_dict = get_yaml_dict(yaml_file)
    job_list = []
    for key, value in yaml_dict.items():
        job_list.append((value, rel_to_cwd(base_dir, key)))

    return job_list