Accepts YAML_EX as a string or as a file object and runs it through the YAML_EX
    parser.

    :rtype: A Python data structure
978363
def render(sls_data, saltenv='base', sls='', **kws):
    '''
    
    '''
    with warnings.catch_warnings(record=True) as warn_list:
        data = deserialize(sls_data) or {}

        for item in warn_list:
            log.warning(
                '%s found in %s saltenv=%s',
                item.message, salt.utils.url.create(sls), saltenv
            )

        log.debug('Results of SLS rendering: \n%s', data)

    return data
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
    )
1117958
def process(self, ymlfile):
        
        output = ""

        try:
            # Need a list of line numbers where the documents resides
            # Used for finding/displaying errors
            self.doclines = []
            linenum = None
            with open(ymlfile, 'r') as txt:
                for linenum, line in enumerate(txt):
                    # Pattern to match document start lines
                    doc_pattern = re.compile('(---) (![a-z]+)(.*$)', flags=re.I)

                    # Pattern to match sequence start lines
                    seq_pattern = re.compile('(\s*)(-+) !([a-z]+)(.*$)', flags=re.I)

                    # If we find a document, remove the tag
                    if doc_pattern.match(line):
                        line = doc_pattern.sub(r"---", line).lower()
                        self.doclines.append(linenum)
                    elif seq_pattern.match(line):
                        # Replace the sequence start with key string
                        line = seq_pattern.sub(r"\1\2 \3: line " + str(linenum), line).lower()

                    output = output + line

            if linenum is None:
                msg = "Empty YAML file: " + ymlfile
                raise util.YAMLError(msg)
            else:
                # Append one more document to docline for the end
                self.doclines.append(linenum+1)

            return output

        except IOError, e:
            msg = "Could not process YAML file '" + ymlfile + "': '" + str(e) + "'"
            raise IOError(msg)
1137124
def from_file(filename)
      if %w{ .yml .yaml }.include?(File.extname(filename))
        from_yaml(filename)
      elsif File.extname(filename) == ".json"
        from_json(filename)
      elsif File.extname(filename) == ".toml"
        from_toml(filename)
      else
        instance_eval(IO.read(filename), filename, 1)
      end
    end
297019
def obj_from_file(filename='annotation.yaml', filetype='auto'):
    '''  '''

    if filetype == 'auto':
        _, ext = os.path.splitext(filename)
        filetype = ext[1:]

    if filetype in ('yaml', 'yml'):
        from ruamel.yaml import YAML
        yaml = YAML(typ="unsafe")
        with open(filename, encoding="utf-8") as f:
            obj = yaml.load(f)
        if obj is None:
            obj = {}
        # import yaml
        # with open(filename, encoding="utf-8") as f:
        #     intext = f.read()
        #     obj = yaml.load(intext)
    elif filetype in ('pickle', 'pkl', 'pklz', 'picklezip'):
        fcontent = read_pkl_and_pklz(filename)
        # import pickle
        if sys.version_info[0] < 3:
            import cPickle as pickle
        else:
            import _pickle as pickle
        # import sPickle as pickle
        if sys.version_info.major == 2:
            obj = pickle.loads(fcontent)
        else:
            obj = pickle.loads(fcontent, encoding="latin1")
    else:
        logger.error('Unknown filetype ' + filetype)
    return obj
709278
def _handle_special_yaml_cases(v):
    
    if "::" in v:
        out = {}
        for part in v.split("::"):
            k_part, v_part = part.split(":")
            out[k_part] = v_part.split(";")
        v = out
    elif ";" in v:
        # split lists and remove accidental empty values
        v = [x for x in v.split(";") if x != ""]
    elif isinstance(v, list):
        v = v
    else:
        try:
            v = int(v)
        except ValueError:
            if v.lower() == "true":
                v = True
            elif v.lower() == "false":
                    v = False
    return v
1343730
def yaml?(file)
      line = open(file) { |f| line = f.gets }
      line.index "!ruby/object:Gem::Specification"
    end
426178
def on_yaml_imported(self, yaml):
        

        def represent_ordereddict(dumper, data):
            """ A custom data representer for ``OrderedDict`` instances.

            .. note:: Credit to https://stackoverflow.com/a/16782282/7828560.

            :param object dumper: The dumper object
            :param collections.OrderedDict data: The ``OrderedDict`` instance
            :return: The yaml mapping node
            :rtype: yaml.MappingNode
            """

            values = []
            for (key, value) in data.items():
                values.append(
                    (dumper.represent_data(key), dumper.represent_data(value))
                )
            return yaml.MappingNode("tag:yaml.org,2002:map", values)

        yaml.add_representer(OrderedDict, represent_ordereddict)
442773
def load_operations_from_docstring(docstring):
    
    doc_data = load_yaml_from_docstring(docstring)
    return {
        key: val
        for key, val in iteritems(doc_data)
        if key in PATH_KEYS or key.startswith("x-")
    }
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)
1254959
def dump(data, stream=None, **kwargs):
    '''
    
    '''
    if 'allow_unicode' not in kwargs:
        kwargs['allow_unicode'] = True
    return yaml.dump(data, stream, **kwargs)
1010513
def write_example_yaml(cls, dest, skip=()):
        
        # Make sure we can make an instance before we open a file.
        inst = cls.example_instance(skip=skip)
        with open(dest, 'w') as f:
            inst.to_yaml(stream=f, skip=skip)
942894
def create_app_from_yml(path):
    """"""

    try:
        with open(path, "rt", encoding="UTF-8") as f:
            try:
                # Substitute ALL occurrences of '%(here)s' with a path to a
                # directory with '.holocron.yml'. Please note, we also want
                # wrap the result into 'io.StringIO' in order to preserve
                # original filename in 'yaml.safe_load()' errors.
                interpolated = io.StringIO(f.read() % {
                    "here": os.path.abspath(os.path.dirname(path))})
                interpolated.name = f.name

                conf = yaml.safe_load(interpolated)
            except yaml.YAMLError as exc:
                raise RuntimeError(
                    "Cannot parse a configuration file. Context: " + str(exc))

    except FileNotFoundError:
        conf = {"metadata": None, "pipes": {}}

    return core.create_app(conf["metadata"], pipes=conf["pipes"])
948953
def parse_as_yaml(strdict):
    """"""
    interm = ""
    for key, val in strdict.items():
        interm = "%s: %s, %s" % (key, val, interm)
    fin = '{%s}' % interm

    return yaml.load(fin)
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)
960980
def save_yaml(self, outFile):
        """"""
        with open(outFile,'w') as myfile:
            print(yaml.dump(self.params), file=myfile)
307954
def example_yaml(cls, skip=()):
        
        return cls.example_instance(skip=skip).to_yaml(skip=skip)