-
Notifications
You must be signed in to change notification settings - Fork 84
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
Core should take file-like objects instead of file names #94
Comments
Together with the functionality described above, it would be nice if there was a clear way how to re-use the same scheme multiple times to validate data sets against it: In the moment, it seems that both have to be parsed "together" into a "core object" However, it would be more practical the state something a la |
@brownberry I have not yet analyzed how much this would change in the code but it feels like that would require some major rework of the code and i am not ready to commit to that one yet. If you want to probe the idea to see what would be required for this to work i would love to see some WIP MR that shows the scope/size of that kind of feature. |
@mastereric @brownberry a1919fa Feature implemented in next major release where you can now accept file like objects, specially designed for StringIO to be used. The feature you suggested @brownberry you have to open up a new issue feature request for to reimplenet Schema as a object instead of how it is parsed right now. |
The following example script shows how the new feature will work
|
In my experimentation with this library, I have found it frustrating that, if I have a file-like object, for example a StringIO, I am forced to write the data to a file before validating it.
This does not conform with Python's standard practices, and the fact that this lengthy process is only for validating the file type makes things even more difficult.
My proposal is:
source_file
argument now takes a file rather than a string filename.validation_type
, with possible valuesyaml
orjson
validation_type
is notNone
, use YAML or JSON resp6ctively to parse the file.self.source
toyaml.load(source_file)
, then tojson.load(source_file)
; if neither work, you can just fall back to the source_data argument as you do now. If people have issues with this automatic parsing attempt, they can use the new argument to force it.As a bonus, this fix also resolves #89.
The text was updated successfully, but these errors were encountered: