Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: load_all() #210

Open
meator opened this issue Nov 12, 2024 · 0 comments
Open

Feature request: load_all() #210

meator opened this issue Nov 12, 2024 · 0 comments

Comments

@meator
Copy link

meator commented Nov 12, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant