python-jsonlogic 0.0.1__tar.gz → 0.2.0__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.
- python_jsonlogic-0.2.0/.github/workflows/ci.yml +130 -0
- python_jsonlogic-0.2.0/.github/workflows/lint.yml +83 -0
- python_jsonlogic-0.2.0/.gitignore +165 -0
- python_jsonlogic-0.2.0/.yamlfmt.yaml +5 -0
- python_jsonlogic-0.2.0/PKG-INFO +120 -0
- python_jsonlogic-0.2.0/README.rst +96 -0
- python_jsonlogic-0.2.0/changelog/entry.rst.jinja +8 -0
- python_jsonlogic-0.2.0/docs/Makefile +20 -0
- python_jsonlogic-0.2.0/docs/make.bat +35 -0
- python_jsonlogic-0.2.0/docs/source/api/core.rst +5 -0
- python_jsonlogic-0.2.0/docs/source/api/evaluation.rst +5 -0
- python_jsonlogic-0.2.0/docs/source/api/index.rst +15 -0
- python_jsonlogic-0.2.0/docs/source/api/json_schema.rst +8 -0
- python_jsonlogic-0.2.0/docs/source/api/registry.rst +5 -0
- python_jsonlogic-0.2.0/docs/source/api/resolving.rst +5 -0
- python_jsonlogic-0.2.0/docs/source/api/typechecking.rst +5 -0
- python_jsonlogic-0.2.0/docs/source/api/typing_helpers.rst +5 -0
- python_jsonlogic-0.2.0/docs/source/changelog.rst +40 -0
- python_jsonlogic-0.2.0/docs/source/conf.py +90 -0
- python_jsonlogic-0.2.0/docs/source/index.rst +19 -0
- python_jsonlogic-0.2.0/docs/source/usage/creating_operators.rst +147 -0
- python_jsonlogic-0.2.0/docs/source/usage/evaluation.rst +84 -0
- python_jsonlogic-0.2.0/docs/source/usage/index.rst +94 -0
- python_jsonlogic-0.2.0/docs/source/usage/resolving_variables.rst +117 -0
- python_jsonlogic-0.2.0/docs/source/usage/typechecking.rst +240 -0
- python_jsonlogic-0.2.0/prek.toml +20 -0
- python_jsonlogic-0.2.0/pyproject.toml +142 -0
- python_jsonlogic-0.2.0/readthedocs.yml +31 -0
- python_jsonlogic-0.2.0/requirements/requirements-dev.in +3 -0
- python_jsonlogic-0.2.0/requirements/requirements-dev.txt +12 -0
- python_jsonlogic-0.2.0/requirements/requirements-docs.in +5 -0
- python_jsonlogic-0.2.0/requirements/requirements-docs.txt +68 -0
- python_jsonlogic-0.2.0/requirements/requirements-test.in +6 -0
- python_jsonlogic-0.2.0/requirements/requirements-test.txt +51 -0
- python_jsonlogic-0.2.0/requirements/requirements.in +1 -0
- python_jsonlogic-0.2.0/requirements/requirements.txt +4 -0
- python_jsonlogic-0.2.0/src/jsonlogic/__init__.py +3 -0
- python_jsonlogic-0.2.0/src/jsonlogic/_compat.py +11 -0
- python_jsonlogic-0.2.0/src/jsonlogic/core.py +129 -0
- python_jsonlogic-0.2.0/src/jsonlogic/evaluation/__init__.py +5 -0
- python_jsonlogic-0.2.0/src/jsonlogic/evaluation/evaluation_context.py +74 -0
- python_jsonlogic-0.2.0/src/jsonlogic/evaluation/evaluation_settings.py +105 -0
- python_jsonlogic-0.2.0/src/jsonlogic/evaluation/utils.py +63 -0
- python_jsonlogic-0.2.0/src/jsonlogic/json_schema/__init__.py +189 -0
- python_jsonlogic-0.2.0/src/jsonlogic/json_schema/types.py +371 -0
- python_jsonlogic-0.2.0/src/jsonlogic/operators/__init__.py +56 -0
- python_jsonlogic-0.2.0/src/jsonlogic/operators/operators.py +399 -0
- python_jsonlogic-0.2.0/src/jsonlogic/registry.py +139 -0
- python_jsonlogic-0.2.0/src/jsonlogic/resolving.py +201 -0
- python_jsonlogic-0.2.0/src/jsonlogic/typechecking/__init__.py +15 -0
- python_jsonlogic-0.2.0/src/jsonlogic/typechecking/diagnostics.py +37 -0
- python_jsonlogic-0.2.0/src/jsonlogic/typechecking/typecheck_context.py +69 -0
- python_jsonlogic-0.2.0/src/jsonlogic/typechecking/typecheck_settings.py +213 -0
- python_jsonlogic-0.2.0/src/jsonlogic/typechecking/utils.py +49 -0
- python_jsonlogic-0.2.0/src/jsonlogic/typing.py +48 -0
- python_jsonlogic-0.2.0/src/jsonlogic/utils.py +48 -0
- python_jsonlogic-0.2.0/tests/json_schema/test_inference.py +151 -0
- python_jsonlogic-0.2.0/tests/json_schema/test_types.py +292 -0
- python_jsonlogic-0.2.0/tests/operators/__init__.py +0 -0
- python_jsonlogic-0.2.0/tests/operators/test_evaluate.py +242 -0
- python_jsonlogic-0.2.0/tests/operators/test_from_expression.py +107 -0
- python_jsonlogic-0.2.0/tests/operators/test_typecheck.py +291 -0
- python_jsonlogic-0.2.0/tests/test_json_logic_expression.py +9 -0
- python_jsonlogic-0.2.0/tests/test_registry.py +107 -0
- python_jsonlogic-0.2.0/tests/test_resolving.py +140 -0
- python_jsonlogic-0.2.0/tests/typechecking/__init__.py +0 -0
- python_jsonlogic-0.2.0/tests/typechecking/test_typecheck_context.py +41 -0
- python_jsonlogic-0.2.0/tests/typechecking/test_typecheck_settings.py +24 -0
- python_jsonlogic-0.2.0/uv.lock +1547 -0
- python-jsonlogic-0.0.1/PKG-INFO +0 -66
- python-jsonlogic-0.0.1/README.rst +0 -21
- python-jsonlogic-0.0.1/pyproject.toml +0 -74
- python-jsonlogic-0.0.1/setup.cfg +0 -4
- python-jsonlogic-0.0.1/src/jsonlogic/_compat.py +0 -8
- python-jsonlogic-0.0.1/src/jsonlogic/core.py +0 -73
- python-jsonlogic-0.0.1/src/jsonlogic/json_schema/__init__.py +0 -77
- python-jsonlogic-0.0.1/src/jsonlogic/json_schema/resolvers.py +0 -51
- python-jsonlogic-0.0.1/src/jsonlogic/json_schema/types.py +0 -130
- python-jsonlogic-0.0.1/src/jsonlogic/operators/__init__.py +0 -24
- python-jsonlogic-0.0.1/src/jsonlogic/operators/operators.py +0 -159
- python-jsonlogic-0.0.1/src/jsonlogic/operators/typechecking.py +0 -16
- python-jsonlogic-0.0.1/src/jsonlogic/registry.py +0 -94
- python-jsonlogic-0.0.1/src/jsonlogic/typing.py +0 -17
- python-jsonlogic-0.0.1/src/jsonlogic/utils.py +0 -14
- python-jsonlogic-0.0.1/src/python_jsonlogic.egg-info/PKG-INFO +0 -66
- python-jsonlogic-0.0.1/src/python_jsonlogic.egg-info/SOURCES.txt +0 -22
- python-jsonlogic-0.0.1/src/python_jsonlogic.egg-info/dependency_links.txt +0 -1
- python-jsonlogic-0.0.1/src/python_jsonlogic.egg-info/requires.txt +0 -3
- python-jsonlogic-0.0.1/src/python_jsonlogic.egg-info/top_level.txt +0 -1
- {python-jsonlogic-0.0.1 → python_jsonlogic-0.2.0}/LICENSE +0 -0
- /python-jsonlogic-0.0.1/src/jsonlogic/__init__.py → /python_jsonlogic-0.2.0/docs/source/_static/.gitkeep +0 -0
- {python-jsonlogic-0.0.1 → python_jsonlogic-0.2.0}/src/jsonlogic/py.typed +0 -0
- /python-jsonlogic-0.0.1/src/jsonlogic/operators/base.py → /python_jsonlogic-0.2.0/tests/__init__.py +0 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
tags:
|
|
8
|
+
- '**'
|
|
9
|
+
pull_request: {}
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
tests:
|
|
16
|
+
name: Run tests with pytest
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
strategy:
|
|
19
|
+
matrix:
|
|
20
|
+
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14', '3.15']
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
23
|
+
with:
|
|
24
|
+
persist-credentials: false
|
|
25
|
+
|
|
26
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
27
|
+
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
|
|
28
|
+
with:
|
|
29
|
+
python-version: ${{ matrix.python-version }}
|
|
30
|
+
enable-cache: true # zizmor: ignore[cache-poisoning] (Job does not produce release artifacts and does not have sensitive permissions)
|
|
31
|
+
|
|
32
|
+
- name: Install tox
|
|
33
|
+
run: uv tool install --managed-python --python 3.13 tox --with tox-uv --with tox-gh
|
|
34
|
+
|
|
35
|
+
- name: Install Python ${{ matrix.python-version }}
|
|
36
|
+
run: uv python install --managed-python ${{ matrix.python-version }}
|
|
37
|
+
|
|
38
|
+
- name: Test with tox
|
|
39
|
+
run: tox run
|
|
40
|
+
env:
|
|
41
|
+
TOX_GH_MAJOR_MINOR: ${{ matrix.python-version }}
|
|
42
|
+
UV_PYTHON_DOWNLOADS: never
|
|
43
|
+
|
|
44
|
+
docs:
|
|
45
|
+
name: Build and check documentation
|
|
46
|
+
runs-on: ubuntu-latest
|
|
47
|
+
steps:
|
|
48
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
49
|
+
with:
|
|
50
|
+
persist-credentials: false
|
|
51
|
+
|
|
52
|
+
- name: Set up Python 3.14
|
|
53
|
+
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
|
|
54
|
+
with:
|
|
55
|
+
python-version: '3.14'
|
|
56
|
+
enable-cache: true # zizmor: ignore[cache-poisoning] (Job does not produce release artifacts and does not have sensitive permissions)
|
|
57
|
+
|
|
58
|
+
- name: Install dependencies
|
|
59
|
+
run: uv sync --group docs
|
|
60
|
+
|
|
61
|
+
- name: Lint docs with sphinx-lint
|
|
62
|
+
run: |
|
|
63
|
+
uv run sphinx-lint docs
|
|
64
|
+
|
|
65
|
+
- name: Build docs and check the integrity of external links
|
|
66
|
+
run: |
|
|
67
|
+
uv run sphinx-build --builder linkcheck --fail-on-warning "source" "build"
|
|
68
|
+
uv run sphinx-build --builder html --fail-on-warning "source" "build"
|
|
69
|
+
working-directory: ./docs
|
|
70
|
+
|
|
71
|
+
build:
|
|
72
|
+
name: Build project
|
|
73
|
+
runs-on: ubuntu-latest
|
|
74
|
+
steps:
|
|
75
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
76
|
+
with:
|
|
77
|
+
persist-credentials: false
|
|
78
|
+
|
|
79
|
+
- uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
|
|
80
|
+
with:
|
|
81
|
+
enable-cache: false
|
|
82
|
+
|
|
83
|
+
- run: uv sync --no-install-project --only-group build
|
|
84
|
+
|
|
85
|
+
- name: Build library
|
|
86
|
+
run: uv run --no-sync python -m build --installer uv
|
|
87
|
+
|
|
88
|
+
- run: ls -lh dist/
|
|
89
|
+
|
|
90
|
+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
91
|
+
with:
|
|
92
|
+
name: pypi_files
|
|
93
|
+
path: dist
|
|
94
|
+
|
|
95
|
+
release:
|
|
96
|
+
needs: [tests, docs, build]
|
|
97
|
+
runs-on: ubuntu-latest
|
|
98
|
+
if: startsWith(github.ref, 'refs/tags/')
|
|
99
|
+
environment: release
|
|
100
|
+
|
|
101
|
+
permissions:
|
|
102
|
+
id-token: write
|
|
103
|
+
contents: write
|
|
104
|
+
|
|
105
|
+
steps:
|
|
106
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
107
|
+
with:
|
|
108
|
+
persist-credentials: false
|
|
109
|
+
|
|
110
|
+
- uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
|
|
111
|
+
with:
|
|
112
|
+
enable-cache: false
|
|
113
|
+
|
|
114
|
+
- run: uv sync --no-install-project --only-group build
|
|
115
|
+
|
|
116
|
+
- name: Get dist artifacts
|
|
117
|
+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
118
|
+
with:
|
|
119
|
+
name: pypi_files
|
|
120
|
+
path: dist
|
|
121
|
+
|
|
122
|
+
- name: Test artifacts integrity
|
|
123
|
+
run: |
|
|
124
|
+
for whl in dist/*.whl; do unzip -qt "$whl"; done
|
|
125
|
+
uv run --no-sync twine check --strict dist/*
|
|
126
|
+
|
|
127
|
+
- name: Upload package to PyPI
|
|
128
|
+
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
|
|
129
|
+
with:
|
|
130
|
+
packages-dir: dist/
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
name: lint
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
tags:
|
|
8
|
+
- '**'
|
|
9
|
+
pull_request: {}
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
prek:
|
|
16
|
+
name: Run prek pre-commit hooks
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
20
|
+
with:
|
|
21
|
+
persist-credentials: false
|
|
22
|
+
|
|
23
|
+
- uses: j178/prek-action@4e14d07f9231acabce116ccfca13b13dd9755ece # v3.0.0
|
|
24
|
+
|
|
25
|
+
ruff-format:
|
|
26
|
+
name: Check code formatting with Ruff
|
|
27
|
+
runs-on: ubuntu-latest
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
30
|
+
with:
|
|
31
|
+
persist-credentials: false
|
|
32
|
+
|
|
33
|
+
- name: Set up Python 3.14
|
|
34
|
+
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
|
|
35
|
+
with:
|
|
36
|
+
python-version: '3.14'
|
|
37
|
+
enable-cache: true # zizmor: ignore[cache-poisoning] (Job does not produce release artifacts and does not have sensitive permissions)
|
|
38
|
+
|
|
39
|
+
- name: Install dependencies
|
|
40
|
+
run: uv sync --group dev
|
|
41
|
+
|
|
42
|
+
- name: Run Ruff formatter
|
|
43
|
+
run: uv run ruff format --diff
|
|
44
|
+
|
|
45
|
+
ruff-check:
|
|
46
|
+
name: Check code linting with Ruff
|
|
47
|
+
runs-on: ubuntu-latest
|
|
48
|
+
steps:
|
|
49
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
50
|
+
with:
|
|
51
|
+
persist-credentials: false
|
|
52
|
+
|
|
53
|
+
- name: Set up Python 3.14
|
|
54
|
+
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
|
|
55
|
+
with:
|
|
56
|
+
python-version: '3.14'
|
|
57
|
+
enable-cache: true # zizmor: ignore[cache-poisoning] (Job does not produce release artifacts and does not have sensitive permissions)
|
|
58
|
+
|
|
59
|
+
- name: Install dependencies
|
|
60
|
+
run: uv sync --group dev
|
|
61
|
+
|
|
62
|
+
- name: Run Ruff formatter
|
|
63
|
+
run: uv run ruff check --output-format=github
|
|
64
|
+
|
|
65
|
+
typecheck:
|
|
66
|
+
name: Run typechecking with pyright
|
|
67
|
+
runs-on: ubuntu-latest
|
|
68
|
+
steps:
|
|
69
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
70
|
+
with:
|
|
71
|
+
persist-credentials: false
|
|
72
|
+
|
|
73
|
+
- name: Set up Python 3.14
|
|
74
|
+
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
|
|
75
|
+
with:
|
|
76
|
+
python-version: '3.14'
|
|
77
|
+
enable-cache: true # zizmor: ignore[cache-poisoning] (Job does not produce release artifacts and does not have sensitive permissions)
|
|
78
|
+
|
|
79
|
+
- name: Install dependencies
|
|
80
|
+
run: uv sync --group dev
|
|
81
|
+
|
|
82
|
+
- name: Run pyright
|
|
83
|
+
run: uv run pyright
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# poetry
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
102
|
+
#poetry.lock
|
|
103
|
+
|
|
104
|
+
# pdm
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
106
|
+
#pdm.lock
|
|
107
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
108
|
+
# in version control.
|
|
109
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
110
|
+
.pdm.toml
|
|
111
|
+
|
|
112
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
113
|
+
__pypackages__/
|
|
114
|
+
|
|
115
|
+
# Celery stuff
|
|
116
|
+
celerybeat-schedule
|
|
117
|
+
celerybeat.pid
|
|
118
|
+
|
|
119
|
+
# SageMath parsed files
|
|
120
|
+
*.sage.py
|
|
121
|
+
|
|
122
|
+
# Environments
|
|
123
|
+
.env
|
|
124
|
+
.venv
|
|
125
|
+
env/
|
|
126
|
+
venv/
|
|
127
|
+
ENV/
|
|
128
|
+
env.bak/
|
|
129
|
+
venv.bak/
|
|
130
|
+
|
|
131
|
+
# Spyder project settings
|
|
132
|
+
.spyderproject
|
|
133
|
+
.spyproject
|
|
134
|
+
|
|
135
|
+
# Rope project settings
|
|
136
|
+
.ropeproject
|
|
137
|
+
|
|
138
|
+
# mkdocs documentation
|
|
139
|
+
/site
|
|
140
|
+
|
|
141
|
+
# mypy
|
|
142
|
+
.mypy_cache/
|
|
143
|
+
.dmypy.json
|
|
144
|
+
dmypy.json
|
|
145
|
+
|
|
146
|
+
# Pyre type checker
|
|
147
|
+
.pyre/
|
|
148
|
+
|
|
149
|
+
# pytype static type analyzer
|
|
150
|
+
.pytype/
|
|
151
|
+
|
|
152
|
+
# Ruff linter
|
|
153
|
+
.ruff_cache/
|
|
154
|
+
|
|
155
|
+
# Cython debug symbols
|
|
156
|
+
cython_debug/
|
|
157
|
+
|
|
158
|
+
.vscode/
|
|
159
|
+
|
|
160
|
+
# PyCharm
|
|
161
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
162
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
163
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
164
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
165
|
+
#.idea/
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: python-jsonlogic
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: An extensible and sane implementation of JsonLogic
|
|
5
|
+
Author-email: Victorien <contact@vctrn.dev>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Requires-Dist: typing-extensions>=4.10.0; python_version < '3.13'
|
|
23
|
+
Description-Content-Type: text/x-rst
|
|
24
|
+
|
|
25
|
+
================
|
|
26
|
+
python-jsonlogic
|
|
27
|
+
================
|
|
28
|
+
|
|
29
|
+
|Pythons| |PyPI| |Ruff|
|
|
30
|
+
|
|
31
|
+
.. |Pythons| image:: https://img.shields.io/pypi/pyversions/python-jsonlogic.svg
|
|
32
|
+
:alt: Supported Python versions
|
|
33
|
+
:target: https://pypi.org/project/python-jsonlogic/
|
|
34
|
+
|
|
35
|
+
.. |PyPI| image:: https://img.shields.io/pypi/v/python-jsonlogic.svg
|
|
36
|
+
:alt: PyPI - Version
|
|
37
|
+
:target: https://pypi.org/project/python-jsonlogic/
|
|
38
|
+
|
|
39
|
+
.. |Ruff| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
|
|
40
|
+
:alt: PyPI - Version
|
|
41
|
+
:target: https://github.com/astral-sh/ruff
|
|
42
|
+
|
|
43
|
+
``python-jsonlogic`` is an extensible and sane implementation of `JsonLogic`_, making use of the `JSON Schema`_ specification.
|
|
44
|
+
|
|
45
|
+
.. _`JSON Schema`: https://json-schema.org/
|
|
46
|
+
|
|
47
|
+
Motivation
|
|
48
|
+
----------
|
|
49
|
+
|
|
50
|
+
While the `JsonLogic`_ format can be great to serialize logic, it lacks a formal specification
|
|
51
|
+
and some aspects are unclear/unspecified:
|
|
52
|
+
|
|
53
|
+
* `operators <https://jsonlogic.com/operations.html>`_ arguments can take any value. For instance,
|
|
54
|
+
`comparison operators <https://jsonlogic.com/operations.html#---and->`_ are said to work with "numeric" values,
|
|
55
|
+
however the `JavaScript playground <https://jsonlogic.com/play.html>`_ doesn't validate inputs. It is
|
|
56
|
+
also convenient to allow such comparison operators for date and datetime objects as well.
|
|
57
|
+
* Operators `accessing data <https://jsonlogic.com/operations.html#accessing-data>`_ use a dot-like notation,
|
|
58
|
+
which is ambiguous when dealing with keys such as ``my.key``.
|
|
59
|
+
* Operators such as `map <https://jsonlogic.com/operations.html#map-reduce-and-filter>`_ provides their own data scope,
|
|
60
|
+
making it impossible to access higher-level data inside the operator expression.
|
|
61
|
+
|
|
62
|
+
For these reasons, ``python-jsonlogic`` provides a way to typecheck your JSON Logic expressions at "compile" time,
|
|
63
|
+
before applying input data to them.
|
|
64
|
+
|
|
65
|
+
.. _`JsonLogic`: https://jsonlogic.com/
|
|
66
|
+
|
|
67
|
+
Installation
|
|
68
|
+
------------
|
|
69
|
+
|
|
70
|
+
From PyPI:
|
|
71
|
+
|
|
72
|
+
.. code:: bash
|
|
73
|
+
|
|
74
|
+
pip install python-jsonlogic
|
|
75
|
+
|
|
76
|
+
The library can be imported from the ``jsonlogic`` module.
|
|
77
|
+
|
|
78
|
+
Usage
|
|
79
|
+
-----
|
|
80
|
+
|
|
81
|
+
.. code-block:: python
|
|
82
|
+
|
|
83
|
+
# 1. Create or use an already existing operator registry:
|
|
84
|
+
from jsonlogic.operators import operator_registry
|
|
85
|
+
|
|
86
|
+
# 2. Parse the JSON Logic expression:
|
|
87
|
+
from jsonlogic import JSONLogicExpression
|
|
88
|
+
|
|
89
|
+
expr = JSONLogicExpression.from_json({"map": [
|
|
90
|
+
[1, 2],
|
|
91
|
+
{"*": [{"var": ""}, {"var": "/my_int@1"}]},
|
|
92
|
+
]})
|
|
93
|
+
|
|
94
|
+
# 3. Create an operator tree:
|
|
95
|
+
root_op = expr.as_operator_tree(operator_registry)
|
|
96
|
+
|
|
97
|
+
# 4. Typecheck the expression:
|
|
98
|
+
from jsonlogic.typechecking import typecheck
|
|
99
|
+
|
|
100
|
+
typ, diagnostics = typecheck(
|
|
101
|
+
root_op,
|
|
102
|
+
data_schema={
|
|
103
|
+
"type": "object",
|
|
104
|
+
"properties": {
|
|
105
|
+
"my_int": {"type": "integer"}
|
|
106
|
+
},
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
print(typ)
|
|
110
|
+
#> ArrayType(IntegerType())
|
|
111
|
+
|
|
112
|
+
# 5. Evaluate with data:
|
|
113
|
+
from jsonlogic.evaluation import evaluate
|
|
114
|
+
value = evaluate(
|
|
115
|
+
root_op,
|
|
116
|
+
data={"my_int": 2},
|
|
117
|
+
data_schema=None,
|
|
118
|
+
)
|
|
119
|
+
print(value)
|
|
120
|
+
#> [2, 4]
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
================
|
|
2
|
+
python-jsonlogic
|
|
3
|
+
================
|
|
4
|
+
|
|
5
|
+
|Pythons| |PyPI| |Ruff|
|
|
6
|
+
|
|
7
|
+
.. |Pythons| image:: https://img.shields.io/pypi/pyversions/python-jsonlogic.svg
|
|
8
|
+
:alt: Supported Python versions
|
|
9
|
+
:target: https://pypi.org/project/python-jsonlogic/
|
|
10
|
+
|
|
11
|
+
.. |PyPI| image:: https://img.shields.io/pypi/v/python-jsonlogic.svg
|
|
12
|
+
:alt: PyPI - Version
|
|
13
|
+
:target: https://pypi.org/project/python-jsonlogic/
|
|
14
|
+
|
|
15
|
+
.. |Ruff| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
|
|
16
|
+
:alt: PyPI - Version
|
|
17
|
+
:target: https://github.com/astral-sh/ruff
|
|
18
|
+
|
|
19
|
+
``python-jsonlogic`` is an extensible and sane implementation of `JsonLogic`_, making use of the `JSON Schema`_ specification.
|
|
20
|
+
|
|
21
|
+
.. _`JSON Schema`: https://json-schema.org/
|
|
22
|
+
|
|
23
|
+
Motivation
|
|
24
|
+
----------
|
|
25
|
+
|
|
26
|
+
While the `JsonLogic`_ format can be great to serialize logic, it lacks a formal specification
|
|
27
|
+
and some aspects are unclear/unspecified:
|
|
28
|
+
|
|
29
|
+
* `operators <https://jsonlogic.com/operations.html>`_ arguments can take any value. For instance,
|
|
30
|
+
`comparison operators <https://jsonlogic.com/operations.html#---and->`_ are said to work with "numeric" values,
|
|
31
|
+
however the `JavaScript playground <https://jsonlogic.com/play.html>`_ doesn't validate inputs. It is
|
|
32
|
+
also convenient to allow such comparison operators for date and datetime objects as well.
|
|
33
|
+
* Operators `accessing data <https://jsonlogic.com/operations.html#accessing-data>`_ use a dot-like notation,
|
|
34
|
+
which is ambiguous when dealing with keys such as ``my.key``.
|
|
35
|
+
* Operators such as `map <https://jsonlogic.com/operations.html#map-reduce-and-filter>`_ provides their own data scope,
|
|
36
|
+
making it impossible to access higher-level data inside the operator expression.
|
|
37
|
+
|
|
38
|
+
For these reasons, ``python-jsonlogic`` provides a way to typecheck your JSON Logic expressions at "compile" time,
|
|
39
|
+
before applying input data to them.
|
|
40
|
+
|
|
41
|
+
.. _`JsonLogic`: https://jsonlogic.com/
|
|
42
|
+
|
|
43
|
+
Installation
|
|
44
|
+
------------
|
|
45
|
+
|
|
46
|
+
From PyPI:
|
|
47
|
+
|
|
48
|
+
.. code:: bash
|
|
49
|
+
|
|
50
|
+
pip install python-jsonlogic
|
|
51
|
+
|
|
52
|
+
The library can be imported from the ``jsonlogic`` module.
|
|
53
|
+
|
|
54
|
+
Usage
|
|
55
|
+
-----
|
|
56
|
+
|
|
57
|
+
.. code-block:: python
|
|
58
|
+
|
|
59
|
+
# 1. Create or use an already existing operator registry:
|
|
60
|
+
from jsonlogic.operators import operator_registry
|
|
61
|
+
|
|
62
|
+
# 2. Parse the JSON Logic expression:
|
|
63
|
+
from jsonlogic import JSONLogicExpression
|
|
64
|
+
|
|
65
|
+
expr = JSONLogicExpression.from_json({"map": [
|
|
66
|
+
[1, 2],
|
|
67
|
+
{"*": [{"var": ""}, {"var": "/my_int@1"}]},
|
|
68
|
+
]})
|
|
69
|
+
|
|
70
|
+
# 3. Create an operator tree:
|
|
71
|
+
root_op = expr.as_operator_tree(operator_registry)
|
|
72
|
+
|
|
73
|
+
# 4. Typecheck the expression:
|
|
74
|
+
from jsonlogic.typechecking import typecheck
|
|
75
|
+
|
|
76
|
+
typ, diagnostics = typecheck(
|
|
77
|
+
root_op,
|
|
78
|
+
data_schema={
|
|
79
|
+
"type": "object",
|
|
80
|
+
"properties": {
|
|
81
|
+
"my_int": {"type": "integer"}
|
|
82
|
+
},
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
print(typ)
|
|
86
|
+
#> ArrayType(IntegerType())
|
|
87
|
+
|
|
88
|
+
# 5. Evaluate with data:
|
|
89
|
+
from jsonlogic.evaluation import evaluate
|
|
90
|
+
value = evaluate(
|
|
91
|
+
root_op,
|
|
92
|
+
data={"my_int": 2},
|
|
93
|
+
data_schema=None,
|
|
94
|
+
)
|
|
95
|
+
print(value)
|
|
96
|
+
#> [2, 4]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{% set refs = [] %}
|
|
2
|
+
{% if metadata.gh_issue %}{% set _ = refs.append("Issue :issue:`%s`" % metadata.gh_issue) %}{% endif %}
|
|
3
|
+
{% if metadata.gh_pr %}{% set _ = refs.append("PR :pr:`%s`" % metadata.gh_pr) %}{% endif %}
|
|
4
|
+
{% set refs = refs | join(", ") %}
|
|
5
|
+
{% if metadata.gh_author %}{% set refs = (refs ~ " by :user:`%s`" % metadata.gh_author) | trim %}{% endif %}
|
|
6
|
+
{# References are attached to the first paragraph, so that multi-paragraph entries (e.g. with a code example) stay valid: #}
|
|
7
|
+
{% set first, _, rest = content.partition("\n\n") %}
|
|
8
|
+
{{ first }}{% if refs %} ({{ refs }}).{% endif %}{% if rest %}{{ "\n\n" ~ rest }}{% endif %}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Minimal makefile for Sphinx documentation
|
|
2
|
+
#
|
|
3
|
+
|
|
4
|
+
# You can set these variables from the command line, and also
|
|
5
|
+
# from the environment for the first two.
|
|
6
|
+
SPHINXOPTS ?=
|
|
7
|
+
SPHINXBUILD ?= sphinx-build
|
|
8
|
+
SOURCEDIR = source
|
|
9
|
+
BUILDDIR = build
|
|
10
|
+
|
|
11
|
+
# Put it first so that "make" without argument is like "make help".
|
|
12
|
+
help:
|
|
13
|
+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
14
|
+
|
|
15
|
+
.PHONY: help Makefile
|
|
16
|
+
|
|
17
|
+
# Catch-all target: route all unknown targets to Sphinx using the new
|
|
18
|
+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
|
19
|
+
%: Makefile
|
|
20
|
+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@ECHO OFF
|
|
2
|
+
|
|
3
|
+
pushd %~dp0
|
|
4
|
+
|
|
5
|
+
REM Command file for Sphinx documentation
|
|
6
|
+
|
|
7
|
+
if "%SPHINXBUILD%" == "" (
|
|
8
|
+
set SPHINXBUILD=sphinx-build
|
|
9
|
+
)
|
|
10
|
+
set SOURCEDIR=source
|
|
11
|
+
set BUILDDIR=build
|
|
12
|
+
|
|
13
|
+
%SPHINXBUILD% >NUL 2>NUL
|
|
14
|
+
if errorlevel 9009 (
|
|
15
|
+
echo.
|
|
16
|
+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
|
17
|
+
echo.installed, then set the SPHINXBUILD environment variable to point
|
|
18
|
+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
|
19
|
+
echo.may add the Sphinx directory to PATH.
|
|
20
|
+
echo.
|
|
21
|
+
echo.If you don't have Sphinx installed, grab it from
|
|
22
|
+
echo.https://www.sphinx-doc.org/
|
|
23
|
+
exit /b 1
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
if "%1" == "" goto help
|
|
27
|
+
|
|
28
|
+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
|
29
|
+
goto end
|
|
30
|
+
|
|
31
|
+
:help
|
|
32
|
+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
|
33
|
+
|
|
34
|
+
:end
|
|
35
|
+
popd
|