Convert given Yaml document to a multi-level map.
773026
@SuppressWarnings("unchecked")
  private Map<String, Object> convertToMap(Object yamlDocument) {

    Map<String, Object> yamlMap = new LinkedHashMap<>();

    // Document is a text block
    if (!(yamlDocument instanceof Map)) {
      yamlMap.put("content", yamlDocument);
      return yamlMap;
    }

    for (Map.Entry<Object, Object> entry : ((Map<Object, Object>) yamlDocument).entrySet()) {
      Object value = entry.getValue();

      if (value instanceof Map) {
        value = convertToMap(value);
      } else if (value instanceof Collection) {
        ArrayList<Map<String, Object>> collection = new ArrayList<>();

        for (Object element : ((Collection) value)) {
          collection.add(convertToMap(element));
        }

        value = collection;
      }

      yamlMap.put(entry.getKey().toString(), value);
    }
    return yamlMap;
  }
1145300
def fromLatex(tex, *args, **kwargs):
        
        source = TexSoup(tex)
        return TOC('[document]', source=source,
            descendants=list(source.descendants), *args, **kwargs)
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)
120269
def getYamlDocument(filePath):
    
    with open(filePath) as stream:
        doc = yaml.load(stream)
        return doc
1295133
def to_map
      map = alg.to_map(fields)
      if b64 == false or b64 == true
        map = map.put('b64', b64)
      end
      return map
    end
66497
def convert_content(self) -> dict:
        """"""
        source_content = self.load_content()

        converted = {}

        md_extenstions = [
            'full_yaml_metadata',
            'markdown.extensions.fenced_code',
        ]
        md = markdown.Markdown(md_extenstions)
        content = md.convert(source_content)
        meta = md.Meta

        if meta:
            converted.update(meta)

        if content:
            converted['content'] = content.strip()

        return converted
659540
def _nested_lookup(document, references, operation):
        """"""
        if isinstance(document, list):
            for d in document:
                for result in NestedLookup._nested_lookup(d, references, operation):
                    yield result

        if isinstance(document, dict):
            for k, v in document.items():
                if operation(k, v):
                    references.append((document, k))
                    yield v
                elif isinstance(v, dict):
                    for result in NestedLookup._nested_lookup(v, references, operation):
                        yield result
                elif isinstance(v, list):
                    for d in v:
                        for result in NestedLookup._nested_lookup(d, references, operation):
                            yield result
1322971
def create_from_yamlfile(cls, yamlfile):
        """"""
        data = load_yaml(yamlfile)
        nebins = len(data)
        emin = np.array([data[i]['emin'] for i in range(nebins)])
        emax = np.array([data[i]['emax'] for i in range(nebins)])
        ref_flux = np.array([data[i]['flux'][1] for i in range(nebins)])
        ref_eflux = np.array([data[i]['eflux'][1] for i in range(nebins)])
        conv = np.array([data[i]['eflux2npred'] for i in range(nebins)])
        ref_npred = conv*ref_eflux
        ones = np.ones(ref_flux.shape)
        ref_spec = ReferenceSpec(emin, emax, ones, ref_flux, ref_eflux, ref_npred)
        norm_data = np.array([data[i]['eflux'] for i in range(nebins)])
        ll_data =  np.array([data[i]['logLike'] for i in range(nebins)])
        max_ll = ll_data.max(1)
        nll_data = (max_ll - ll_data.T).T
        return cls(norm_data, nll_data, ref_spec, 'eflux')
735446
def get_document_models():
    """"""
    mappings = {}
    for i in get_index_names():
        for m in get_index_models(i):
            key = "%s.%s" % (i, m._meta.model_name)
            mappings[key] = m
    return mappings
1003755
def write_dict_to_yaml(dictionary, path, **kwargs):
    
    with open(path, 'w') as f:
        yaml.dump(dictionary, f, indent=4, **kwargs)
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))
583582
def construct_yaml_omap(self, node):
        '''
        
        '''
        sls_map = SLSMap()
        if not isinstance(node, MappingNode):
            raise ConstructorError(
                None,
                None,
                'expected a mapping node, but found {0}'.format(node.id),
                node.start_mark)

        self.flatten_mapping(node)

        for key_node, value_node in node.value:

            # !reset instruction applies on document only.
            # It tells to reset previous decoded value for this present key.
            reset = key_node.tag == '!reset'

            # even if !aggregate tag apply only to values and not keys
            # it's a reason to act as a such nazi.
            if key_node.tag == '!aggregate':
                log.warning('!aggregate applies on values only, not on keys')
                value_node.tag = key_node.tag
                key_node.tag = self.resolve_sls_tag(key_node)[0]

            key = self.construct_object(key_node, deep=False)
            try:
                hash(key)
            except TypeError:
                err = ('While constructing a mapping {0} found unacceptable '
                       'key {1}').format(node.start_mark, key_node.start_mark)
                raise ConstructorError(err)
            value = self.construct_object(value_node, deep=False)
            if key in sls_map and not reset:
                value = merge_recursive(sls_map[key], value)
            sls_map[key] = value
        return sls_map
578347
function stringYAML2YAML (doc, compact = false) {
  if (!doc || typeof doc !== 'string') {
    throw new TypeError('Argument must be a string or object, and not empty: ' + doc)
  }

  let obj = yaml.safeLoad(doc)

  if (!obj || typeof obj !== 'object') {
    throw new TypeError('Argument must be in yaml format: ' + doc)
  }

  return yaml.safeDump(obj, compact ? { 'flowLevel': 0 } : undefined)
}
396999
def from_yaml(cls, path):
        """"""
        import yaml

        with path.open(mode='r') as fp:
            source = yaml.safe_load(fp) or {}
            self = cls.from_jsonld(
                source,
                __reference__=path,
                __source__=deepcopy(source),
            )

        return self
241881
public static TransformProcess fromYaml(String yaml) {
        try {
            return JsonMappers.getMapper().readValue(yaml, TransformProcess.class);
        } catch (IOException e) {
            //TODO proper exception message
            throw new RuntimeException(e);
        }
    }
1082748
def write_yaml(filename, content):
    '''
    
    '''

    y = _yaml.dump(content, indent=4, default_flow_style=False)
    if y:
        return write_file(filename, y)
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)