-
Notifications
You must be signed in to change notification settings - Fork 6
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
Support custom formats #28
base: master
Are you sure you want to change the base?
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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): dict
and registering using theregister_format
function.Extensions can also be associated to previously registered formats by adding them to the extension
register as alias so it automatically detects with
.eq
extension: