Pyjoyment 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- Pyjo/App/ASGI.py +735 -0
- Pyjo/App/CGI.py +773 -0
- Pyjo/App/FastCGI.py +631 -0
- Pyjo/App/Lambda.py +987 -0
- Pyjo/App/WSGI.py +427 -0
- Pyjo/App/__init__.py +409 -0
- Pyjo/Asset/File.py +377 -0
- Pyjo/Asset/Memory.py +235 -0
- Pyjo/Asset/__init__.py +200 -0
- Pyjo/Base.py +215 -0
- Pyjo/Cache.py +119 -0
- Pyjo/Collection.py +570 -0
- Pyjo/Content/MultiPart.py +325 -0
- Pyjo/Content/Single.py +193 -0
- Pyjo/Content/__init__.py +806 -0
- Pyjo/Cookie/Request.py +90 -0
- Pyjo/Cookie/Response.py +294 -0
- Pyjo/Cookie/__init__.py +143 -0
- Pyjo/DOM/CSS.py +1019 -0
- Pyjo/DOM/HTML.py +550 -0
- Pyjo/DOM/__init__.py +1329 -0
- Pyjo/Date.py +294 -0
- Pyjo/EventEmitter.py +522 -0
- Pyjo/Exception.py +494 -0
- Pyjo/File.py +959 -0
- Pyjo/GetOpt.py +605 -0
- Pyjo/Headers.py +760 -0
- Pyjo/HelloWorld.py +77 -0
- Pyjo/Home.py +109 -0
- Pyjo/IOLoop/ChildProcess.py +591 -0
- Pyjo/IOLoop/Client.py +736 -0
- Pyjo/IOLoop/Datagram.py +982 -0
- Pyjo/IOLoop/Messages.py +664 -0
- Pyjo/IOLoop/Server.py +458 -0
- Pyjo/IOLoop/Stdio.py +446 -0
- Pyjo/IOLoop/Stream.py +644 -0
- Pyjo/IOLoop/Subprocess.py +419 -0
- Pyjo/IOLoop/TLS.py +360 -0
- Pyjo/IOLoop/__init__.py +1036 -0
- Pyjo/IOLoop/certs/README.md +41 -0
- Pyjo/IOLoop/certs/ca.crt +20 -0
- Pyjo/IOLoop/certs/server.crt +21 -0
- Pyjo/IOLoop/certs/server.key +28 -0
- Pyjo/JSON/Pointer.py +135 -0
- Pyjo/JSON/RPC.py +772 -0
- Pyjo/JSON/Schema.py +2506 -0
- Pyjo/JSON/__init__.py +573 -0
- Pyjo/Loader.py +342 -0
- Pyjo/Log.py +723 -0
- Pyjo/Message/Request.py +725 -0
- Pyjo/Message/Response.py +476 -0
- Pyjo/Message/__init__.py +830 -0
- Pyjo/Parameters.py +472 -0
- Pyjo/Path.py +419 -0
- Pyjo/Promise.py +894 -0
- Pyjo/Prove.py +1305 -0
- Pyjo/Reactor/Asyncio.py +854 -0
- Pyjo/Reactor/Poll.py +439 -0
- Pyjo/Reactor/__init__.py +525 -0
- Pyjo/SSE.py +119 -0
- Pyjo/Server/ASGI.py +486 -0
- Pyjo/Server/CGI.py +259 -0
- Pyjo/Server/Daemon.py +1007 -0
- Pyjo/Server/FastCGI.py +517 -0
- Pyjo/Server/Hot/__init__.py +687 -0
- Pyjo/Server/Hot/__main__.py +5 -0
- Pyjo/Server/Lambda.py +641 -0
- Pyjo/Server/Prefork.py +917 -0
- Pyjo/Server/Prethread.py +394 -0
- Pyjo/Server/Reload/Backend/Poll.py +114 -0
- Pyjo/Server/Reload/Backend/__init__.py +126 -0
- Pyjo/Server/Reload/__init__.py +482 -0
- Pyjo/Server/Reload/__main__.py +5 -0
- Pyjo/Server/Stdio.py +228 -0
- Pyjo/Server/WSGI.py +349 -0
- Pyjo/Server/__init__.py +396 -0
- Pyjo/String/Bytes.py +532 -0
- Pyjo/String/HTML.py +210 -0
- Pyjo/String/Mixin.py +333 -0
- Pyjo/String/Template.py +470 -0
- Pyjo/String/Unicode.py +553 -0
- Pyjo/String/__init__.py +0 -0
- Pyjo/TOML.py +232 -0
- Pyjo/Template.py +1290 -0
- Pyjo/Test/Pyjo.py +1454 -0
- Pyjo/Test/__init__.py +1233 -0
- Pyjo/Test/pytest_plugin.py +305 -0
- Pyjo/Transaction/HTTP.py +374 -0
- Pyjo/Transaction/WebSocket.py +709 -0
- Pyjo/Transaction/__init__.py +429 -0
- Pyjo/URL/Template.py +459 -0
- Pyjo/URL/__init__.py +651 -0
- Pyjo/Upload.py +139 -0
- Pyjo/UserAgent/CookieJar.py +391 -0
- Pyjo/UserAgent/Proxy.py +138 -0
- Pyjo/UserAgent/Server.py +239 -0
- Pyjo/UserAgent/Transactor.py +766 -0
- Pyjo/UserAgent/__init__.py +1243 -0
- Pyjo/Util.py +3567 -0
- Pyjo/WebSocket.py +332 -0
- Pyjo/YAML.py +1167 -0
- Pyjo/__init__.py +441 -0
- Pyjo/__main__.py +35 -0
- Pyjo/py.typed +0 -0
- Pyjoyment/Command/Author/__init__.py +20 -0
- Pyjoyment/Command/Author/generate/__init__.py +106 -0
- Pyjoyment/Command/Author/generate/app.py +299 -0
- Pyjoyment/Command/Author/generate/dockerfile.py +281 -0
- Pyjoyment/Command/Author/generate/kubernetes.py +514 -0
- Pyjoyment/Command/Author/generate/lambda_zip.py +372 -0
- Pyjoyment/Command/Author/generate/lite_app.py +113 -0
- Pyjoyment/Command/Author/generate/plugin.py +267 -0
- Pyjoyment/Command/Author/generate/pyproject.py +123 -0
- Pyjoyment/Command/Author/inflate.py +101 -0
- Pyjoyment/Command/__init__.py +332 -0
- Pyjoyment/Command/asgi.py +92 -0
- Pyjoyment/Command/cgi.py +90 -0
- Pyjoyment/Command/daemon.py +160 -0
- Pyjoyment/Command/eval.py +128 -0
- Pyjoyment/Command/fastcgi.py +99 -0
- Pyjoyment/Command/get.py +305 -0
- Pyjoyment/Command/lambda.py +117 -0
- Pyjoyment/Command/prefork.py +181 -0
- Pyjoyment/Command/prethread.py +126 -0
- Pyjoyment/Command/routes.py +133 -0
- Pyjoyment/Command/stdio.py +92 -0
- Pyjoyment/Command/version.py +141 -0
- Pyjoyment/Command/wsgi.py +93 -0
- Pyjoyment/Commands.py +546 -0
- Pyjoyment/Controller.py +1307 -0
- Pyjoyment/HelloWorld.py +56 -0
- Pyjoyment/Lite.py +494 -0
- Pyjoyment/Plugin/AllowedHosts.py +205 -0
- Pyjoyment/Plugin/Config.py +248 -0
- Pyjoyment/Plugin/DefaultHelpers.py +1202 -0
- Pyjoyment/Plugin/EPLRenderer.py +134 -0
- Pyjoyment/Plugin/EPRenderer.py +212 -0
- Pyjoyment/Plugin/HeaderCondition.py +98 -0
- Pyjoyment/Plugin/Health.py +325 -0
- Pyjoyment/Plugin/JSONConfig.py +172 -0
- Pyjoyment/Plugin/Mount.py +223 -0
- Pyjoyment/Plugin/PyRenderer.py +209 -0
- Pyjoyment/Plugin/TOMLConfig.py +141 -0
- Pyjoyment/Plugin/TagHelpers.py +959 -0
- Pyjoyment/Plugin/YAMLConfig.py +178 -0
- Pyjoyment/Plugin/__init__.py +80 -0
- Pyjoyment/Plugins.py +215 -0
- Pyjoyment/Renderer.py +673 -0
- Pyjoyment/Routes/Match.py +251 -0
- Pyjoyment/Routes/Pattern.py +443 -0
- Pyjoyment/Routes/Route.py +827 -0
- Pyjoyment/Routes/__init__.py +419 -0
- Pyjoyment/Sessions.py +255 -0
- Pyjoyment/Static.py +421 -0
- Pyjoyment/Types.py +238 -0
- Pyjoyment/Validator/Validation.py +395 -0
- Pyjoyment/Validator/__init__.py +304 -0
- Pyjoyment/__init__.py +1083 -0
- Pyjoyment/__main__.py +5 -0
- Pyjoyment/py.typed +0 -0
- Pyjoyment/resources/public/favicon.ico +0 -0
- Pyjoyment/resources/public/favicon.svg +345 -0
- Pyjoyment/resources/public/pyjo/bootstrap/LICENSE +21 -0
- Pyjoyment/resources/public/pyjo/bootstrap/bootstrap.bundle.min.js.map +1 -0
- Pyjoyment/resources/public/pyjo/bootstrap/bootstrap.css +6 -0
- Pyjoyment/resources/public/pyjo/bootstrap/bootstrap.js +7 -0
- Pyjoyment/resources/public/pyjo/bootstrap/bootstrap.min.css.map +1 -0
- Pyjoyment/resources/public/pyjo/failunicat.png +0 -0
- Pyjoyment/resources/public/pyjo/failunicat.svg +50 -0
- Pyjoyment/resources/public/pyjo/highlight.js/LICENSE +29 -0
- Pyjoyment/resources/public/pyjo/highlight.js/highlight-mojo-dark.css +56 -0
- Pyjoyment/resources/public/pyjo/highlight.js/highlight.min.js +1262 -0
- Pyjoyment/resources/public/pyjo/highlight.js/pyjoyment.min.js +1 -0
- Pyjoyment/resources/public/pyjo/logo-black-4x.png +0 -0
- Pyjoyment/resources/public/pyjo/logo-black-4x.svg +346 -0
- Pyjoyment/resources/public/pyjo/logo-white-2x.png +0 -0
- Pyjoyment/resources/public/pyjo/logo-white-2x.svg +346 -0
- Pyjoyment/resources/public/pyjo/logo-white-4x.png +0 -0
- Pyjoyment/resources/public/pyjo/logo-white-4x.svg +346 -0
- Pyjoyment/resources/public/pyjo/logo-white.png +0 -0
- Pyjoyment/resources/public/pyjo/logo-white.svg +346 -0
- Pyjoyment/resources/public/pyjo/logo.png +0 -0
- Pyjoyment/resources/public/pyjo/logo.svg +346 -0
- Pyjoyment/resources/public/pyjo/notfound.png +0 -0
- Pyjoyment/resources/public/pyjo/notfound.svg +3 -0
- Pyjoyment/resources/public/pyjo/nounicat.png +0 -0
- Pyjoyment/resources/public/pyjo/nounicat.svg +5 -0
- Pyjoyment/resources/public/pyjo/pinstripe-dark.png +0 -0
- Pyjoyment/resources/public/pyjo/pinstripe-dark.svg +4 -0
- Pyjoyment/resources/public/pyjo/pinstripe-light.png +0 -0
- Pyjoyment/resources/public/pyjo/pinstripe-light.svg +4 -0
- Pyjoyment/resources/public/pyjo/pyjo.css +204 -0
- Pyjoyment/resources/templates/pyjo/debug.html.ep +346 -0
- Pyjoyment/resources/templates/pyjo/exception.html.ep +32 -0
- Pyjoyment/resources/templates/pyjo/not_found.html.ep +45 -0
- pyjoyment-0.1.0.dist-info/METADATA +376 -0
- pyjoyment-0.1.0.dist-info/RECORD +200 -0
- pyjoyment-0.1.0.dist-info/WHEEL +4 -0
- pyjoyment-0.1.0.dist-info/entry_points.txt +8 -0
- pyjoyment-0.1.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# The default certificate for TLS servers
|
|
2
|
+
|
|
3
|
+
The certificate and key that a TLS server of `Pyjo.IOLoop.Server` uses when
|
|
4
|
+
it is given none, as `lib/Mojo/IOLoop/resources` in Mojolicious. They are not
|
|
5
|
+
secret and are meant for development only.
|
|
6
|
+
|
|
7
|
+
| Files | Certificate |
|
|
8
|
+
| -------------------------- | ------------------------------------------------- |
|
|
9
|
+
| `ca.crt` | The CA that signs the server, `Pyjoyment Test CA` |
|
|
10
|
+
| `server.crt`, `server.key` | `localhost` and `127.0.0.1`, for a server |
|
|
11
|
+
|
|
12
|
+
The key of the CA is not kept, so the certificate is made again with a new
|
|
13
|
+
CA. They are RSA 2048 keys, valid for a hundred years, made with OpenSSL 3 in
|
|
14
|
+
a temporary directory, from the root of the repository:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
certs=$PWD/Pyjo/IOLoop/certs
|
|
18
|
+
cd "$(mktemp -d)"
|
|
19
|
+
|
|
20
|
+
openssl req -x509 -newkey rsa:2048 -nodes -days 36500 \
|
|
21
|
+
-keyout ca.key -out ca.crt -subj '/O=Pyjoyment/CN=Pyjoyment Test CA' \
|
|
22
|
+
-addext 'basicConstraints=critical,CA:TRUE' \
|
|
23
|
+
-addext 'keyUsage=critical,keyCertSign,cRLSign' \
|
|
24
|
+
-addext 'subjectKeyIdentifier=hash'
|
|
25
|
+
|
|
26
|
+
openssl req -newkey rsa:2048 -nodes -keyout server.key -out server.csr -subj '/O=Pyjoyment/CN=localhost'
|
|
27
|
+
printf 'basicConstraints=critical,CA:FALSE\nkeyUsage=critical,digitalSignature,keyEncipherment\nextendedKeyUsage=serverAuth\nsubjectAltName=DNS:localhost,IP:127.0.0.1\nsubjectKeyIdentifier=hash\nauthorityKeyIdentifier=keyid\n' > server.ext
|
|
28
|
+
openssl x509 -req -days 36500 -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial \
|
|
29
|
+
-out server.crt -extfile server.ext
|
|
30
|
+
|
|
31
|
+
openssl verify -CAfile ca.crt server.crt
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Then copy the certificates and the key into `Pyjo/IOLoop/certs`, readable by
|
|
35
|
+
everyone, and delete the temporary directory, the key of the CA with it:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
chmod 644 server.key
|
|
39
|
+
cp ca.crt server.crt server.key "$certs/"
|
|
40
|
+
cd "$certs" && rm -rf "$OLDPWD"
|
|
41
|
+
```
|
Pyjo/IOLoop/certs/ca.crt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
|
2
|
+
MIIDUzCCAjugAwIBAgIUGusTwLea9+WoMwFTwdUZ02xRYGowDQYJKoZIhvcNAQEL
|
|
3
|
+
BQAwMDESMBAGA1UECgwJUHlqb3ltZW50MRowGAYDVQQDDBFQeWpveW1lbnQgVGVz
|
|
4
|
+
dCBDQTAgFw0yNjEwMTMyMzAwNTVaGA8yMTI2MDkxOTIzMDA1NVowMDESMBAGA1UE
|
|
5
|
+
CgwJUHlqb3ltZW50MRowGAYDVQQDDBFQeWpveW1lbnQgVGVzdCBDQTCCASIwDQYJ
|
|
6
|
+
KoZIhvcNAQEBBQADggEPADCCAQoCggEBALaawIuyilsP0nJF4w9L4TCfgyg/MEib
|
|
7
|
+
c0vRmzGHU25FwPd3DXLxxXvp8LAbLraV7y0ML2pBDLPnAGlZeiwj80gnjU7Xa6cz
|
|
8
|
+
uf530qau29XUY2wL1DdZ8glbfXFssF5tzday6QNCBNHrmKhAM4AfHZCF8ZQba65p
|
|
9
|
+
x5XO3VRuayYu4hzvbNgV/0/CbQdfLu7iQk+RepzBjhELwYOnSddXqMVEKMHJ1T1n
|
|
10
|
+
G8qBP1lhZ1RZCo6sPRG/Ctsb865QrhXR/Yy3Z4PR1kMxQuWOmegDqkvFZ2eflg+6
|
|
11
|
+
Tg803GIVLyD/iHNqI1Bmpra9yFAYdfDKJMKR+xi7bViUlRnaKCsuoeECAwEAAaNj
|
|
12
|
+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+
I/pTI0qorX2qnNtzP4hCQHna4QKBgQDTGEO//kiyX488VpXW5VnBZPDvZ63+gmCt
|
|
17
|
+
4MJWFvlg6NYQ4RICi7LLjoc71HM1uyVXPBJ7LhPhaMrtYT3froM+1ClG2OAKaNTw
|
|
18
|
+
XRNtyEl61YXMEQvTHKcVJqgirFb1ozkBm46Xyl3f2xumYP+FBBULthVfnNa5wEUJ
|
|
19
|
+
vXEKTbKAeQKBgQCue3jSmuHdc+TrzIhQLKGKlZjmzC8jSarY+DooJfW3JWVDXRXN
|
|
20
|
+
1eOrCBPMA6aL/0SrmWJEMhcKuBIcjLfpNkp6/o8lIiTOmgws5uj0uu4LR6/UK5oN
|
|
21
|
+
QQJSVXGvccnPLvDb/8xFJmnB0hZtTkxWaNvj4xQ24vqwJgkyooY7UVH9oQKBgFGl
|
|
22
|
+
XO7xZyS2mSv5QVMwuhp29ElkjIOX4dTezcuGb0XwSHuW0eRyK+FXay7U6QqrK7Il
|
|
23
|
+
5fAGzmGsqnBN4CSX1uOCI8TnNSBRk6q0FUOs596+n1VicnRg7K7dmMJwbeHsE6xv
|
|
24
|
+
giNrfguLL5KWib3k6k7xSisE+ng1yX4O653Ul2nhAoGAYl9SDnK4lZHqVsMIMO2D
|
|
25
|
+
4V+SFPpoAHFYKGM2kbRPvsWPja5WkDE0rMh50FkeDSZgkmI9/tGYkNi7d3GiM1T5
|
|
26
|
+
pg2u6dPfP5kqzMHOWe6twDh/OWAXduxfiEp54GrKL1jbfr1XniKFWqqKTCeGCUU4
|
|
27
|
+
QbxC3HkS17GyLy/r4Uo6+zg=
|
|
28
|
+
-----END PRIVATE KEY-----
|
Pyjo/JSON/Pointer.py
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Pyjo.JSON.Pointer - JSON Pointers
|
|
3
|
+
=================================
|
|
4
|
+
::
|
|
5
|
+
|
|
6
|
+
from Pyjo.JSON.Pointer import Pointer
|
|
7
|
+
|
|
8
|
+
pointer = Pointer({'foo': [23, 'bar']})
|
|
9
|
+
print(pointer.get('/foo/1'))
|
|
10
|
+
if pointer.contains('/foo'):
|
|
11
|
+
print('Contains "/foo".')
|
|
12
|
+
|
|
13
|
+
# Or import the module, as in Google Python Style Guide
|
|
14
|
+
|
|
15
|
+
import Pyjo.JSON.Pointer
|
|
16
|
+
|
|
17
|
+
pointer = Pyjo.JSON.Pointer.new({'foo': [23, 'bar']})
|
|
18
|
+
print(pointer.get('/foo/1'))
|
|
19
|
+
if pointer.contains('/foo'):
|
|
20
|
+
print('Contains "/foo".')
|
|
21
|
+
|
|
22
|
+
:mod:`Pyjo.JSON.Pointer` is an implementation of :rfc:`6901`.
|
|
23
|
+
|
|
24
|
+
See also
|
|
25
|
+
--------
|
|
26
|
+
|
|
27
|
+
:mod:`Pyjoyment`, https://mojolicious.org.
|
|
28
|
+
|
|
29
|
+
Ported from `Mojo::JSON::Pointer <https://github.com/mojolicious/mojo/blob/v9.49/lib/Mojo/JSON/Pointer.pm>`_
|
|
30
|
+
of Mojolicious 9.49.
|
|
31
|
+
|
|
32
|
+
Classes
|
|
33
|
+
-------
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
import Pyjo.Base
|
|
37
|
+
|
|
38
|
+
import re
|
|
39
|
+
|
|
40
|
+
from typing import Any, cast
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class Pyjo_JSON_Pointer(Pyjo.Base.object):
|
|
44
|
+
"""
|
|
45
|
+
:mod:`Pyjo.JSON.Pointer` inherits all methods from :mod:`Pyjo.Base` and
|
|
46
|
+
implements the following new ones.
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
def __init__(self, data: Any = None) -> None:
|
|
50
|
+
"""::
|
|
51
|
+
|
|
52
|
+
pointer = Pyjo.JSON.Pointer.new()
|
|
53
|
+
pointer = Pyjo.JSON.Pointer.new({'foo': 'bar'})
|
|
54
|
+
|
|
55
|
+
Build new :mod:`Pyjo.JSON.Pointer` object.
|
|
56
|
+
"""
|
|
57
|
+
self.data: Any = data
|
|
58
|
+
"""::
|
|
59
|
+
|
|
60
|
+
data = pointer.data
|
|
61
|
+
pointer.data = {'foo': 'bar'}
|
|
62
|
+
|
|
63
|
+
Data structure to be processed.
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
def contains(self, pointer: str) -> bool:
|
|
67
|
+
"""::
|
|
68
|
+
|
|
69
|
+
boolean = pointer.contains('/foo/1')
|
|
70
|
+
|
|
71
|
+
Check if :attr:`data` contains a value that can be identified with the
|
|
72
|
+
given JSON Pointer. ::
|
|
73
|
+
|
|
74
|
+
# True
|
|
75
|
+
Pyjo.JSON.Pointer.new('just a string').contains('')
|
|
76
|
+
Pyjo.JSON.Pointer.new({'♥': 'pyjoyment'}).contains('/♥')
|
|
77
|
+
Pyjo.JSON.Pointer.new({'foo': 'bar', 'baz': [4, 5]}).contains('/foo')
|
|
78
|
+
Pyjo.JSON.Pointer.new({'foo': 'bar', 'baz': [4, 5]}).contains('/baz/1')
|
|
79
|
+
|
|
80
|
+
# False
|
|
81
|
+
Pyjo.JSON.Pointer.new({'♥': 'pyjoyment'}).contains('/☃')
|
|
82
|
+
Pyjo.JSON.Pointer.new({'foo': 'bar', 'baz': [4, 5]}).contains('/bar')
|
|
83
|
+
Pyjo.JSON.Pointer.new({'foo': 'bar', 'baz': [4, 5]}).contains('/baz/9')
|
|
84
|
+
"""
|
|
85
|
+
return self._pointer(False, pointer) is not None
|
|
86
|
+
|
|
87
|
+
def get(self, pointer: str) -> Any:
|
|
88
|
+
"""::
|
|
89
|
+
|
|
90
|
+
value = pointer.get('/foo/bar')
|
|
91
|
+
|
|
92
|
+
Extract value from :attr:`data` identified by the given JSON Pointer. ::
|
|
93
|
+
|
|
94
|
+
# "just a string"
|
|
95
|
+
Pyjo.JSON.Pointer.new('just a string').get('')
|
|
96
|
+
|
|
97
|
+
# "pyjoyment"
|
|
98
|
+
Pyjo.JSON.Pointer.new({'♥': 'pyjoyment'}).get('/♥')
|
|
99
|
+
|
|
100
|
+
# "bar"
|
|
101
|
+
Pyjo.JSON.Pointer.new({'foo': 'bar', 'baz': [4, 5, 6]}).get('/foo')
|
|
102
|
+
|
|
103
|
+
# 4
|
|
104
|
+
Pyjo.JSON.Pointer.new({'foo': 'bar', 'baz': [4, 5, 6]}).get('/baz/0')
|
|
105
|
+
|
|
106
|
+
# 6
|
|
107
|
+
Pyjo.JSON.Pointer.new({'foo': 'bar', 'baz': [4, 5, 6]}).get('/baz/2')
|
|
108
|
+
"""
|
|
109
|
+
return self._pointer(True, pointer)
|
|
110
|
+
|
|
111
|
+
def _pointer(self, get: bool, pointer: str) -> Any:
|
|
112
|
+
data: Any = self.data
|
|
113
|
+
if not pointer.startswith('/'):
|
|
114
|
+
return None if len(pointer) else data if get else True
|
|
115
|
+
for p in pointer[1:].split('/'):
|
|
116
|
+
p = p.replace('~1', '/').replace('~0', '~')
|
|
117
|
+
|
|
118
|
+
# Hash
|
|
119
|
+
if isinstance(data, dict) and p in data:
|
|
120
|
+
data = cast(dict[str, Any], data)[p]
|
|
121
|
+
|
|
122
|
+
# Array
|
|
123
|
+
elif isinstance(data, (list, tuple)) and re.fullmatch(r'[0-9]+', p) and len(cast(list[Any], data)) > int(p):
|
|
124
|
+
data = cast(list[Any], data)[int(p)]
|
|
125
|
+
|
|
126
|
+
# Nothing
|
|
127
|
+
else:
|
|
128
|
+
return None
|
|
129
|
+
|
|
130
|
+
return data if get else True
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
new = Pyjo_JSON_Pointer.new
|
|
134
|
+
object = Pyjo_JSON_Pointer
|
|
135
|
+
Pointer = Pyjo_JSON_Pointer
|