Parse all YAML documents in a stream
    and produce corresponding Python objects.
493385
def load_all(stream, Loader=None):
    
    if Loader is None:
        load_warning('load_all')
        Loader = FullLoader

    loader = Loader(stream)
    try:
        while loader.check_data():
            yield loader.get_data()
    finally:
        loader.dispose()
1245981
def parse_yaml_file(self, path):
        """"""
        with open(path, 'r') as fp:
            data = yaml.safe_load(fp)

        if not data:
            return {}

        def traverse(namespace, d):
            cfg = {}
            for key, val in d.items():
                if isinstance(d[key], dict):
                    cfg.update(traverse(namespace + [key], d[key]))
                else:
                    if not isinstance(val, str):
                        # All values should be double-quoted strings so they
                        # parse as strings; anything else is a configuration
                        # error at parse-time
                        raise ConfigurationError(
                            'Invalid value %r in file %s: values must be double-quoted strings' % (
                                val, path
                            )
                        )

                    cfg['_'.join(namespace + [key]).upper()] = val

            return cfg

        return traverse([], data)
1004195
def yaml_parse(yamlstr):
    """"""
    try:
        # PyYAML doesn't support json as well as it should, so if the input
        # is actually just json it is better to parse it with the standard
        # json parser.
        return json.loads(yamlstr)
    except ValueError:
        yaml.SafeLoader.add_multi_constructor("!", intrinsics_multi_constructor)
        return yaml.safe_load(yamlstr)
233830
@SuppressWarnings("unchecked") // yaml.load API returns raw Map
  public static Map<String, Object> loadStream(InputStream inputStream) {
    LOG.fine("Reading config stream");

    Yaml yaml = new Yaml();
    Map<Object, Object> propsYaml = (Map<Object, Object>) yaml.load(inputStream);
    LOG.fine("Successfully read config");

    Map<String, Object> typedMap = new HashMap<>();
    for (Object key: propsYaml.keySet()) {
      typedMap.put(key.toString(), propsYaml.get(key));
    }

    return typedMap;
  }
306357
def load_yaml_file(filename):
    
    try:
        with open(filename, 'r') as f:
            return yaml.safe_load(f)
    except IOError as e:
        raise ParserError('Error opening ' + filename + ': ' + e.message)
    except ValueError as e:
        raise ParserError('Error parsing processes in {}: {}'
                          .format(filename, e.message))
790734
def dump_all(data_list, stream=None, **kwargs):
    
    return yaml.dump_all(
        data_list,
        stream=stream,
        Dumper=YAMLDictDumper,
        **kwargs
    )
892432
def ParseMany(text):
  
  precondition.AssertType(text, Text)

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

  return list(yaml.safe_load_all(text))
567160
def dump(data, stream=None, **kwargs):
    
    return yaml.dump_all(
        [data],
        stream=stream,
        Dumper=YAMLDictDumper,
        **kwargs
    )
317404
def _parse_document(document: Path, system: System = None, profile=EProfile.FULL):
        
        logger.debug('parse document: {0}'.format(document))
        stream = FileStream(str(document), encoding='utf-8')
        system = FileSystem._parse_stream(stream, system, document, profile)
        FileSystem.merge_annotations(system, document.stripext() + '.yaml')
        return system
771981
def items(stream, **kwargs):
    
    for s in yield_json(stream):
        yield json.loads(s, **kwargs)
251974
def read_file(paths):
    

    if isinstance(paths, str):
        paths = [paths]

    re = {}
    for path in paths:
        cfg = yaml.load(open(path))
        merge(re, cfg)

    return re
214068
def parse(self, stream):
        """"""

        items = OrderedDict()
        for i, line in enumerate(stream):
            line = line.strip()
            if not line or line[0] in ["#", ";", "["] or line.startswith("---"):
                continue
            white_space = "\\s*"
            key = "(?P<key>[^:=;#\s]+?)"
            value = white_space+"[:=\s]"+white_space+"(?P<value>.+?)"
            comment = white_space+"(?P<comment>\\s[;#].*)?"

            key_only_match = re.match("^" + key + comment + "$", line)
            if key_only_match:
                key = key_only_match.group("key")
                items[key] = "true"
                continue

            key_value_match = re.match("^"+key+value+comment+"$", line)
            if key_value_match:
                key = key_value_match.group("key")
                value = key_value_match.group("value")

                if value.startswith("[") and value.endswith("]"):
                    # handle special case of lists
                    value = [elem.strip() for elem in value[1:-1].split(",")]

                items[key] = value
                continue

            raise ConfigFileParserException("Unexpected line %s in %s: %s" % (i,
                getattr(stream, 'name', 'stream'), line))
        return items
1254959
def dump(data, stream=None, **kwargs):
    '''
    
    '''
    if 'allow_unicode' not in kwargs:
        kwargs['allow_unicode'] = True
    return yaml.dump(data, stream, **kwargs)
715645
def load_yaml(filepath):
    """"""
    with open(filepath) as f:
        txt = f.read()
    return yaml.load(txt)
531841
def from_yaml(stream, cls=None, loader_cls=yaml.Loader,
              object_pairs_hook=OrderedDict, **extras):
    

    class OrderedLoader(loader_cls):
        pass

    def construct_mapping(loader, node):
        loader.flatten_mapping(node)
        return object_pairs_hook(loader.construct_pairs(node))

    OrderedLoader.add_constructor(
        yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
        construct_mapping)

    yaml_dict = yaml.load(stream, OrderedLoader) or {}
    yaml_dict.update(extras)
    return cls(**yaml_dict) if cls else yaml_dict
1286062
def load_yaml(self):
        '''
        
        '''
        env = self.state.document.settings.env
        relpath, abspath = env.relfn2path(directives.path(self.arguments[0]))

        env.note_dependency(relpath)

        encoding = self.options.get('encoding', env.config.source_encoding)
        with io.open(abspath, 'rt', encoding=encoding) as stream:
            spec = yaml.load(stream, _YamlOrderedLoader)
        self.spec = spec
        self.paths = spec[self.path_path]
        self.definitions = spec[self.models_path]
        self.openapi_version = spec.get('swagger', None) or spec['openapi']
        self.options.setdefault('uri', 'file://%s' % abspath)
903817
def yml_load(stream, container, yml_fnc=yml_fnc, **options):
    
    if options.get("ac_safe", False):
        options = {}  # yaml.safe_load does not process Loader opts.
    elif not options.get("Loader"):
        maybe_container = options.get("ac_dict", False)
        if maybe_container and callable(maybe_container):
            container = maybe_container

        options["Loader"] = _customized_loader(container)

    ret = yml_fnc("load", stream,
                  **common.filter_from_options("ac_dict", options))
    if ret is None:
        return container()

    return ret