pykwalify
pykwalify copied to clipboard
Implement acceptance of custom file extensions for files to validate
This pull request adds the following cli options:
-
-y EXT, --yaml-extension EXT
-
-j EXT, --json-extension EXT
Both accept a string representing a file extension for files like, e.g., my-data-file.ext
which contain JSON or YAML data respectively, but don't share the default file endings.
Usage examples:
pykwalify -d my-json-data-file.jext -s schema.yml -j jext
pykwalify -d my-yaml-data-file.yext -s schema.yml -y yext
Coverage increased (+0.04%) to 87.241% when pulling d0fa7a3af99df4b1f3b10842e9f263c0d168ddd0 on sdruskat:pykwalify into e7fac6a5f5d27a472b206b896f684ee83650b5be on Grokzen:master.
Coverage increased (+0.04%) to 87.241% when pulling 54d967bb80b55d3d3a23c93dafe6d57b45f2b5fb on sdruskat:pykwalify into e7fac6a5f5d27a472b206b896f684ee83650b5be on Grokzen:master.
Coverage increased (+0.04%) to 87.241% when pulling 54d967bb80b55d3d3a23c93dafe6d57b45f2b5fb on sdruskat:pykwalify into e7fac6a5f5d27a472b206b896f684ee83650b5be on Grokzen:master.
Coverage increased (+0.04%) to 87.241% when pulling 54d967bb80b55d3d3a23c93dafe6d57b45f2b5fb on sdruskat:pykwalify into e7fac6a5f5d27a472b206b896f684ee83650b5be on Grokzen:master.
Coverage increased (+0.04%) to 87.241% when pulling 6622b08f0095565deb69c0c75181b42f0b9a15db on sdruskat:pykwalify into e7fac6a5f5d27a472b206b896f684ee83650b5be on Grokzen:master.
@sdruskat Just a random thought. Why not just remove the blocks that is in place right now to only support .yaml/.json filetypes? Why not just accet any file that you can point to and try to read it either as json or yaml? This feels like a wrong turn somewhere to add another flag to allow more file endings, the cli syntax feels clunky and not correct in some way.
I see no reason right now to merge this MR. Simply allowing any file extension and handle the loading error seems easier.
Simply allowing any file extension and handle the loading error seems easier.
Isn't JSON a subtype of YAML? Hence perhaps you'll always be able to read every file using using the YAML parser? Is it ever necessary to fallback to the JSON parser assuming a YAML parser is installed?