chisel 1.2.4__tar.gz → 1.2.6__tar.gz

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.
chisel-1.2.6/PKG-INFO ADDED
@@ -0,0 +1,113 @@
1
+ Metadata-Version: 2.1
2
+ Name: chisel
3
+ Version: 1.2.6
4
+ Summary: Lightweight WSGI application framework, schema-validated JSON APIs, and API documentation
5
+ Home-page: https://github.com/craigahobbs/chisel
6
+ Author: Craig A. Hobbs
7
+ Author-email: craigahobbs@gmail.com
8
+ License: MIT
9
+ Keywords: api,json,framework,schema,wsgi
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Internet :: WWW/HTTP :: WSGI
20
+ Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Application
21
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: schema-markdown>=1.2.0
25
+
26
+ # chisel
27
+
28
+ [![PyPI - Status](https://img.shields.io/pypi/status/chisel)](https://pypi.org/project/chisel/)
29
+ [![PyPI](https://img.shields.io/pypi/v/chisel)](https://pypi.org/project/chisel/)
30
+ [![GitHub](https://img.shields.io/github/license/craigahobbs/chisel)](https://github.com/craigahobbs/chisel/blob/main/LICENSE)
31
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/chisel)](https://pypi.org/project/chisel/)
32
+
33
+ Chisel is a light-weight Python WSGI application framework built for creating well-documented,
34
+ schema-validated JSON web APIs.
35
+
36
+
37
+ ## Links
38
+
39
+ - [API Documentation](https://craigahobbs.github.io/chisel/)
40
+ - [Source code](https://github.com/craigahobbs/chisel)
41
+
42
+
43
+ ## JSON APIs
44
+
45
+ Chisel provides the [action](https://craigahobbs.github.io/chisel/action.html#chisel.action)
46
+ decorator for easily implementing schema-validated JSON APIs.
47
+
48
+ ~~~ python
49
+ @chisel.action(spec='''
50
+ # Sum a list of numbers
51
+ action sum_numbers
52
+ urls
53
+ GET
54
+
55
+ query
56
+ # The list of numbers
57
+ float[len > 0] numbers
58
+
59
+ output
60
+ # The sum of the numbers
61
+ float sum
62
+ ''')
63
+ def sum_numbers(ctx, req):
64
+ return {'sum': sum(req['numbers'])}
65
+
66
+ application = chisel.Application()
67
+ application.add_request(sum_numbers)
68
+ application.request('GET', '/sum_numbers', query_string='numbers.0=1&numbers.1=2&numbers.2=4')
69
+
70
+ ('200 OK', [('Content-Type', 'application/json')], b'{"sum":7.0}')
71
+ ~~~
72
+
73
+ Each action defines an ``action`` definition using
74
+ [Schema Markdown](https://craigahobbs.github.io/schema-markdown-js/language/).
75
+ The action callback is passed two arguments, a request
76
+ [Context](https://craigahobbs.github.io/chisel/app.html#chisel.Context)
77
+ and the schema-validated request input dictionary. The input request dictionary is created by
78
+ combining the request's URL path parameters, query string parameters, and input JSON content
79
+ parameters.
80
+
81
+ If there is a schema validation error the appropriate error code is automatically returned.
82
+
83
+ ~~~ python
84
+ status, _, content_bytes = application.request('GET', '/sum_numbers')
85
+
86
+ '400 Bad Request'
87
+ b'{"error":"InvalidInput","message":"Required member \'numbers\' missing (query string)"}'
88
+ ~~~
89
+
90
+
91
+ ## API Documentation
92
+
93
+ You can add API documentation to your application by adding the Chisel documentation application
94
+ requests from
95
+ [create_doc_requests](https://craigahobbs.github.io/chisel/request.html#chisel.create_doc_requests).
96
+
97
+ ~~~ python
98
+ application = chisel.Application()
99
+ application.add_requests(chisel.create_doc_requests())
100
+ ~~~
101
+
102
+ By default the documentation application is hosted at "/doc/". An example of of Chisel's documentation output is
103
+ available [here](https://craigahobbs.github.io/chisel/example/#var.vName='chisel_doc_request').
104
+
105
+
106
+ ## Development
107
+
108
+ This package is developed using [python-build](https://github.com/craigahobbs/python-build#readme).
109
+ It was started using [python-template](https://github.com/craigahobbs/python-template#readme) as follows:
110
+
111
+ ~~~ sh
112
+ template-specialize python-template/template/ chisel/ -k package chisel -k name 'Craig A. Hobbs' -k email 'craigahobbs@gmail.com' -k github 'craigahobbs' -k nomain 1
113
+ ~~~
chisel-1.2.6/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # chisel
2
+
3
+ [![PyPI - Status](https://img.shields.io/pypi/status/chisel)](https://pypi.org/project/chisel/)
4
+ [![PyPI](https://img.shields.io/pypi/v/chisel)](https://pypi.org/project/chisel/)
5
+ [![GitHub](https://img.shields.io/github/license/craigahobbs/chisel)](https://github.com/craigahobbs/chisel/blob/main/LICENSE)
6
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/chisel)](https://pypi.org/project/chisel/)
7
+
8
+ Chisel is a light-weight Python WSGI application framework built for creating well-documented,
9
+ schema-validated JSON web APIs.
10
+
11
+
12
+ ## Links
13
+
14
+ - [API Documentation](https://craigahobbs.github.io/chisel/)
15
+ - [Source code](https://github.com/craigahobbs/chisel)
16
+
17
+
18
+ ## JSON APIs
19
+
20
+ Chisel provides the [action](https://craigahobbs.github.io/chisel/action.html#chisel.action)
21
+ decorator for easily implementing schema-validated JSON APIs.
22
+
23
+ ~~~ python
24
+ @chisel.action(spec='''
25
+ # Sum a list of numbers
26
+ action sum_numbers
27
+ urls
28
+ GET
29
+
30
+ query
31
+ # The list of numbers
32
+ float[len > 0] numbers
33
+
34
+ output
35
+ # The sum of the numbers
36
+ float sum
37
+ ''')
38
+ def sum_numbers(ctx, req):
39
+ return {'sum': sum(req['numbers'])}
40
+
41
+ application = chisel.Application()
42
+ application.add_request(sum_numbers)
43
+ application.request('GET', '/sum_numbers', query_string='numbers.0=1&numbers.1=2&numbers.2=4')
44
+
45
+ ('200 OK', [('Content-Type', 'application/json')], b'{"sum":7.0}')
46
+ ~~~
47
+
48
+ Each action defines an ``action`` definition using
49
+ [Schema Markdown](https://craigahobbs.github.io/schema-markdown-js/language/).
50
+ The action callback is passed two arguments, a request
51
+ [Context](https://craigahobbs.github.io/chisel/app.html#chisel.Context)
52
+ and the schema-validated request input dictionary. The input request dictionary is created by
53
+ combining the request's URL path parameters, query string parameters, and input JSON content
54
+ parameters.
55
+
56
+ If there is a schema validation error the appropriate error code is automatically returned.
57
+
58
+ ~~~ python
59
+ status, _, content_bytes = application.request('GET', '/sum_numbers')
60
+
61
+ '400 Bad Request'
62
+ b'{"error":"InvalidInput","message":"Required member \'numbers\' missing (query string)"}'
63
+ ~~~
64
+
65
+
66
+ ## API Documentation
67
+
68
+ You can add API documentation to your application by adding the Chisel documentation application
69
+ requests from
70
+ [create_doc_requests](https://craigahobbs.github.io/chisel/request.html#chisel.create_doc_requests).
71
+
72
+ ~~~ python
73
+ application = chisel.Application()
74
+ application.add_requests(chisel.create_doc_requests())
75
+ ~~~
76
+
77
+ By default the documentation application is hosted at "/doc/". An example of of Chisel's documentation output is
78
+ available [here](https://craigahobbs.github.io/chisel/example/#var.vName='chisel_doc_request').
79
+
80
+
81
+ ## Development
82
+
83
+ This package is developed using [python-build](https://github.com/craigahobbs/python-build#readme).
84
+ It was started using [python-template](https://github.com/craigahobbs/python-template#readme) as follows:
85
+
86
+ ~~~ sh
87
+ template-specialize python-template/template/ chisel/ -k package chisel -k name 'Craig A. Hobbs' -k email 'craigahobbs@gmail.com' -k github 'craigahobbs' -k nomain 1
88
+ ~~~
@@ -1,13 +1,13 @@
1
1
  [metadata]
2
2
  name = chisel
3
- version = 1.2.4
3
+ version = 1.2.6
4
4
  url = https://github.com/craigahobbs/chisel
5
5
  author = Craig A. Hobbs
6
6
  author_email = craigahobbs@gmail.com
7
7
  license = MIT
8
8
  description = Lightweight WSGI application framework, schema-validated JSON APIs, and API documentation
9
- long_description = file:README.rst
10
- long_description_content_type = text/x-rst
9
+ long_description = file:README.md
10
+ long_description_content_type = text/markdown
11
11
  keywords = api, json, framework, schema, wsgi
12
12
  classifiers =
13
13
  Development Status :: 5 - Production/Stable
@@ -97,6 +97,59 @@ class Application:
97
97
  for request in requests:
98
98
  self.add_request(request)
99
99
 
100
+ def match_request(self, request_method, path_info):
101
+ """
102
+ Match an application request by request method and path
103
+
104
+ :param request_method: The request method
105
+ :type request_method: str
106
+ :param path_info: The request path
107
+ :type path_info: str
108
+ :return: A tuple of :class:`~chisel.Request` and URL argument :class:`dict`. If the request is None,
109
+ there is no matching request. If the URL argument dict is None, there are no URL arguments.
110
+ :rtype: tuple(chisel.Request or None, dict or None)
111
+ """
112
+
113
+ # Exact match?
114
+ request = self.__request_urls.get((request_method, path_info))
115
+ if request is not None:
116
+ return request, None
117
+
118
+ # Match the request by method and URL regex
119
+ request, url_args = next(
120
+ (
121
+ (request, {unquote(url_arg): unquote(url_value) for url_arg, url_value in request_match.groupdict().items()})
122
+ for request, request_match in
123
+ (
124
+ (request, regex.match(path_info)) for method, regex, request in self.__request_regex
125
+ if method is not None and method == request_method
126
+ )
127
+ if request_match
128
+ ),
129
+ (None, None)
130
+ )
131
+ if request is not None:
132
+ return request, url_args
133
+
134
+ # Match the request by exact URL (any method)
135
+ request, url_args = self.__request_urls.get((None, path_info)), None
136
+ if request is None:
137
+
138
+ # Match the request by URL regex (any method)
139
+ request, url_args = next(
140
+ (
141
+ (request, {unquote(url_arg): unquote(url_value) for url_arg, url_value in request_match.groupdict().items()})
142
+ for request, request_match in
143
+ (
144
+ (request, regex.match(path_info)) for method, regex, request in self.__request_regex
145
+ if method is None
146
+ )
147
+ if request_match
148
+ ),
149
+ (None, None)
150
+ )
151
+ return request, url_args
152
+
100
153
  def __call__(self, environ, start_response):
101
154
  """
102
155
  The chisel application WSGI callback. When the application recieves an HTTP request, this method matches the
@@ -109,47 +162,15 @@ class Application:
109
162
  :returns: The WSGI content iterable
110
163
  """
111
164
 
112
- # Match the request by method and exact URL
113
- path_info = environ['PATH_INFO']
165
+ # HEAD request?
114
166
  request_method = environ['REQUEST_METHOD'].upper()
115
167
  is_head = (request_method == 'HEAD')
116
168
  if is_head:
117
169
  request_method = environ['REQUEST_METHOD'] = 'GET'
118
- request, url_args = self.__request_urls.get((request_method, path_info)), None
119
- if request is None:
120
170
 
121
- # Match the request by method and URL regex
122
- request, url_args = next(
123
- (
124
- (request, {unquote(url_arg): unquote(url_value) for url_arg, url_value in request_match.groupdict().items()})
125
- for request, request_match in
126
- (
127
- (request, regex.match(path_info)) for method, regex, request in self.__request_regex
128
- if method is not None and method == request_method
129
- )
130
- if request_match
131
- ),
132
- (None, None)
133
- )
134
- if request is None:
135
-
136
- # Match the request by exact URL (any method)
137
- request, url_args = self.__request_urls.get((None, path_info)), None
138
- if request is None:
139
-
140
- # Match the request by URL regex (any method)
141
- request, url_args = next(
142
- (
143
- (request, {unquote(url_arg): unquote(url_value) for url_arg, url_value in request_match.groupdict().items()})
144
- for request, request_match in
145
- (
146
- (request, regex.match(path_info)) for method, regex, request in self.__request_regex
147
- if method is None
148
- )
149
- if request_match
150
- ),
151
- (None, None)
152
- )
171
+ # Match the request by method and exact URL
172
+ path_info = environ['PATH_INFO']
173
+ request, url_args = self.match_request(request_method, path_info)
153
174
 
154
175
  # Create the request context
155
176
  ctx = environ[Context.ENVIRON_CTX] = Context(self, environ, start_response, url_args)
@@ -56,6 +56,7 @@ CHISEL_DOC_HTML = b'''\
56
56
  'markdownText': `\
57
57
  ~~~ markdown-script
58
58
  include 'https://craigahobbs.github.io/chisel/doc/app.mds'
59
+
59
60
  chiselDoc()
60
61
  ~~~
61
62
  `});
@@ -0,0 +1,113 @@
1
+ Metadata-Version: 2.1
2
+ Name: chisel
3
+ Version: 1.2.6
4
+ Summary: Lightweight WSGI application framework, schema-validated JSON APIs, and API documentation
5
+ Home-page: https://github.com/craigahobbs/chisel
6
+ Author: Craig A. Hobbs
7
+ Author-email: craigahobbs@gmail.com
8
+ License: MIT
9
+ Keywords: api,json,framework,schema,wsgi
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Internet :: WWW/HTTP :: WSGI
20
+ Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Application
21
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: schema-markdown>=1.2.0
25
+
26
+ # chisel
27
+
28
+ [![PyPI - Status](https://img.shields.io/pypi/status/chisel)](https://pypi.org/project/chisel/)
29
+ [![PyPI](https://img.shields.io/pypi/v/chisel)](https://pypi.org/project/chisel/)
30
+ [![GitHub](https://img.shields.io/github/license/craigahobbs/chisel)](https://github.com/craigahobbs/chisel/blob/main/LICENSE)
31
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/chisel)](https://pypi.org/project/chisel/)
32
+
33
+ Chisel is a light-weight Python WSGI application framework built for creating well-documented,
34
+ schema-validated JSON web APIs.
35
+
36
+
37
+ ## Links
38
+
39
+ - [API Documentation](https://craigahobbs.github.io/chisel/)
40
+ - [Source code](https://github.com/craigahobbs/chisel)
41
+
42
+
43
+ ## JSON APIs
44
+
45
+ Chisel provides the [action](https://craigahobbs.github.io/chisel/action.html#chisel.action)
46
+ decorator for easily implementing schema-validated JSON APIs.
47
+
48
+ ~~~ python
49
+ @chisel.action(spec='''
50
+ # Sum a list of numbers
51
+ action sum_numbers
52
+ urls
53
+ GET
54
+
55
+ query
56
+ # The list of numbers
57
+ float[len > 0] numbers
58
+
59
+ output
60
+ # The sum of the numbers
61
+ float sum
62
+ ''')
63
+ def sum_numbers(ctx, req):
64
+ return {'sum': sum(req['numbers'])}
65
+
66
+ application = chisel.Application()
67
+ application.add_request(sum_numbers)
68
+ application.request('GET', '/sum_numbers', query_string='numbers.0=1&numbers.1=2&numbers.2=4')
69
+
70
+ ('200 OK', [('Content-Type', 'application/json')], b'{"sum":7.0}')
71
+ ~~~
72
+
73
+ Each action defines an ``action`` definition using
74
+ [Schema Markdown](https://craigahobbs.github.io/schema-markdown-js/language/).
75
+ The action callback is passed two arguments, a request
76
+ [Context](https://craigahobbs.github.io/chisel/app.html#chisel.Context)
77
+ and the schema-validated request input dictionary. The input request dictionary is created by
78
+ combining the request's URL path parameters, query string parameters, and input JSON content
79
+ parameters.
80
+
81
+ If there is a schema validation error the appropriate error code is automatically returned.
82
+
83
+ ~~~ python
84
+ status, _, content_bytes = application.request('GET', '/sum_numbers')
85
+
86
+ '400 Bad Request'
87
+ b'{"error":"InvalidInput","message":"Required member \'numbers\' missing (query string)"}'
88
+ ~~~
89
+
90
+
91
+ ## API Documentation
92
+
93
+ You can add API documentation to your application by adding the Chisel documentation application
94
+ requests from
95
+ [create_doc_requests](https://craigahobbs.github.io/chisel/request.html#chisel.create_doc_requests).
96
+
97
+ ~~~ python
98
+ application = chisel.Application()
99
+ application.add_requests(chisel.create_doc_requests())
100
+ ~~~
101
+
102
+ By default the documentation application is hosted at "/doc/". An example of of Chisel's documentation output is
103
+ available [here](https://craigahobbs.github.io/chisel/example/#var.vName='chisel_doc_request').
104
+
105
+
106
+ ## Development
107
+
108
+ This package is developed using [python-build](https://github.com/craigahobbs/python-build#readme).
109
+ It was started using [python-template](https://github.com/craigahobbs/python-template#readme) as follows:
110
+
111
+ ~~~ sh
112
+ template-specialize python-template/template/ chisel/ -k package chisel -k name 'Craig A. Hobbs' -k email 'craigahobbs@gmail.com' -k github 'craigahobbs' -k nomain 1
113
+ ~~~
@@ -1,5 +1,5 @@
1
1
  LICENSE
2
- README.rst
2
+ README.md
3
3
  pyproject.toml
4
4
  setup.cfg
5
5
  src/chisel/__init__.py
chisel-1.2.4/PKG-INFO DELETED
@@ -1,126 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: chisel
3
- Version: 1.2.4
4
- Summary: Lightweight WSGI application framework, schema-validated JSON APIs, and API documentation
5
- Home-page: https://github.com/craigahobbs/chisel
6
- Author: Craig A. Hobbs
7
- Author-email: craigahobbs@gmail.com
8
- License: MIT
9
- Keywords: api,json,framework,schema,wsgi
10
- Classifier: Development Status :: 5 - Production/Stable
11
- Classifier: Intended Audience :: Developers
12
- Classifier: License :: OSI Approved :: MIT License
13
- Classifier: Operating System :: OS Independent
14
- Classifier: Programming Language :: Python :: 3.8
15
- Classifier: Programming Language :: Python :: 3.9
16
- Classifier: Programming Language :: Python :: 3.10
17
- Classifier: Programming Language :: Python :: 3.11
18
- Classifier: Programming Language :: Python :: 3.12
19
- Classifier: Topic :: Internet :: WWW/HTTP :: WSGI
20
- Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Application
21
- Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
22
- Description-Content-Type: text/x-rst
23
- License-File: LICENSE
24
- Requires-Dist: schema-markdown>=1.2.0
25
-
26
- chisel
27
- ======
28
-
29
- .. |badge-status| image:: https://img.shields.io/pypi/status/chisel
30
- :alt: PyPI - Status
31
- :target: https://pypi.python.org/pypi/chisel/
32
-
33
- .. |badge-version| image:: https://img.shields.io/pypi/v/chisel
34
- :alt: PyPI
35
- :target: https://pypi.python.org/pypi/chisel/
36
-
37
- .. |badge-license| image:: https://img.shields.io/github/license/craigahobbs/chisel
38
- :alt: GitHub
39
- :target: https://github.com/craigahobbs/chisel/blob/main/LICENSE
40
-
41
- .. |badge-python| image:: https://img.shields.io/pypi/pyversions/chisel
42
- :alt: PyPI - Python Version
43
- :target: https://www.python.org/downloads/
44
-
45
- |badge-status| |badge-version| |badge-license| |badge-python|
46
-
47
- Chisel is a light-weight Python WSGI application framework built for creating well-documented,
48
- schema-validated JSON web APIs.
49
-
50
-
51
- Links
52
- -----
53
-
54
- - `API Documentation <https://craigahobbs.github.io/chisel/>`__
55
- - `Source code <https://github.com/craigahobbs/chisel>`__
56
-
57
-
58
- JSON APIs
59
- ---------
60
-
61
- Chisel provides the `action <https://craigahobbs.github.io/chisel/action.html#chisel.action>`__
62
- decorator for easily implementing schema-validated JSON APIs.
63
-
64
- >>> @chisel.action(spec='''
65
- ... # Sum a list of numbers
66
- ... action sum_numbers
67
- ... urls
68
- ... GET
69
- ...
70
- ... query
71
- ... # The list of numbers
72
- ... float[len > 0] numbers
73
- ...
74
- ... output
75
- ... # The sum of the numbers
76
- ... float sum
77
- ... ''')
78
- ... def sum_numbers(ctx, req):
79
- ... return {'sum': sum(req['numbers'])}
80
- ...
81
- >>> application = chisel.Application()
82
- >>> application.add_request(sum_numbers)
83
- >>> application.request('GET', '/sum_numbers', query_string='numbers.0=1&numbers.1=2&numbers.2=4')
84
- ('200 OK', [('Content-Type', 'application/json')], b'{"sum":7.0}')
85
-
86
- Each action defines an ``action`` definition using
87
- `Schema Markdown <https://craigahobbs.github.io/schema-markdown-js/language/>`__.
88
- The action callback is passed two arguments, a request
89
- `Context <https://craigahobbs.github.io/chisel/app.html#chisel.Context>`__
90
- and the schema-validated request input dictionary. The input request dictionary is created by
91
- combining the request's URL path parameters, query string parameters, and input JSON content
92
- parameters.
93
-
94
- If there is a schema validation error the appropriate error code is automatically returned.
95
-
96
- >>> status, _, content_bytes = application.request('GET', '/sum_numbers')
97
- >>> status
98
- '400 Bad Request'
99
-
100
- >>> content_bytes
101
- b'{"error":"InvalidInput","message":"Required member \'numbers\' missing (query string)"}'
102
-
103
-
104
- API Documentation
105
- -----------------
106
-
107
- You can add API documentation to your application by adding the Chisel documentation application
108
- requests from
109
- `create_doc_requests <https://craigahobbs.github.io/chisel/request.html#chisel.create_doc_requests>`__.
110
-
111
- >>> application = chisel.Application()
112
- >>> application.add_requests(chisel.create_doc_requests())
113
-
114
- By default the documentation application is hosted at "/doc/". An example of of Chisel's documentation output is
115
- available `here <https://craigahobbs.github.io/chisel/example/#var.vName='chisel_doc_request'>`__.
116
-
117
-
118
- Development
119
- -----------
120
-
121
- This package is developed using `python-build <https://github.com/craigahobbs/python-build#readme>`__.
122
- It was started using `python-template <https://github.com/craigahobbs/python-template#readme>`__ as follows:
123
-
124
- .. code-block:: sh
125
-
126
- template-specialize python-template/template/ chisel/ -k package chisel -k name 'Craig A. Hobbs' -k email 'craigahobbs@gmail.com' -k github 'craigahobbs' -k nomain 1
chisel-1.2.4/README.rst DELETED
@@ -1,101 +0,0 @@
1
- chisel
2
- ======
3
-
4
- .. |badge-status| image:: https://img.shields.io/pypi/status/chisel
5
- :alt: PyPI - Status
6
- :target: https://pypi.python.org/pypi/chisel/
7
-
8
- .. |badge-version| image:: https://img.shields.io/pypi/v/chisel
9
- :alt: PyPI
10
- :target: https://pypi.python.org/pypi/chisel/
11
-
12
- .. |badge-license| image:: https://img.shields.io/github/license/craigahobbs/chisel
13
- :alt: GitHub
14
- :target: https://github.com/craigahobbs/chisel/blob/main/LICENSE
15
-
16
- .. |badge-python| image:: https://img.shields.io/pypi/pyversions/chisel
17
- :alt: PyPI - Python Version
18
- :target: https://www.python.org/downloads/
19
-
20
- |badge-status| |badge-version| |badge-license| |badge-python|
21
-
22
- Chisel is a light-weight Python WSGI application framework built for creating well-documented,
23
- schema-validated JSON web APIs.
24
-
25
-
26
- Links
27
- -----
28
-
29
- - `API Documentation <https://craigahobbs.github.io/chisel/>`__
30
- - `Source code <https://github.com/craigahobbs/chisel>`__
31
-
32
-
33
- JSON APIs
34
- ---------
35
-
36
- Chisel provides the `action <https://craigahobbs.github.io/chisel/action.html#chisel.action>`__
37
- decorator for easily implementing schema-validated JSON APIs.
38
-
39
- >>> @chisel.action(spec='''
40
- ... # Sum a list of numbers
41
- ... action sum_numbers
42
- ... urls
43
- ... GET
44
- ...
45
- ... query
46
- ... # The list of numbers
47
- ... float[len > 0] numbers
48
- ...
49
- ... output
50
- ... # The sum of the numbers
51
- ... float sum
52
- ... ''')
53
- ... def sum_numbers(ctx, req):
54
- ... return {'sum': sum(req['numbers'])}
55
- ...
56
- >>> application = chisel.Application()
57
- >>> application.add_request(sum_numbers)
58
- >>> application.request('GET', '/sum_numbers', query_string='numbers.0=1&numbers.1=2&numbers.2=4')
59
- ('200 OK', [('Content-Type', 'application/json')], b'{"sum":7.0}')
60
-
61
- Each action defines an ``action`` definition using
62
- `Schema Markdown <https://craigahobbs.github.io/schema-markdown-js/language/>`__.
63
- The action callback is passed two arguments, a request
64
- `Context <https://craigahobbs.github.io/chisel/app.html#chisel.Context>`__
65
- and the schema-validated request input dictionary. The input request dictionary is created by
66
- combining the request's URL path parameters, query string parameters, and input JSON content
67
- parameters.
68
-
69
- If there is a schema validation error the appropriate error code is automatically returned.
70
-
71
- >>> status, _, content_bytes = application.request('GET', '/sum_numbers')
72
- >>> status
73
- '400 Bad Request'
74
-
75
- >>> content_bytes
76
- b'{"error":"InvalidInput","message":"Required member \'numbers\' missing (query string)"}'
77
-
78
-
79
- API Documentation
80
- -----------------
81
-
82
- You can add API documentation to your application by adding the Chisel documentation application
83
- requests from
84
- `create_doc_requests <https://craigahobbs.github.io/chisel/request.html#chisel.create_doc_requests>`__.
85
-
86
- >>> application = chisel.Application()
87
- >>> application.add_requests(chisel.create_doc_requests())
88
-
89
- By default the documentation application is hosted at "/doc/". An example of of Chisel's documentation output is
90
- available `here <https://craigahobbs.github.io/chisel/example/#var.vName='chisel_doc_request'>`__.
91
-
92
-
93
- Development
94
- -----------
95
-
96
- This package is developed using `python-build <https://github.com/craigahobbs/python-build#readme>`__.
97
- It was started using `python-template <https://github.com/craigahobbs/python-template#readme>`__ as follows:
98
-
99
- .. code-block:: sh
100
-
101
- template-specialize python-template/template/ chisel/ -k package chisel -k name 'Craig A. Hobbs' -k email 'craigahobbs@gmail.com' -k github 'craigahobbs' -k nomain 1
@@ -1,126 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: chisel
3
- Version: 1.2.4
4
- Summary: Lightweight WSGI application framework, schema-validated JSON APIs, and API documentation
5
- Home-page: https://github.com/craigahobbs/chisel
6
- Author: Craig A. Hobbs
7
- Author-email: craigahobbs@gmail.com
8
- License: MIT
9
- Keywords: api,json,framework,schema,wsgi
10
- Classifier: Development Status :: 5 - Production/Stable
11
- Classifier: Intended Audience :: Developers
12
- Classifier: License :: OSI Approved :: MIT License
13
- Classifier: Operating System :: OS Independent
14
- Classifier: Programming Language :: Python :: 3.8
15
- Classifier: Programming Language :: Python :: 3.9
16
- Classifier: Programming Language :: Python :: 3.10
17
- Classifier: Programming Language :: Python :: 3.11
18
- Classifier: Programming Language :: Python :: 3.12
19
- Classifier: Topic :: Internet :: WWW/HTTP :: WSGI
20
- Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Application
21
- Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
22
- Description-Content-Type: text/x-rst
23
- License-File: LICENSE
24
- Requires-Dist: schema-markdown>=1.2.0
25
-
26
- chisel
27
- ======
28
-
29
- .. |badge-status| image:: https://img.shields.io/pypi/status/chisel
30
- :alt: PyPI - Status
31
- :target: https://pypi.python.org/pypi/chisel/
32
-
33
- .. |badge-version| image:: https://img.shields.io/pypi/v/chisel
34
- :alt: PyPI
35
- :target: https://pypi.python.org/pypi/chisel/
36
-
37
- .. |badge-license| image:: https://img.shields.io/github/license/craigahobbs/chisel
38
- :alt: GitHub
39
- :target: https://github.com/craigahobbs/chisel/blob/main/LICENSE
40
-
41
- .. |badge-python| image:: https://img.shields.io/pypi/pyversions/chisel
42
- :alt: PyPI - Python Version
43
- :target: https://www.python.org/downloads/
44
-
45
- |badge-status| |badge-version| |badge-license| |badge-python|
46
-
47
- Chisel is a light-weight Python WSGI application framework built for creating well-documented,
48
- schema-validated JSON web APIs.
49
-
50
-
51
- Links
52
- -----
53
-
54
- - `API Documentation <https://craigahobbs.github.io/chisel/>`__
55
- - `Source code <https://github.com/craigahobbs/chisel>`__
56
-
57
-
58
- JSON APIs
59
- ---------
60
-
61
- Chisel provides the `action <https://craigahobbs.github.io/chisel/action.html#chisel.action>`__
62
- decorator for easily implementing schema-validated JSON APIs.
63
-
64
- >>> @chisel.action(spec='''
65
- ... # Sum a list of numbers
66
- ... action sum_numbers
67
- ... urls
68
- ... GET
69
- ...
70
- ... query
71
- ... # The list of numbers
72
- ... float[len > 0] numbers
73
- ...
74
- ... output
75
- ... # The sum of the numbers
76
- ... float sum
77
- ... ''')
78
- ... def sum_numbers(ctx, req):
79
- ... return {'sum': sum(req['numbers'])}
80
- ...
81
- >>> application = chisel.Application()
82
- >>> application.add_request(sum_numbers)
83
- >>> application.request('GET', '/sum_numbers', query_string='numbers.0=1&numbers.1=2&numbers.2=4')
84
- ('200 OK', [('Content-Type', 'application/json')], b'{"sum":7.0}')
85
-
86
- Each action defines an ``action`` definition using
87
- `Schema Markdown <https://craigahobbs.github.io/schema-markdown-js/language/>`__.
88
- The action callback is passed two arguments, a request
89
- `Context <https://craigahobbs.github.io/chisel/app.html#chisel.Context>`__
90
- and the schema-validated request input dictionary. The input request dictionary is created by
91
- combining the request's URL path parameters, query string parameters, and input JSON content
92
- parameters.
93
-
94
- If there is a schema validation error the appropriate error code is automatically returned.
95
-
96
- >>> status, _, content_bytes = application.request('GET', '/sum_numbers')
97
- >>> status
98
- '400 Bad Request'
99
-
100
- >>> content_bytes
101
- b'{"error":"InvalidInput","message":"Required member \'numbers\' missing (query string)"}'
102
-
103
-
104
- API Documentation
105
- -----------------
106
-
107
- You can add API documentation to your application by adding the Chisel documentation application
108
- requests from
109
- `create_doc_requests <https://craigahobbs.github.io/chisel/request.html#chisel.create_doc_requests>`__.
110
-
111
- >>> application = chisel.Application()
112
- >>> application.add_requests(chisel.create_doc_requests())
113
-
114
- By default the documentation application is hosted at "/doc/". An example of of Chisel's documentation output is
115
- available `here <https://craigahobbs.github.io/chisel/example/#var.vName='chisel_doc_request'>`__.
116
-
117
-
118
- Development
119
- -----------
120
-
121
- This package is developed using `python-build <https://github.com/craigahobbs/python-build#readme>`__.
122
- It was started using `python-template <https://github.com/craigahobbs/python-template#readme>`__ as follows:
123
-
124
- .. code-block:: sh
125
-
126
- template-specialize python-template/template/ chisel/ -k package chisel -k name 'Craig A. Hobbs' -k email 'craigahobbs@gmail.com' -k github 'craigahobbs' -k nomain 1
File without changes
File without changes
File without changes
File without changes
File without changes