Support custom formats#28
Open
jvrsantacruz wants to merge 4 commits intomasterfrom
Open
Conversation
224fa1d to
7f5792b
Compare
- Changes loader API to take paths rather than open streams - Makes loader API public through the `register_format` function so library users can define their own custom loaders.
7f5792b to
abf446e
Compare
frank-lenormand
approved these changes
May 30, 2024
Contributor
frank-lenormand
left a comment
There was a problem hiding this comment.
Adding PreCommit hooks produced a lot of noise, maybe we should create a cosmetics PR later, to address some minor things (typing annotations, not using mutable objects as default values in functions…).
| 'json': lambda *args: json.load(*args, object_pairs_hook=OrderedDict), | ||
| 'toml': lambda *args: toml.load(*args, _dict=OrderedDict), | ||
| 'ini': load_ini | ||
| "js": "json", |
Contributor
There was a problem hiding this comment.
question: Is that really a ubiquitous abbreviation for the .json extension?
I think .js means JavaScript. Plus a JavaScript file can contain a JSON object, but they’re not necessarily cross-compatible.
I suggest removing this alias.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allows to register custom formats fixes #26 by also changing the file loader API to control how the stream is created.
Other formats can be registered by name providing a function with the loader signature
loader(path): dictand registering using theregister_formatfunction.Extensions can also be associated to previously registered formats by adding them to the extension
register as alias so it automatically detects with
.eqextension: