pyformatters-json 0.5.195__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.
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyformatters-json
3
+ Version: 0.5.195
4
+ Summary: Sherpa Json formatter
5
+ Home-page: https://kairntech.com/
6
+ Author: Olivier Terrier
7
+ Author-email: olivier.terrier@kairntech.com
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ Classifier: Intended Audience :: Information Technology
11
+ Classifier: Intended Audience :: System Administrators
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python
15
+ Classifier: Topic :: Internet
16
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Classifier: Topic :: Software Development :: Libraries
19
+ Classifier: Topic :: Software Development
20
+ Classifier: Typing :: Typed
21
+ Classifier: Development Status :: 4 - Beta
22
+ Classifier: Environment :: Web Environment
23
+ Classifier: Framework :: AsyncIO
24
+ Classifier: Intended Audience :: Developers
25
+ Classifier: Programming Language :: Python :: 3 :: Only
26
+ Classifier: Programming Language :: Python :: 3.8
27
+ Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
28
+ Classifier: Topic :: Internet :: WWW/HTTP
29
+ Requires-Dist: pymultirole_plugins>=0.5.0,<0.6.0
30
+ Requires-Dist: pytest
31
+
32
+ ## Requirements
33
+
34
+ - Python 3.8+
35
+ - Flit to put Python packages and modules on PyPI
36
+ - Pydantic for the data parts.
37
+
38
+ ## Installation
39
+ ```
40
+ pip install flit
41
+ pip install pyconverters-plugins
42
+ ```
43
+
44
+ ## Publish the Python Package to PyPI
45
+ - Increment the version of your package in the `__init__.py` file:
46
+ ```
47
+ """An amazing package!"""
48
+
49
+ __version__ = 'x.y.z'
50
+ ```
51
+ - Publish
52
+ ```
53
+ flit publish
54
+ ```
55
+
@@ -0,0 +1,23 @@
1
+ ## Requirements
2
+
3
+ - Python 3.8+
4
+ - Flit to put Python packages and modules on PyPI
5
+ - Pydantic for the data parts.
6
+
7
+ ## Installation
8
+ ```
9
+ pip install flit
10
+ pip install pyconverters-plugins
11
+ ```
12
+
13
+ ## Publish the Python Package to PyPI
14
+ - Increment the version of your package in the `__init__.py` file:
15
+ ```
16
+ """An amazing package!"""
17
+
18
+ __version__ = 'x.y.z'
19
+ ```
20
+ - Publish
21
+ ```
22
+ flit publish
23
+ ```
@@ -0,0 +1,2 @@
1
+ """Sherpa Json formatter"""
2
+ __version__ = "0.5.195"
@@ -0,0 +1,47 @@
1
+ import json
2
+ from typing import Type
3
+
4
+ from pydantic import BaseModel
5
+ from pymultirole_plugins.v1.formatter import FormatterBase, FormatterParameters
6
+ from pymultirole_plugins.v1.schema import Document
7
+ from starlette.responses import Response, JSONResponse
8
+
9
+
10
+ class JsonParameters(FormatterParameters):
11
+ pass
12
+
13
+
14
+ class JsonFormatter(FormatterBase):
15
+ """Json formatter.
16
+ """
17
+
18
+ def format(self, document: Document, parameters: FormatterParameters) \
19
+ -> Response:
20
+ """Parse the altTexts of the document and return a json response.
21
+
22
+ :param document: An annotated document.
23
+ :param options: options of the parser.
24
+ :returns: Response.
25
+ """
26
+ parameters: JsonParameters = parameters
27
+ try:
28
+ alts = []
29
+ if document.altTexts:
30
+ altTexts = document.altTexts
31
+ alts = {altText.name: altText.text for altText in altTexts}
32
+ anames = list(alts.keys())
33
+ for aname in anames:
34
+ atext = alts[aname]
35
+ result = None
36
+ try:
37
+ result = json.loads(atext)
38
+ alts[aname] = result
39
+ except json.JSONDecodeError:
40
+ del alts[aname]
41
+ return JSONResponse(alts)
42
+ except BaseException as err:
43
+ raise err
44
+
45
+ @classmethod
46
+ def get_model(cls) -> Type[BaseModel]:
47
+ return JsonParameters
@@ -0,0 +1,68 @@
1
+ [build-system]
2
+ requires = ["flit_core >=2,<4"]
3
+ build-backend = "flit_core.buildapi"
4
+
5
+ [tool.flit.metadata]
6
+ module = "pyformatters_json"
7
+ author = "Olivier Terrier"
8
+ author-email = "olivier.terrier@kairntech.com"
9
+ home-page = "https://kairntech.com/"
10
+ classifiers = [
11
+ "Intended Audience :: Information Technology",
12
+ "Intended Audience :: System Administrators",
13
+ "Operating System :: OS Independent",
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python",
16
+ "Topic :: Internet",
17
+ "Topic :: Software Development :: Libraries :: Application Frameworks",
18
+ "Topic :: Software Development :: Libraries :: Python Modules",
19
+ "Topic :: Software Development :: Libraries",
20
+ "Topic :: Software Development",
21
+ "Typing :: Typed",
22
+ "Development Status :: 4 - Beta",
23
+ "Environment :: Web Environment",
24
+ "Framework :: AsyncIO",
25
+ "Intended Audience :: Developers",
26
+ "Programming Language :: Python :: 3 :: Only",
27
+ "Programming Language :: Python :: 3.8",
28
+ "Topic :: Internet :: WWW/HTTP :: HTTP Servers",
29
+ "Topic :: Internet :: WWW/HTTP",
30
+ ]
31
+ requires = [
32
+ "pymultirole_plugins>=0.5.0,<0.6.0",
33
+ "pytest"
34
+ ]
35
+ dist-name = "pyformatters-json"
36
+ description-file = "README.md"
37
+ requires-python = ">=3.8"
38
+
39
+ [tool.flit.entrypoints."pyformatters.plugins"]
40
+ json = "pyformatters_json.json_formatter:JsonFormatter"
41
+
42
+ [tool.flakehell]
43
+ exclude = ["README.md"]
44
+ format = "colored"
45
+ #format = "junit-xml"
46
+ max_line_length = 120
47
+ show_source = true
48
+ #whitelist = "../../allowlist.txt"
49
+ extended_default_ignore = []
50
+
51
+ [tool.flakehell.plugins]
52
+ flake8-bandit = ["+*", "-S322"]
53
+ flake8-bugbear = ["+*"]
54
+ flake8-builtins = ["+*", "-A003"]
55
+ flake8-comprehensions = ["+*"]
56
+ #flake8-darglint = ["+*"]
57
+ flake8-docstrings = ["+*"]
58
+ flake8-eradicate = ["+*"]
59
+ flake8-isort = ["+*"]
60
+ flake8-mutable = ["+*"]
61
+ flake8-pytest-style = ["+*"]
62
+ flake8-spellcheck = ["+*"]
63
+ mccabe = ["+*"]
64
+ pep8-naming = ["+*"]
65
+ pycodestyle = ["+*"]
66
+ pyflakes = ["+*"]
67
+ pylint = ["+*"]
68
+