Closed gsemet closed 5 years ago
How about this although a little bit long ?
content = anyconfig.load((pathlib.Path("path") / "to" / "my" / "json.json").open(), ac_parser="json")
To support pathlib (direct passing of pathlib.Path objects) needs some work and may not be easy, I think. At least, I have to keep compatibility with older python versions w/o pathlib somehow. (I opened another issue for this enhancement as #85.)
FYI. pathlib support was into the git HEAD (master branch).
FYI. I released 0.9.6 and it includes this feature.
>>> import pathlib
>>> import anyconfig
>>> anyconfig.VERSION
'0.9.6'
>>> p = pathlib.Path("/var/lib/dnf/groups.json")
>>> x = anyconfig.load(p)
>>> x.keys()
dict_keys(['ENVIRONMENTS', 'GROUPS', 'meta'])
>>> x["meta"]
{'version': '0.6.0'}
>>>
I'll close this as the fixes are merged. Please let me know if you have any further issues on this.
Thanks again for your report!
Hello. Can we have support for pathlib in the load and dump api?