jsonref icon indicating copy to clipboard operation
jsonref copied to clipboard

PEP8 and support for `env:VAR_NAME`

Open SamuelMarks opened this issue 8 years ago • 7 comments

Split it into two commits because the new feature isn't part of the JSON Pointer or JSON Reference standards; so you can easily cherrypick.

SamuelMarks avatar Jul 05 '17 04:07 SamuelMarks

Coverage Status

Coverage increased (+0.05%) to 91.909% when pulling e481a30213cffcbfa611a5b55672586dc6c330e3 on offscale:master into 0235f4913daf835201115975369176c6c9e1f65b on gazpachoking:master.

coveralls avatar Jul 05 '17 04:07 coveralls

Coverage Status

Coverage decreased (-3.1%) to 88.715% when pulling 71237ffea8e19f429ef5e18edcd94e2ae2c246d9 on offscale:master into 0235f4913daf835201115975369176c6c9e1f65b on gazpachoking:master.

coveralls avatar Jul 05 '17 12:07 coveralls

Coverage Status

Coverage decreased (-3.1%) to 88.715% when pulling 27f04358e459107e8bc21fcee947710fd2b25856 on offscale:master into 0235f4913daf835201115975369176c6c9e1f65b on gazpachoking:master.

coveralls avatar Jul 05 '17 12:07 coveralls

Coverage Status

Coverage decreased (-3.8%) to 88.037% when pulling 1285f9126b5b2aa87c2c2a38349e241e0fd22830 on offscale:master into 0235f4913daf835201115975369176c6c9e1f65b on gazpachoking:master.

coveralls avatar Jul 06 '17 02:07 coveralls

Coverage Status

Coverage decreased (-4.3%) to 87.234% when pulling e30aab61bbc3b1261a55d2fb64f56793ec09c242 on offscale:master into 066132e527f8115f75bcadfd0eca12f8973a6309 on gazpachoking:master.

coveralls avatar Jul 07 '17 05:07 coveralls

Add tests; coverage decreases

LOL: that didn't go as expected!

SamuelMarks avatar Jul 07 '17 05:07 SamuelMarks

@gazpachoking Decided to update this after 3 years…

SamuelMarks avatar Sep 20 '20 11:09 SamuelMarks

I think I took care of the PEP parts of this PR when I added black to the pre-commit hooks. As for the ENV part, I'm not sure directly supporting that is appropriate. I think using a custom loader to handle those URIs would work though, without any modifications to the core?

gazpachoking avatar Oct 09 '22 21:10 gazpachoking

@gazpachoking Can you describe what that would look like? - Would the ENV: syntax still work? - Are you thinking some URI style syntax with a fake device/mount like file://ENV:VAR_NAME?

SamuelMarks avatar Oct 15 '22 22:10 SamuelMarks

@gazpachoking Can you describe what that would look like? - Would the ENV: syntax still work? - Are you thinking some URI style syntax with a fake device/mount like file://ENV:VAR_NAME?

Here's a simple example of what I mean:

import os

import jsonref


json = {
    "a": {"$ref": "env:MYENV"}
}


def loader(uri):
    if uri.startswith("env:"):
        return os.environ[uri[4:]]
    # If you want to fall back to the default loader:
    return jsonref.jsonloader(uri)


print(jsonref.replace_refs(json, loader=loader))

gazpachoking avatar Oct 20 '22 03:10 gazpachoking

I added that example to the docs for upcoming release. Going to close this out now. Feel free to open other issues or PRs if you've got any!

gazpachoking avatar Oct 20 '22 04:10 gazpachoking