pyrulefilter 0.5.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.
@@ -0,0 +1,2 @@
1
+ # SCM syntax highlighting & preventing 3-way merges
2
+ pixi.lock merge=binary linguist-language=YAML linguist-generated=true
@@ -0,0 +1,41 @@
1
+ # TODO: setup auto-update pixi.lock https://pixi.sh/latest/advanced/updates_github_actions/#how-to-use
2
+ # TODO: use quarto GH action (https://github.com/quarto-dev/quarto-actions/tree/main/publish)
3
+
4
+ name: deploy-book
5
+
6
+ on:
7
+ push:
8
+ branches: [main]
9
+ pull_request:
10
+ branches: [main]
11
+
12
+ jobs:
13
+ build:
14
+ strategy:
15
+ matrix:
16
+ include:
17
+ - os: ubuntu-latest
18
+ label: linux-64
19
+
20
+ name: ${{ matrix.label }}
21
+ runs-on: ${{ matrix.os }}
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+ - uses: prefix-dev/setup-pixi@v0.8.3
25
+ with:
26
+ manifest-path: pyproject.toml
27
+ pixi-version: v0.48.1
28
+ cache: true
29
+ cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
30
+ - run: pixi run docs
31
+
32
+ - name: add .nojekyll file
33
+ working-directory: ./docs/_site
34
+ run: touch .nojekyll
35
+
36
+ # Push the book's HTML to github-pages
37
+ - name: GitHub Pages action
38
+ uses: peaceiris/actions-gh-pages@v3.6.1
39
+ with:
40
+ github_token: ${{ secrets.GITHUB_TOKEN }}
41
+ publish_dir: docs/_site
@@ -0,0 +1,28 @@
1
+ # .github/workflows/ci-cd.yml
2
+ name: Publish to PyPI
3
+
4
+ on:
5
+ push:
6
+ tags:
7
+ - '*'
8
+ - '!rc*' # Exclude release candidates
9
+ jobs:
10
+
11
+ pypi-publish:
12
+ name: Upload release to PyPI
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: prefix-dev/setup-pixi@v0.8.5
17
+ with:
18
+ pixi-version: v0.45.0
19
+ cache: true
20
+ cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
21
+ - run: pixi run build
22
+ - name: Publish package distributions to PyPI
23
+ uses: pypa/gh-action-pypi-publish@release/v1
24
+ environment:
25
+ name: pypi
26
+ url: https://pypi.org/p/pyrulefilter
27
+ permissions:
28
+ id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
@@ -0,0 +1,29 @@
1
+ # TODO: setup auto-update pixi.lock https://pixi.sh/latest/advanced/updates_github_actions/#how-to-use
2
+
3
+ name: Test and Lint
4
+
5
+ on:
6
+ push:
7
+ branches: [main]
8
+ pull_request:
9
+ branches: [main]
10
+
11
+ jobs:
12
+ build:
13
+ strategy:
14
+ matrix:
15
+ include:
16
+ - os: ubuntu-latest
17
+ label: linux-64
18
+
19
+ name: ${{ matrix.label }}
20
+ runs-on: ${{ matrix.os }}
21
+ steps:
22
+ - uses: actions/checkout@v4
23
+ - uses: prefix-dev/setup-pixi@v0.8.3
24
+ with:
25
+ manifest-path: pyproject.toml
26
+ pixi-version: v0.48.1
27
+ cache: true
28
+ cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
29
+ - run: pixi run tests
@@ -0,0 +1,168 @@
1
+ docs/_site/
2
+
3
+ # Byte-compiled / optimized / DLL files
4
+ __pycache__/
5
+ *.py[cod]
6
+ *$py.class
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ build/
14
+ develop-eggs/
15
+ dist/
16
+ downloads/
17
+ eggs/
18
+ .eggs/
19
+ lib/
20
+ lib64/
21
+ parts/
22
+ sdist/
23
+ var/
24
+ wheels/
25
+ share/python-wheels/
26
+ *.egg-info/
27
+ .installed.cfg
28
+ *.egg
29
+ MANIFEST
30
+ src/pyrulefilter/_version.py
31
+
32
+ # PyInstaller
33
+ # Usually these files are written by a python script from a template
34
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
35
+ *.manifest
36
+ *.spec
37
+
38
+ # Installer logs
39
+ pip-log.txt
40
+ pip-delete-this-directory.txt
41
+
42
+ # Unit test / coverage reports
43
+ htmlcov/
44
+ .tox/
45
+ .nox/
46
+ .coverage
47
+ .coverage.*
48
+ .cache
49
+ nosetests.xml
50
+ coverage.xml
51
+ *.cover
52
+ *.py,cover
53
+ .hypothesis/
54
+ .pytest_cache/
55
+ cover/
56
+
57
+ # Translations
58
+ *.mo
59
+ *.pot
60
+
61
+ # Django stuff:
62
+ *.log
63
+ local_settings.py
64
+ db.sqlite3
65
+ db.sqlite3-journal
66
+
67
+ # Flask stuff:
68
+ instance/
69
+ .webassets-cache
70
+
71
+ # Scrapy stuff:
72
+ .scrapy
73
+
74
+ # Sphinx documentation
75
+ docs/_build/
76
+
77
+ # PyBuilder
78
+ .pybuilder/
79
+ target/
80
+
81
+ # Jupyter Notebook
82
+ .ipynb_checkpoints
83
+
84
+ # IPython
85
+ profile_default/
86
+ ipython_config.py
87
+
88
+ # pyenv
89
+ # For a library or package, you might want to ignore these files since the code is
90
+ # intended to run in multiple environments; otherwise, check them in:
91
+ # .python-version
92
+
93
+ # pipenv
94
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
95
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
96
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
97
+ # install all needed dependencies.
98
+ #Pipfile.lock
99
+
100
+ # poetry
101
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
102
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
103
+ # commonly ignored for libraries.
104
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
105
+ #poetry.lock
106
+
107
+ # pdm
108
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
109
+ #pdm.lock
110
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
111
+ # in version control.
112
+ # https://pdm.fming.dev/#use-with-ide
113
+ .pdm.toml
114
+
115
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
116
+ __pypackages__/
117
+
118
+ # Celery stuff
119
+ celerybeat-schedule
120
+ celerybeat.pid
121
+
122
+ # SageMath parsed files
123
+ *.sage.py
124
+
125
+ # Environments
126
+ .env
127
+ .venv
128
+ env/
129
+ venv/
130
+ ENV/
131
+ env.bak/
132
+ venv.bak/
133
+
134
+ # Spyder project settings
135
+ .spyderproject
136
+ .spyproject
137
+
138
+ # Rope project settings
139
+ .ropeproject
140
+
141
+ # mkdocs documentation
142
+ /site
143
+
144
+ # mypy
145
+ .mypy_cache/
146
+ .dmypy.json
147
+ dmypy.json
148
+
149
+ # Pyre type checker
150
+ .pyre/
151
+
152
+ # pytype static type analyzer
153
+ .pytype/
154
+
155
+ # Cython debug symbols
156
+ cython_debug/
157
+
158
+ # PyCharm
159
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
160
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
161
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
162
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
163
+ #.idea/
164
+
165
+
166
+ # pixi environments
167
+ .pixi
168
+ *.egg-info
@@ -0,0 +1,7 @@
1
+ {
2
+ "python.testing.pytestArgs": [
3
+ "tests"
4
+ ],
5
+ "python.testing.unittestEnabled": false,
6
+ "python.testing.pytestEnabled": true
7
+ }
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyrulefilter
3
+ Version: 0.5.0
4
+ Author-email: jgunstone <j.gunstone@maxfordham.com>
5
+ License-Expression: BSD-3-Clause
6
+ License-File: licenses/BSD-3-Clause.txt
7
+ Keywords: revit,rules
8
+ Requires-Python: >=3.11
9
+ Requires-Dist: pydantic>2
@@ -0,0 +1,7 @@
1
+ # pyrulefilter
2
+
3
+ TODO:
4
+ [![PyPI - Version](https://img.shields.io/pypi/v/pyrulefilter.svg)](https://pypi.org/project/pyrulefilter)
5
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyrulefilter.svg)](https://pypi.org/project/pyrulefilter)
6
+ Used to create rules for filtering lists of dictionaries (tabular style).
7
+
@@ -0,0 +1 @@
1
+ /.quarto/
@@ -0,0 +1,35 @@
1
+ project:
2
+ type: website
3
+
4
+ website:
5
+ page-navigation: true
6
+ navbar:
7
+ left:
8
+ - index.qmd
9
+ - reference/operators.qmd
10
+
11
+ right:
12
+ - icon: github
13
+ href: https://github.com/maxfordham/pyrulefilter
14
+ aria-label: GitHub
15
+
16
+
17
+ quartodoc:
18
+ # the name used to import the package you want to create reference docs for
19
+ package: pyrulefilter
20
+ parser: google
21
+
22
+ sections:
23
+ - title: Some functions
24
+ contents:
25
+ # the functions being documented in the package.
26
+ # you can refer to anything: class methods, modules, etc..
27
+ - operators
28
+
29
+ format:
30
+ html:
31
+ css: styles.css
32
+ toc: true
33
+ theme:
34
+ light: flatly
35
+ dark: darkly
@@ -0,0 +1,50 @@
1
+ ---
2
+ title: "pyrulefilter"
3
+ ---
4
+
5
+ Use python to simply check if a flat dict of data complies with a rule and return a boolean value.
6
+ The main benefit is that both the data and the rule can be defined as json objects and stored
7
+ as data.
8
+
9
+ ```{python}
10
+
11
+ from pyrulefilter import rule_check_dict, OperatorsEnum, Rule
12
+
13
+ data = {"a": "ave a good day", "b": "ave a mediocre day"}
14
+ r1 = Rule(parameter="a", value="ave", operator=OperatorsEnum.BeginsWith)
15
+ rule_check_dict(data, r1)
16
+
17
+ ```
18
+
19
+
20
+ :::{.callout-note collapse="true" title="RuleSet definitions and operators match Revit"}
21
+ This enables Rulesets to be declared externally and programmaticlly generated in REvit using the Revit API.
22
+
23
+ ```json
24
+ {
25
+ "revit_version": "2022",
26
+ "revit_version_name": "Autodesk Revit 2022",
27
+ "revit_api_query": "Autodesk.Revit.DB.ParameterFilterRuleFactory",
28
+ "revit_api_docs": "https://www.revitapidocs.com/2023/317755a4-24ba-9f36-7639-f6fb2aa5a1a7.htm",
29
+ "operators": {
30
+ "CreateBeginsWithRule": "begins with",
31
+ "CreateContainsRule": "contains",
32
+ "CreateEndsWithRule": "ends with",
33
+ "CreateEqualsRule": "equals",
34
+ "CreateGreaterOrEqualRule": "is greater than or equal to",
35
+ "CreateGreaterRule": "is greater than",
36
+ "CreateHasNoValueParameterRule": "has no value",
37
+ "CreateHasValueParameterRule": "has value",
38
+ "CreateIsAssociatedWithGlobalParameterRule": "?",
39
+ "CreateIsNotAssociatedWithGlobalParameterRule": "?",
40
+ "CreateLessOrEqualRule": "is less than or equal to",
41
+ "CreateLessRule": "is less than",
42
+ "CreateNotBeginsWithRule": "does not begin with",
43
+ "CreateNotContainsRule": "does not contain",
44
+ "CreateNotEndsWithRule": "does not end with",
45
+ "CreateNotEqualsRule": "dont not equal",
46
+ "CreateSharedParameterApplicableRule": "?"
47
+ }
48
+ }
49
+ ```
50
+ :::
@@ -0,0 +1 @@
1
+ {"project": "pyrulefilter", "version": "0.0.9999", "count": 9, "items": [{"name": "pyrulefilter.operators.contains", "domain": "py", "role": "function", "priority": "1", "uri": "reference/operators.html#pyrulefilter.operators.contains", "dispname": "-"}, {"name": "pyrulefilter.operators.endswith", "domain": "py", "role": "function", "priority": "1", "uri": "reference/operators.html#pyrulefilter.operators.endswith", "dispname": "-"}, {"name": "pyrulefilter.operators.isnone", "domain": "py", "role": "function", "priority": "1", "uri": "reference/operators.html#pyrulefilter.operators.isnone", "dispname": "-"}, {"name": "pyrulefilter.operators.not_contains", "domain": "py", "role": "function", "priority": "1", "uri": "reference/operators.html#pyrulefilter.operators.not_contains", "dispname": "-"}, {"name": "pyrulefilter.operators.not_endswith", "domain": "py", "role": "function", "priority": "1", "uri": "reference/operators.html#pyrulefilter.operators.not_endswith", "dispname": "-"}, {"name": "pyrulefilter.operators.not_isnone", "domain": "py", "role": "function", "priority": "1", "uri": "reference/operators.html#pyrulefilter.operators.not_isnone", "dispname": "-"}, {"name": "pyrulefilter.operators.not_startswith", "domain": "py", "role": "function", "priority": "1", "uri": "reference/operators.html#pyrulefilter.operators.not_startswith", "dispname": "-"}, {"name": "pyrulefilter.operators.startswith", "domain": "py", "role": "function", "priority": "1", "uri": "reference/operators.html#pyrulefilter.operators.startswith", "dispname": "-"}, {"name": "pyrulefilter.operators", "domain": "py", "role": "module", "priority": "1", "uri": "reference/operators.html#pyrulefilter.operators", "dispname": "-"}]}
@@ -0,0 +1,7 @@
1
+ # Function reference {.doc .doc-index}
2
+
3
+ ## Some functions
4
+
5
+ | | |
6
+ | --- | --- |
7
+ | [operators](operators.qmd#pyrulefilter.operators) | |
@@ -0,0 +1,154 @@
1
+ # operators { #pyrulefilter.operators }
2
+
3
+ `operators`
4
+
5
+
6
+
7
+ ## Functions
8
+
9
+ | Name | Description |
10
+ | --- | --- |
11
+ | [contains](#pyrulefilter.operators.contains) | Check a in b. |
12
+ | [endswith](#pyrulefilter.operators.endswith) | Check a endswith b |
13
+ | [isnone](#pyrulefilter.operators.isnone) | Check a isnone. |
14
+ | [not_contains](#pyrulefilter.operators.not_contains) | Check a not in b. |
15
+ | [not_endswith](#pyrulefilter.operators.not_endswith) | Check a not_endswith b. |
16
+ | [not_isnone](#pyrulefilter.operators.not_isnone) | Check a isnone. |
17
+ | [not_startswith](#pyrulefilter.operators.not_startswith) | Check a not startswith b. |
18
+ | [startswith](#pyrulefilter.operators.startswith) | Check a startswith b. |
19
+
20
+ ### contains { #pyrulefilter.operators.contains }
21
+
22
+ ```python
23
+ operators.contains(a, b)
24
+ ```
25
+
26
+ Check a in b.
27
+
28
+ ```py
29
+ from pyrulefilter.operators import contains
30
+
31
+ print(contains("hello", "hell"))
32
+ #> True
33
+ print(contains("heel", "hello"))
34
+ #> False
35
+ ```
36
+
37
+ ### endswith { #pyrulefilter.operators.endswith }
38
+
39
+ ```python
40
+ operators.endswith(a, b)
41
+ ```
42
+
43
+ Check a endswith b
44
+
45
+ ```py
46
+ from pyrulefilter.operators import endswith
47
+
48
+ print(endswith("hello", "lo"))
49
+ #> True
50
+ print(endswith("hello", "elo"))
51
+ #> False
52
+ ```
53
+
54
+ ### isnone { #pyrulefilter.operators.isnone }
55
+
56
+ ```python
57
+ operators.isnone(a, b=None)
58
+ ```
59
+
60
+ Check a isnone.
61
+
62
+ ```py
63
+ from pyrulefilter.operators import isnone
64
+
65
+ print(isnone("hello"))
66
+ #> False
67
+ print(isnone(None))
68
+ #> True
69
+ ```
70
+
71
+ ### not_contains { #pyrulefilter.operators.not_contains }
72
+
73
+ ```python
74
+ operators.not_contains(a, b)
75
+ ```
76
+
77
+ Check a not in b.
78
+
79
+ ```py
80
+ from pyrulefilter.operators import not_contains
81
+
82
+ print(not_contains("hello", "hell"))
83
+ #> False
84
+ print(not_contains("heel", "hello"))
85
+ #> True
86
+ ```
87
+
88
+ ### not_endswith { #pyrulefilter.operators.not_endswith }
89
+
90
+ ```python
91
+ operators.not_endswith(a, b)
92
+ ```
93
+
94
+ Check a not_endswith b.
95
+
96
+ ```py
97
+ from pyrulefilter.operators import not_endswith
98
+
99
+ print(not_endswith("hello", "lo"))
100
+ #> False
101
+ print(not_endswith("hello", "elo"))
102
+ #> True
103
+ ```
104
+
105
+ ### not_isnone { #pyrulefilter.operators.not_isnone }
106
+
107
+ ```python
108
+ operators.not_isnone(a, b=None)
109
+ ```
110
+
111
+ Check a isnone.
112
+
113
+ ```py
114
+ from pyrulefilter.operators import not_isnone
115
+
116
+ print(not_isnone("hello"))
117
+ #> True
118
+ print(not_isnone(None))
119
+ #> False
120
+ ```
121
+
122
+ ### not_startswith { #pyrulefilter.operators.not_startswith }
123
+
124
+ ```python
125
+ operators.not_startswith(a, b)
126
+ ```
127
+
128
+ Check a not startswith b.
129
+
130
+ ```py
131
+ from pyrulefilter.operators import not_startswith
132
+
133
+ print(not_startswith("hello", "hell"))
134
+ #> False
135
+ print(not_startswith("heel", "hello"))
136
+ #> True
137
+ ```
138
+
139
+ ### startswith { #pyrulefilter.operators.startswith }
140
+
141
+ ```python
142
+ operators.startswith(a, b)
143
+ ```
144
+
145
+ Check a startswith b.
146
+
147
+ ```py
148
+ from pyrulefilter.operators import startswith
149
+
150
+ print(startswith("hello", "hell"))
151
+ #> True
152
+ print(startswith("heel", "hello"))
153
+ #> False
154
+ ```
@@ -0,0 +1,15 @@
1
+ Note: This license has also been called the “New BSD License” or “Modified BSD License”. See also the 2-clause BSD License.
2
+
3
+ Copyright <YEAR> <COPYRIGHT HOLDER>
4
+
5
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8
+
9
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10
+
11
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
+
15
+ // SPDX-License-Identifier: BSD-3-Clause