Import upstream version 0.4.3.1
Debian Janitor
2 years ago
0 | 0 | Metadata-Version: 2.1 |
1 | 1 | Name: jsonrpclib-pelix |
2 | Version: 0.4.2 | |
2 | Version: 0.4.3.1 | |
3 | 3 | Summary: This project is an implementation of the JSON-RPC v2.0 specification (backwards-compatible) as a client library, for Python 2.7 and Python 3. This version is a fork of jsonrpclib by Josh Marshall, made to be also usable with Pelix/iPOPO remote services. |
4 | 4 | Home-page: http://github.com/tcalmant/jsonrpclib/ |
5 | 5 | Author: Thomas Calmant |
71 | 71 | |
72 | 72 | ## Requirements |
73 | 73 | |
74 | This library supports `cjson` and `simplejson`, and looks for the parsers in | |
75 | that order (searching first for `cjson`, then for the *built-in* `json` in 2.7+, | |
76 | and then the `simplejson` external library). | |
74 | This library supports `ujson`, `cjson` and `simplejson`, and looks for the | |
75 | parsers in that order (searching first for `ujson`, `cjson`, `simplejson` | |
76 | and finally for the *built-in* `json`). | |
77 | 77 | One of these must be installed to use this library, although if you have a |
78 | 78 | standard distribution of 2.7+, you should already have one. |
79 | Keep in mind that `cjson` is supposed to be the quickest, I believe, so if you | |
79 | Keep in mind that `ujson` is supposed to be the quickest, I believe, so if you | |
80 | 80 | are going for full-on optimization you may want to pick it up. |
81 | 81 | |
82 | 82 | ## Installation |
63 | 63 | |
64 | 64 | ## Requirements |
65 | 65 | |
66 | This library supports `cjson` and `simplejson`, and looks for the parsers in | |
67 | that order (searching first for `cjson`, then for the *built-in* `json` in 2.7+, | |
68 | and then the `simplejson` external library). | |
66 | This library supports `ujson`, `cjson` and `simplejson`, and looks for the | |
67 | parsers in that order (searching first for `ujson`, `cjson`, `simplejson` | |
68 | and finally for the *built-in* `json`). | |
69 | 69 | One of these must be installed to use this library, although if you have a |
70 | 70 | standard distribution of 2.7+, you should already have one. |
71 | Keep in mind that `cjson` is supposed to be the quickest, I believe, so if you | |
71 | Keep in mind that `ujson` is supposed to be the quickest, I believe, so if you | |
72 | 72 | are going for full-on optimization you may want to pick it up. |
73 | 73 | |
74 | 74 | ## Installation |
4 | 4 | CGI request handler. |
5 | 5 | |
6 | 6 | :authors: Josh Marshall, Thomas Calmant |
7 | :copyright: Copyright 2020, Thomas Calmant | |
7 | :copyright: Copyright 2021, Thomas Calmant | |
8 | 8 | :license: Apache License 2.0 |
9 | :version: 0.4.2 | |
9 | :version: 0.4.3.1 | |
10 | 10 | |
11 | 11 | .. |
12 | 12 | |
13 | Copyright 2020 Thomas Calmant | |
13 | Copyright 2021 Thomas Calmant | |
14 | 14 | |
15 | 15 | Licensed under the Apache License, Version 2.0 (the "License"); |
16 | 16 | you may not use this file except in compliance with the License. |
82 | 82 | # ------------------------------------------------------------------------------ |
83 | 83 | |
84 | 84 | # Module version |
85 | __version_info__ = (0, 4, 2) | |
85 | __version_info__ = (0, 4, 3, 1) | |
86 | 86 | __version__ = ".".join(str(x) for x in __version_info__) |
87 | 87 | |
88 | 88 | # Documentation strings format |
3 | 3 | Aliases to ease access to jsonrpclib classes |
4 | 4 | |
5 | 5 | :authors: Josh Marshall, Thomas Calmant |
6 | :copyright: Copyright 2020, Thomas Calmant | |
6 | :copyright: Copyright 2021, Thomas Calmant | |
7 | 7 | :license: Apache License 2.0 |
8 | :version: 0.4.2 | |
8 | :version: 0.4.3.1 | |
9 | 9 | |
10 | 10 | .. |
11 | 11 | |
12 | Copyright 2020 Thomas Calmant | |
12 | Copyright 2021 Thomas Calmant | |
13 | 13 | |
14 | 14 | Licensed under the Apache License, Version 2.0 (the "License"); |
15 | 15 | you may not use this file except in compliance with the License. |
42 | 42 | |
43 | 43 | |
44 | 44 | # Module version |
45 | __version_info__ = (0, 4, 2) | |
45 | __version_info__ = (0, 4, 3, 1) | |
46 | 46 | __version__ = ".".join(str(x) for x in __version_info__) |
47 | 47 | |
48 | 48 | # Documentation strings format |
2 | 2 | """ |
3 | 3 | The configuration module. |
4 | 4 | |
5 | :copyright: Copyright 2020, Thomas Calmant | |
5 | :copyright: Copyright 2021, Thomas Calmant | |
6 | 6 | :license: Apache License 2.0 |
7 | :version: 0.4.2 | |
7 | :version: 0.4.3.1 | |
8 | 8 | |
9 | 9 | .. |
10 | 10 | |
11 | Copyright 2020 Thomas Calmant | |
11 | Copyright 2021 Thomas Calmant | |
12 | 12 | |
13 | 13 | Licensed under the Apache License, Version 2.0 (the "License"); |
14 | 14 | you may not use this file except in compliance with the License. |
28 | 28 | # ------------------------------------------------------------------------------ |
29 | 29 | |
30 | 30 | # Module version |
31 | __version_info__ = (0, 4, 2) | |
31 | __version_info__ = (0, 4, 3, 1) | |
32 | 32 | __version__ = ".".join(str(x) for x in __version_info__) |
33 | 33 | |
34 | 34 | # Documentation strings format |
3 | 3 | The history module. |
4 | 4 | |
5 | 5 | :authors: Josh Marshall, Thomas Calmant |
6 | :copyright: Copyright 2020, Thomas Calmant | |
6 | :copyright: Copyright 2021, Thomas Calmant | |
7 | 7 | :license: Apache License 2.0 |
8 | :version: 0.4.2 | |
8 | :version: 0.4.3.1 | |
9 | 9 | |
10 | 10 | .. |
11 | 11 | |
12 | Copyright 2020 Thomas Calmant | |
12 | Copyright 2021 Thomas Calmant | |
13 | 13 | |
14 | 14 | Licensed under the Apache License, Version 2.0 (the "License"); |
15 | 15 | you may not use this file except in compliance with the License. |
25 | 25 | """ |
26 | 26 | |
27 | 27 | # Module version |
28 | __version_info__ = (0, 4, 2) | |
28 | __version_info__ = (0, 4, 3, 1) | |
29 | 29 | __version__ = ".".join(str(x) for x in __version_info__) |
30 | 30 | |
31 | 31 | # Documentation strings format |
3 | 3 | The serialization module |
4 | 4 | |
5 | 5 | :authors: Josh Marshall, Thomas Calmant |
6 | :copyright: Copyright 2020, Thomas Calmant | |
6 | :copyright: Copyright 2021, Thomas Calmant | |
7 | 7 | :license: Apache License 2.0 |
8 | :version: 0.4.2 | |
8 | :version: 0.4.3.1 | |
9 | 9 | |
10 | 10 | .. |
11 | 11 | |
12 | Copyright 2020 Thomas Calmant | |
12 | Copyright 2021 Thomas Calmant | |
13 | 13 | |
14 | 14 | Licensed under the Apache License, Version 2.0 (the "License"); |
15 | 15 | you may not use this file except in compliance with the License. |
35 | 35 | # ------------------------------------------------------------------------------ |
36 | 36 | |
37 | 37 | # Module version |
38 | __version_info__ = (0, 4, 2) | |
38 | __version_info__ = (0, 4, 3, 1) | |
39 | 39 | __version__ = ".".join(str(x) for x in __version_info__) |
40 | 40 | |
41 | 41 | # Documentation strings format |
0 | #!/usr/bin/python | |
1 | # -- Content-Encoding: UTF-8 -- | |
2 | """ | |
3 | Loads the "best" Python library available for the current interpreter and | |
4 | provides a single interface for all | |
5 | ||
6 | :authors: Thomas Calmant | |
7 | :copyright: Copyright 2021, Thomas Calmant | |
8 | :license: Apache License 2.0 | |
9 | :version: 0.4.3.1 | |
10 | ||
11 | .. | |
12 | ||
13 | Copyright 2021 Thomas Calmant | |
14 | ||
15 | Licensed under the Apache License, Version 2.0 (the "License"); | |
16 | you may not use this file except in compliance with the License. | |
17 | You may obtain a copy of the License at | |
18 | ||
19 | http://www.apache.org/licenses/LICENSE-2.0 | |
20 | ||
21 | Unless required by applicable law or agreed to in writing, software | |
22 | distributed under the License is distributed on an "AS IS" BASIS, | |
23 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
24 | See the License for the specific language governing permissions and | |
25 | limitations under the License. | |
26 | """ | |
27 | ||
28 | # Standard library | |
29 | import json | |
30 | import sys | |
31 | ||
32 | # ------------------------------------------------------------------------------ | |
33 | ||
34 | # Module version | |
35 | __version_info__ = (0, 4, 3, 1) | |
36 | __version__ = ".".join(str(x) for x in __version_info__) | |
37 | ||
38 | # Documentation strings format | |
39 | __docformat__ = "restructuredtext en" | |
40 | ||
41 | # Python version flag | |
42 | PYTHON_2 = sys.version_info[0] < 3 | |
43 | ||
44 | # ------------------------------------------------------------------------------ | |
45 | ||
46 | ||
47 | class JsonHandler(object): | |
48 | """ | |
49 | Parent class for JSON handlers | |
50 | """ | |
51 | ||
52 | def get_methods(self): | |
53 | """ | |
54 | Returns the loads and dumps methods | |
55 | """ | |
56 | if PYTHON_2: | |
57 | # We use the Py2 API with an encoding argument | |
58 | return json.loads, json.dumps | |
59 | ||
60 | def dumps_py3(obj, encoding="utf-8"): | |
61 | return json.dumps(obj) | |
62 | ||
63 | return json.loads, dumps_py3 | |
64 | ||
65 | ||
66 | class CJsonHandler(JsonHandler): | |
67 | """ | |
68 | Handler based on cjson | |
69 | """ | |
70 | ||
71 | def get_methods(self): | |
72 | import cjson | |
73 | ||
74 | def dumps_cjson(obj, encoding="utf-8"): | |
75 | return cjson.encode(obj) | |
76 | ||
77 | return cjson.decode, dumps_cjson | |
78 | ||
79 | ||
80 | class SimpleJsonHandler(JsonHandler): | |
81 | """ | |
82 | Handler based on simplejson | |
83 | """ | |
84 | ||
85 | def get_methods(self): | |
86 | import simplejson | |
87 | ||
88 | return simplejson.loads, simplejson.dumps | |
89 | ||
90 | ||
91 | class UJsonHandler(JsonHandler): | |
92 | """ | |
93 | Handler based on ujson | |
94 | """ | |
95 | ||
96 | def get_methods(self): | |
97 | import ujson | |
98 | ||
99 | def dumps_ujson(obj, encoding="utf-8"): | |
100 | return ujson.dumps(obj) | |
101 | ||
102 | return ujson.loads, dumps_ujson | |
103 | ||
104 | ||
105 | def get_handler(): | |
106 | # type: () -> JsonHandler | |
107 | """ | |
108 | Returns the best available Json parser | |
109 | """ | |
110 | for handler_class in (UJsonHandler, SimpleJsonHandler, CJsonHandler): | |
111 | handler = handler_class() | |
112 | try: | |
113 | loader, dumper = handler.get_methods() | |
114 | except ImportError: | |
115 | # Library is missing | |
116 | pass | |
117 | else: | |
118 | try: | |
119 | # Check if the library really works | |
120 | loader(dumper({"answer": 42})) | |
121 | break | |
122 | except Exception: | |
123 | pass | |
124 | else: | |
125 | handler = JsonHandler() | |
126 | ||
127 | return handler | |
128 | ||
129 | ||
130 | def get_handler_methods(): | |
131 | """ | |
132 | Returns the load and dump methods of the best Json handler | |
133 | """ | |
134 | return get_handler().get_methods() |
35 | 35 | See https://github.com/tcalmant/jsonrpclib for more info. |
36 | 36 | |
37 | 37 | :authors: Josh Marshall, Thomas Calmant |
38 | :copyright: Copyright 2020, Thomas Calmant | |
38 | :copyright: Copyright 2021, Thomas Calmant | |
39 | 39 | :license: Apache License 2.0 |
40 | :version: 0.4.2 | |
40 | :version: 0.4.3.1 | |
41 | 41 | |
42 | 42 | .. |
43 | 43 | |
44 | Copyright 2020 Thomas Calmant | |
44 | Copyright 2021 Thomas Calmant | |
45 | 45 | |
46 | 46 | Licensed under the Apache License, Version 2.0 (the "License"); |
47 | 47 | you may not use this file except in compliance with the License. |
61 | 61 | import logging |
62 | 62 | import os |
63 | 63 | import socket |
64 | import sys | |
65 | 64 | import uuid |
66 | 65 | |
67 | 66 | try: |
93 | 92 | |
94 | 93 | # Library includes |
95 | 94 | import jsonrpclib.config |
95 | import jsonrpclib.jsonlib as jsonlib | |
96 | 96 | import jsonrpclib.jsonclass as jsonclass |
97 | 97 | import jsonrpclib.utils as utils |
98 | 98 | |
99 | 99 | # ------------------------------------------------------------------------------ |
100 | 100 | |
101 | 101 | # Module version |
102 | __version_info__ = (0, 4, 2) | |
102 | __version_info__ = (0, 4, 3, 1) | |
103 | 103 | __version__ = ".".join(str(x) for x in __version_info__) |
104 | 104 | |
105 | 105 | # Documentation strings format |
109 | 109 | _logger = logging.getLogger(__name__) |
110 | 110 | |
111 | 111 | # ------------------------------------------------------------------------------ |
112 | # JSON library import | |
113 | ||
114 | try: | |
115 | # pylint: disable=F0401,E0611 | |
116 | # Using cjson | |
117 | import cjson # type: ignore | |
118 | ||
119 | _logger.debug("Using cjson as JSON library") | |
120 | ||
121 | # Declare cjson methods | |
122 | def jdumps(obj, encoding="utf-8"): # pylint: disable=unused-argument | |
123 | """ | |
124 | Serializes ``obj`` to a JSON formatted string, using cjson. | |
125 | """ | |
126 | return cjson.encode(obj) | |
127 | ||
128 | def jloads(json_string): | |
129 | """ | |
130 | Deserializes ``json_string`` (a string containing a JSON document) | |
131 | to a Python object, using cjson. | |
132 | """ | |
133 | return cjson.decode(json_string) | |
134 | ||
135 | ||
136 | except ImportError: | |
137 | # pylint: disable=F0401,E0611 | |
138 | # Use json or simplejson | |
139 | try: | |
140 | import json | |
141 | ||
142 | _logger.debug("Using json as JSON library") | |
143 | except ImportError: | |
144 | try: | |
145 | import simplejson as json # type: ignore | |
146 | ||
147 | _logger.debug("Using simplejson as JSON library") | |
148 | except ImportError: | |
149 | _logger.error("No supported JSON library found") | |
150 | raise ImportError( | |
151 | "You must have the cjson, json, or simplejson " | |
152 | "module(s) available." | |
153 | ) | |
154 | ||
155 | # Declare json methods | |
156 | if sys.version_info[0] < 3: | |
157 | ||
158 | def jdumps(obj, encoding="utf-8"): | |
159 | """ | |
160 | Serializes ``obj`` to a JSON formatted string. | |
161 | """ | |
162 | # Python 2 (explicit encoding) | |
163 | return json.dumps(obj, encoding=encoding) | |
164 | ||
165 | else: | |
166 | # Python 3 | |
167 | def jdumps(obj, encoding="utf-8"): # pylint: disable=unused-argument | |
168 | """ | |
169 | Serializes ``obj`` to a JSON formatted string. | |
170 | """ | |
171 | # Python 3 (the encoding parameter has been removed) | |
172 | return json.dumps(obj) | |
173 | ||
174 | def jloads(json_string): | |
175 | """ | |
176 | Deserializes ``json_string`` (a string containing a JSON document) | |
177 | to a Python object. | |
178 | """ | |
179 | return json.loads(json_string) | |
180 | ||
112 | # JSON library selection | |
113 | ||
114 | jloads, jdumps = jsonlib.get_handler_methods() | |
181 | 115 | |
182 | 116 | # ------------------------------------------------------------------------------ |
183 | 117 | # XMLRPClib re-implementations |
628 | 562 | schema = su.scheme |
629 | 563 | self.__host = su.netloc |
630 | 564 | self.__handler = su.path |
565 | self.__query_string = su.query | |
631 | 566 | |
632 | 567 | use_unix = False |
633 | 568 | if schema.startswith("unix+"): |
726 | 661 | if self.__history is not None: |
727 | 662 | self.__history.add_request(request) |
728 | 663 | |
664 | # Add the query string to the path | |
665 | if not self.__query_string: | |
666 | path_qs = self.__handler | |
667 | else: | |
668 | path_qs = "{}?{}".format(self.__handler, self.__query_string) | |
669 | ||
729 | 670 | response = self.__transport.request( |
730 | self.__host, self.__handler, request, verbose=self.__verbose | |
671 | self.__host, path_qs, request, verbose=self.__verbose | |
731 | 672 | ) |
732 | 673 | |
733 | 674 | # Here, the XMLRPC library translates a single list |
3 | 3 | Cached thread pool, inspired from Pelix/iPOPO Thread Pool |
4 | 4 | |
5 | 5 | :author: Thomas Calmant |
6 | :copyright: Copyright 2020, Thomas Calmant | |
6 | :copyright: Copyright 2021, Thomas Calmant | |
7 | 7 | :license: Apache License 2.0 |
8 | :version: 0.4.2 | |
8 | :version: 0.4.3.1 | |
9 | 9 | |
10 | 10 | .. |
11 | 11 | |
12 | Copyright 2020 Thomas Calmant | |
12 | Copyright 2021 Thomas Calmant | |
13 | 13 | |
14 | 14 | Licensed under the Apache License, Version 2.0 (the "License"); |
15 | 15 | you may not use this file except in compliance with the License. |
38 | 38 | # ------------------------------------------------------------------------------ |
39 | 39 | |
40 | 40 | # Module version |
41 | __version_info__ = (0, 4, 2) | |
41 | __version_info__ = (0, 4, 3, 1) | |
42 | 42 | __version__ = ".".join(str(x) for x in __version_info__) |
43 | 43 | |
44 | 44 | # Documentation strings format |
3 | 3 | Utility methods, for compatibility between Python version |
4 | 4 | |
5 | 5 | :author: Thomas Calmant |
6 | :copyright: Copyright 2020, Thomas Calmant | |
6 | :copyright: Copyright 2021, Thomas Calmant | |
7 | 7 | :license: Apache License 2.0 |
8 | :version: 0.4.2 | |
8 | :version: 0.4.3.1 | |
9 | 9 | |
10 | 10 | .. |
11 | 11 | |
12 | Copyright 2020 Thomas Calmant | |
12 | Copyright 2021 Thomas Calmant | |
13 | 13 | |
14 | 14 | Licensed under the Apache License, Version 2.0 (the "License"); |
15 | 15 | you may not use this file except in compliance with the License. |
29 | 29 | # ------------------------------------------------------------------------------ |
30 | 30 | |
31 | 31 | # Module version |
32 | __version_info__ = (0, 4, 2) | |
32 | __version_info__ = (0, 4, 3, 1) | |
33 | 33 | __version__ = ".".join(str(x) for x in __version_info__) |
34 | 34 | |
35 | 35 | # Documentation strings format |
0 | 0 | Metadata-Version: 2.1 |
1 | 1 | Name: jsonrpclib-pelix |
2 | Version: 0.4.2 | |
2 | Version: 0.4.3.1 | |
3 | 3 | Summary: This project is an implementation of the JSON-RPC v2.0 specification (backwards-compatible) as a client library, for Python 2.7 and Python 3. This version is a fork of jsonrpclib by Josh Marshall, made to be also usable with Pelix/iPOPO remote services. |
4 | 4 | Home-page: http://github.com/tcalmant/jsonrpclib/ |
5 | 5 | Author: Thomas Calmant |
71 | 71 | |
72 | 72 | ## Requirements |
73 | 73 | |
74 | This library supports `cjson` and `simplejson`, and looks for the parsers in | |
75 | that order (searching first for `cjson`, then for the *built-in* `json` in 2.7+, | |
76 | and then the `simplejson` external library). | |
74 | This library supports `ujson`, `cjson` and `simplejson`, and looks for the | |
75 | parsers in that order (searching first for `ujson`, `cjson`, `simplejson` | |
76 | and finally for the *built-in* `json`). | |
77 | 77 | One of these must be installed to use this library, although if you have a |
78 | 78 | standard distribution of 2.7+, you should already have one. |
79 | Keep in mind that `cjson` is supposed to be the quickest, I believe, so if you | |
79 | Keep in mind that `ujson` is supposed to be the quickest, I believe, so if you | |
80 | 80 | are going for full-on optimization you may want to pick it up. |
81 | 81 | |
82 | 82 | ## Installation |
0 | 0 | LICENSE |
1 | 1 | MANIFEST.in |
2 | 2 | README.md |
3 | pyproject.toml | |
3 | 4 | setup.cfg |
4 | 5 | setup.py |
5 | 6 | jsonrpclib/SimpleJSONRPCServer.py |
7 | 8 | jsonrpclib/config.py |
8 | 9 | jsonrpclib/history.py |
9 | 10 | jsonrpclib/jsonclass.py |
11 | jsonrpclib/jsonlib.py | |
10 | 12 | jsonrpclib/jsonrpc.py |
11 | 13 | jsonrpclib/threadpool.py |
12 | 14 | jsonrpclib/utils.py |
3 | 3 | [flake8] |
4 | 4 | max-line-length = 80 |
5 | 5 | |
6 | [nosetests] | |
7 | traverse-namespace = 1 | |
8 | ||
6 | 9 | [egg_info] |
7 | 10 | tag_build = |
8 | 11 | tag_date = 0 |
3 | 3 | Installation script |
4 | 4 | |
5 | 5 | :authors: Josh Marshall, Thomas Calmant |
6 | :copyright: Copyright 2020, Thomas Calmant | |
6 | :copyright: Copyright 2021, Thomas Calmant | |
7 | 7 | :license: Apache License 2.0 |
8 | :version: 0.4.2 | |
8 | :version: 0.4.3.1 | |
9 | 9 | |
10 | 10 | .. |
11 | 11 | |
12 | Copyright 2020 Thomas Calmant | |
12 | Copyright 2021 Thomas Calmant | |
13 | 13 | |
14 | 14 | Licensed under the Apache License, Version 2.0 (the "License"); |
15 | 15 | you may not use this file except in compliance with the License. |
25 | 25 | """ |
26 | 26 | |
27 | 27 | # Module version |
28 | __version_info__ = (0, 4, 2) | |
28 | __version_info__ = (0, 4, 3, 1) | |
29 | 29 | __version__ = ".".join(str(x) for x in __version_info__) |
30 | 30 | |
31 | 31 | # Documentation strings format |