Skip to content

Feature request: load_all() #210

Description

@meator

To my knowledge, strictyaml currently doesn't explicitly support reading multiple YAML documents within a single YAML stream.

For simple enough YAML documents, this is trivial to implement manually. Instead of calling

strictyaml.load(input)

I can call

strictyaml.load(input.split("\n---\n"))

This doesn't handle several edge cases though. --- may appear at the beginning or at the end of the document. The --- line may also contain additional control characters:

--- >
  Mark McGwire's
  year was crippled
  by a knee injury.

The biggest problem is that validation errors report the "local" line number instead of the "global" one (using my naïve solution). I assume that the members of the YAMLValidationError (or other error class) instance could be edited manually to match the "real" line number, but that would likely result in interacting with implementation details.

A "quick and easy" solution would be to add a keyword argument to strictyaml.load() and strictyaml.dirty_load() that would set a line number offset. This number could be added to the resulting line number reported by strictyaml exceptions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions