Dump a list of artifacts into a yaml string.
551226
def DumpArtifactsToYaml(self, sort_by_os=True):
    """"""
    artifact_list = self.GetArtifacts()
    if sort_by_os:
      # Sort so its easier to split these if necessary.
      yaml_list = []
      done_set = set()
      for os_name in rdf_artifacts.Artifact.SUPPORTED_OS_LIST:
        done_set = set(a for a in artifact_list if a.supported_os == [os_name])
        # Separate into knowledge_base and non-kb for easier sorting.
        done_set = sorted(done_set, key=lambda x: x.name)
        yaml_list.extend(x.ToYaml() for x in done_set if x.provides)
        yaml_list.extend(x.ToYaml() for x in done_set if not x.provides)
        artifact_list = artifact_list.difference(done_set)
      yaml_list.extend(x.ToYaml() for x in artifact_list)  # The rest.
    else:
      yaml_list = [x.ToYaml() for x in artifact_list]

    return "---\n\n".join(yaml_list)
955659
def dump(config):
    

    return yaml.safe_dump(
        config.to_primitive(),
        default_flow_style=False,
        encoding='utf-8',
        allow_unicode=True)
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()
  })
}
435930
def yaml_to_param(obj, name):
	
	return from_pyvalue(u"yaml:%s" % name, unicode(yaml.dump(obj)))
1220884
def to_yaml(cls, dumper, vividict):
        
        dictionary = cls.vividict_to_dict(vividict)
        node = dumper.represent_mapping(cls.yaml_tag, dictionary)
        return node
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);
        }
    }
580893
def write_yaml(data, out_path, Dumper=yaml.Dumper, **kwds):
    ''''''
    import errno
    import os

    class OrderedDumper(Dumper):
        pass
    def _dict_representer(dumper, data):
        return dumper.represent_mapping(
            yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
            data.items())

    OrderedDumper.add_representer(OrderedDict, _dict_representer)

    # Make directory for calibration file if does not exist
    base_path, file_name = os.path.split(out_path)
    try:
        os.makedirs(base_path)
    except OSError as exc: # Python >2.5
        if exc.errno == errno.EEXIST and os.path.isdir(base_path):
            pass
        else: raise

    # Write dictionary to YAML
    with open(out_path, 'w') as f:
        return yaml.dump(data, f, OrderedDumper, default_flow_style=False, **kwds)
1202677
def dump_yaml(data):
    
    return yaml.dump(data,
                     indent=2,
                     encoding=None,
                     allow_unicode=True,
                     default_flow_style=False,
                     Dumper=MyDumper)
573901
def _dump(self, stream, pattern=None, object_ids=False):
        """"""
        return self._lists[pattern]._dump(stream, '', object_ids=object_ids)
1082884
def ordered_yaml_dump(data, stream=None, Dumper=None, **kwds):
    """"""
    Dumper = Dumper or yaml.Dumper

    class OrderedDumper(Dumper):
        pass

    def _dict_representer(dumper, data):
        return dumper.represent_mapping(
            yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
            data.items())
    OrderedDumper.add_representer(OrderedDict, _dict_representer)
    return yaml.dump(data, stream, OrderedDumper, **kwds)
260355
def FormatArtifacts(self, artifacts):
    
    # TODO: improve output formatting of yaml
    artifact_definitions = [artifact.AsDict() for artifact in artifacts]
    yaml_data = yaml.safe_dump_all(artifact_definitions)
    return yaml_data
1352714
def get_yaml_files_at_env_root(self):
        """"""
        yaml_files = glob.glob(
            os.path.join(self.env_root, '*.yaml')
        )
        yml_files = glob.glob(
            os.path.join(self.env_root, '*.yml')
        )
        return yaml_files + yml_files
871596
def cfgdump(path, config):
    """"""
    dump = yaml_dump(config)
    if not os.path.exists(path):
        os.makedirs(path)
    with open(os.path.join(path, 'config.yaml'), 'w') as outf:
        outf.write(dump)
    print(dump)
1197722
def _extract_yaml_block(self, indent, fh):
        """"""
        raw_yaml = []
        indent_match = re.compile(r"^{}".format(indent))
        try:
            fh.next()
            while indent_match.match(fh.peek()):
                raw_yaml.append(fh.next().replace(indent, "", 1))
                # check for the end and stop adding yaml if encountered
                if self.yaml_block_end.match(fh.peek()):
                    fh.next()
                    break
        except StopIteration:
            pass
        return "\n".join(raw_yaml)
740878
def to_yamlf(self, fpath: str, encoding: str='utf8', ignore_none: bool=True, ignore_empty: bool=False) -> str:
        
        return util.save_yamlf(traverse(self, ignore_none, force_value=True, ignore_empty=ignore_empty), fpath, encoding)
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
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
    )