Checks whether loaded yaml is well-formed according to syntax defined for
        version 0.9.0 and later.

        Raises:
            YamlError: (containing a meaningful message) when the loaded Yaml
                is not well formed
424876
def check(self):
        
        if not isinstance(self.parsed_yaml, dict):
            msg = 'In {0}:\n'.format(self.sourcefile)
            msg += 'Assistants and snippets must be Yaml mappings, not "{0}"!'.\
                format(self.parsed_yaml)
            raise exceptions.YamlTypeError(msg)
        self._check_fullname(self.sourcefile)
        self._check_description(self.sourcefile)
        self._check_section_names(self.sourcefile)
        self._check_project_type(self.sourcefile)
        self._check_args(self.sourcefile)
        self._check_files(self.sourcefile)
        self._check_dependencies(self.sourcefile)
        self._check_run(self.sourcefile)
1216306
def _include_yaml(loader, node):
    
    return load_yaml(os.path.join(os.path.dirname(loader.name), node.value))
1322596
def to_nice_yaml(yaml_input, indentation=2):
    
    return yaml.safe_dump(yaml_input, indent=indentation,
                          allow_unicode=True, default_flow_style=False)
1323611
def validate_yaml(yaml_in, yaml_fn):
    """"""
    try:
        import yamllint.linter as linter
        from yamllint.config import YamlLintConfig
    except ImportError:
        return
    conf = """{"extends": "relaxed",
               "rules": {"trailing-spaces": {"level": "warning"},
                         "new-lines": {"level": "warning"},
                         "new-line-at-end-of-file": {"level": "warning"}}}"""
    if utils.file_exists(yaml_in):
        with open(yaml_in) as in_handle:
            yaml_in = in_handle.read()
    out = linter.run(yaml_in, YamlLintConfig(conf))

    for problem in out:
        msg = '%(fn)s:%(line)s:%(col)s: [%(level)s] %(msg)s' % {'fn': yaml_fn,
                                                                'line': problem.line,
                                                                'col': problem.column,
                                                                'level': problem.level,
                                                                'msg': problem.message}
        if problem.level == "error":
            raise ValueError(msg)
254777
def valid?(format=@config[:local_format]||:conventional)
      if @config[:mailbox_validator].is_a?(Proc)
        @config[:mailbox_validator].call(self.mailbox, self.tag)
      elsif format.is_a?(Proc)
        format.call(self)
      elsif format == :conventional
        self.conventional?
      elsif format == :relaxed
        self.relaxed?
      elsif format == :redacted
        self.redacted?
      elsif format == :standard
        self.standard?
      elsif format == :none
        true
      else
        raise "Unknown format #{format}"
      end
    end
295479
def execute!
      files_to_check = parse_options.leftovers

      YamlLint.logger.level = Logger::DEBUG if opts.debug

      no_yamls_to_check_msg = "Error: need at least one YAML file to check.\n"\
                              'Try --help for help.'
      abort(no_yamls_to_check_msg) if files_to_check.empty?
      lint(files_to_check)
    end
1156267
def check_has_version(self, api):
        ''''''
        if not hasattr(api, 'version'):
            msg = 'The Api class "{}" lacks a `version` attribute.'
            return [msg.format(api.__name__)]
592260
def _validate(self):
        
        if self.data_format is FormatType.PYTHON:
            self.data = self.raw_data
        elif self.data_format is FormatType.JSON:
            self._validate_json()
        elif self.data_format is FormatType.YAML:
            self._validate_yaml()
675921
def check(self, defn, msg=None):
        
        if isinstance(defn.type, dtype.PrimitiveType):
            # Check the nbytes designated in the YAML match the PDT
            nbytes = defn.type.nbytes
            defnbytes = defn.slice().stop - defn.slice().start
            if nbytes != defnbytes:
                self.messages.append(self.msg % defn.name)
                self.messages.append("Definition size of (" + str(defnbytes) +
                                     " bytes) does not match size of data" +
                                     " type " +str(defn.type.name) + " (" +
                                     str(nbytes) + " byte(s))")
                # TODO self.messages.append("TBD location message")
                self.valid = False
718424
def is_toml_file(filename, show_warnings = False):
    
    if is_yaml_file(filename):
        return(False)
    try:
        config_dict = load_config(filename, file_type = "toml")
        is_toml = True
    except:
        is_toml = False
    return(is_toml)
1296600
def validate_template_syntax(source):
    
    try:
        Template(source)
    except (TemplateSyntaxError, TemplateDoesNotExist) as err:
        raise ValidationError(text_type(err))
977021
def discover_yaml(self):
        
        try:
            import yaml
            self.register('yaml', yaml.load, yaml.dump)
        except ImportError:
            pass
284216
def check(self, _):
        """"""

        try:
            import yaml
        except:
            return True
        try:
            yaml.safe_load(self.recipes)
        except Exception as e:
            raise RADLParseException("Invalid YAML code: %s." % e, line=self.line)
        return True
1155519
def as_yaml(self):
        
        dumped = dump(self.as_marked_up(), Dumper=StrictYAMLDumper, allow_unicode=True)
        return dumped if sys.version_info[0] == 3 else dumped.decode("utf8")
314686
def yaml_block(self):
        
        if LOAD_YAML and self._yaml_block is not None:
            try:
                yaml_dict = yaml.load(self._yaml_block)
                return yaml_dict
            except yaml.error.YAMLError:
                print("Error parsing yaml block. Check formatting.")
        return None
140219
def register_yaml():
    """"""
    try:
        import yaml
        registry.register('yaml', yaml.safe_dump, yaml.safe_load,
                          content_type='application/x-yaml',
                          content_encoding='utf-8')
    except ImportError:

        def not_available(*args, **kwargs):
            """In case a client receives a yaml message, but yaml
            isn't installed."""
            raise SerializerNotInstalled(
                "No decoder installed for YAML. Install the PyYAML library")
        registry.register('yaml', None, not_available, 'application/x-yaml')
831311
def needs_fully_loaded(method):
    
    @functools.wraps(method)
    def inner(self, *args, **kwargs):
        if not self.fully_loaded:
            loaded_yaml = yaml_loader.YamlLoader.load_yaml_by_path(self.path)
            self.parsed_yaml = loaded_yaml
            self.fully_loaded = True
        return method(self, *args, **kwargs)

    return inner