<a name="readme-top"></a>
# 🤏🏻 Criteria Pattern
<p align="center">
<a href="https://github.com/adriamontoto/criteria-pattern/actions/workflows/test.yaml?event=push&branch=master" target="_blank">
<img src="https://github.com/adriamontoto/criteria-pattern/actions/workflows/test.yaml/badge.svg?event=push&branch=master" alt="Test Pipeline">
</a>
<a href="https://github.com/adriamontoto/criteria-pattern/actions/workflows/lint.yaml?event=push&branch=master" target="_blank">
<img src="https://github.com/adriamontoto/criteria-pattern/actions/workflows/lint.yaml/badge.svg?event=push&branch=master" alt="Lint Pipeline">
</a>
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/adriamontoto/criteria-pattern" target="_blank">
<img src="https://coverage-badge.samuelcolvin.workers.dev/adriamontoto/criteria-pattern.svg" alt="Coverage Pipeline">
</a>
<a href="https://pypi.org/project/criteria-pattern" target="_blank">
<img src="https://img.shields.io/pypi/v/criteria-pattern?color=%2334D058&label=pypi%20package" alt="Package Version">
</a>
<a href="https://pypi.org/project/criteria-pattern/" target="_blank">
<img src="https://img.shields.io/pypi/pyversions/criteria-pattern.svg?color=%2334D058" alt="Supported Python Versions">
</a>
</p>
The "Criteria Pattern" is a Python 🐍 package that simplifies and standardizes criteria based filtering 🤏🏻, validation and selection. This package provides a set of prebuilt 👷🏻 objects and utilities that you can drop into your existing projects and not have to implement yourself.
These utilities 🛠️ are useful when you need complex filtering logic. It also enforces 👮🏻 best practices so all your filtering processes follow a uniform standard.
Easy to install and integrate, this is a must have for any Python developer looking to simplify their workflow, enforce design patterns and use the full power of modern ORMs and SQL 🗄️ in their projects 🚀.
<br><br>
## Table of Contents
- [📥 Installation](#installation)
- [🔑 License](#license)
- [💻 Utilization](#utilization)
<br><br>
<p align="right">
<a href="#readme-top">🔼 Back to top</a>
</p>
<a name="installation"></a>
## 📥 Installation
```bash
pip install criteria-pattern
```
<br><br>
<p align="right">
<a href="#readme-top">🔼 Back to top</a>
</p>
<a name="utilization"></a>
## 💻 Utilization
```python
from criteria_pattern import Criteria, Filter, FilterOperator
from criteria_pattern.converter import SqlConverter
is_adult = Criteria(filters=[Filter('age', FilterOperator.GREATER_OR_EQUAL, 18)])
email_is_gmail = Criteria(filters=[Filter('email', FilterOperator.ENDS_WITH, '@gmail.com')])
email_is_yahoo = Criteria(filters=[Filter('email', FilterOperator.ENDS_WITH, '@yahoo.com')])
query = SqlConverter.convert(criteria=is_adult & (email_is_gmail | email_is_yahoo), table='user')
print(query)
# >>> SELECT * FROM user WHERE (age >= '18' AND (email LIKE '%@gmail.com' OR email LIKE '%@yahoo.com'));
```
<br><br>
<p align="right">
<a href="#readme-top">🔼 Back to top</a>
</p>
<a name="license"></a>
## 🔑 License
This project is licensed under the terms of the [MIT license](https://choosealicense.com/licenses/mit/).
<br><br>
<p align="right">
<a href="#readme-top">🔼 Back to top</a>
</p>
Raw data
{
"_id": null,
"home_page": null,
"name": "criteria-pattern",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "criteria, development, filtering, pattern, python, selection, tools, utilities, validation",
"author": "Adria Montoto",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/e4/e6/84d0ef6e9ac521aa91838e953c9a32feb178b81c5b45652a043d30a81215/criteria_pattern-2024.11.5.tar.gz",
"platform": null,
"description": "<a name=\"readme-top\"></a>\n\n# \ud83e\udd0f\ud83c\udffb Criteria Pattern\n<p align=\"center\">\n <a href=\"https://github.com/adriamontoto/criteria-pattern/actions/workflows/test.yaml?event=push&branch=master\" target=\"_blank\">\n <img src=\"https://github.com/adriamontoto/criteria-pattern/actions/workflows/test.yaml/badge.svg?event=push&branch=master\" alt=\"Test Pipeline\">\n </a>\n <a href=\"https://github.com/adriamontoto/criteria-pattern/actions/workflows/lint.yaml?event=push&branch=master\" target=\"_blank\">\n <img src=\"https://github.com/adriamontoto/criteria-pattern/actions/workflows/lint.yaml/badge.svg?event=push&branch=master\" alt=\"Lint Pipeline\">\n </a>\n <a href=\"https://coverage-badge.samuelcolvin.workers.dev/redirect/adriamontoto/criteria-pattern\" target=\"_blank\">\n <img src=\"https://coverage-badge.samuelcolvin.workers.dev/adriamontoto/criteria-pattern.svg\" alt=\"Coverage Pipeline\">\n </a>\n <a href=\"https://pypi.org/project/criteria-pattern\" target=\"_blank\">\n <img src=\"https://img.shields.io/pypi/v/criteria-pattern?color=%2334D058&label=pypi%20package\" alt=\"Package Version\">\n </a>\n <a href=\"https://pypi.org/project/criteria-pattern/\" target=\"_blank\">\n <img src=\"https://img.shields.io/pypi/pyversions/criteria-pattern.svg?color=%2334D058\" alt=\"Supported Python Versions\">\n </a>\n</p>\n\nThe \"Criteria Pattern\" is a Python \ud83d\udc0d package that simplifies and standardizes criteria based filtering \ud83e\udd0f\ud83c\udffb, validation and selection. This package provides a set of prebuilt \ud83d\udc77\ud83c\udffb objects and utilities that you can drop into your existing projects and not have to implement yourself.\n\nThese utilities \ud83d\udee0\ufe0f are useful when you need complex filtering logic. It also enforces \ud83d\udc6e\ud83c\udffb best practices so all your filtering processes follow a uniform standard.\n\nEasy to install and integrate, this is a must have for any Python developer looking to simplify their workflow, enforce design patterns and use the full power of modern ORMs and SQL \ud83d\uddc4\ufe0f in their projects \ud83d\ude80.\n<br><br>\n\n\n## Table of Contents\n- [\ud83d\udce5 Installation](#installation)\n- [\ud83d\udd11 License](#license)\n- [\ud83d\udcbb Utilization](#utilization)\n<br><br>\n\n<p align=\"right\">\n <a href=\"#readme-top\">\ud83d\udd3c Back to top</a>\n</p>\n\n\n<a name=\"installation\"></a>\n## \ud83d\udce5 Installation\n```bash\npip install criteria-pattern\n```\n<br><br>\n\n<p align=\"right\">\n <a href=\"#readme-top\">\ud83d\udd3c Back to top</a>\n</p>\n\n\n<a name=\"utilization\"></a>\n## \ud83d\udcbb Utilization\n\n```python\nfrom criteria_pattern import Criteria, Filter, FilterOperator\nfrom criteria_pattern.converter import SqlConverter\n\nis_adult = Criteria(filters=[Filter('age', FilterOperator.GREATER_OR_EQUAL, 18)])\nemail_is_gmail = Criteria(filters=[Filter('email', FilterOperator.ENDS_WITH, '@gmail.com')])\nemail_is_yahoo = Criteria(filters=[Filter('email', FilterOperator.ENDS_WITH, '@yahoo.com')])\n\nquery = SqlConverter.convert(criteria=is_adult & (email_is_gmail | email_is_yahoo), table='user')\n\nprint(query)\n\n# >>> SELECT * FROM user WHERE (age >= '18' AND (email LIKE '%@gmail.com' OR email LIKE '%@yahoo.com'));\n```\n<br><br>\n\n<p align=\"right\">\n <a href=\"#readme-top\">\ud83d\udd3c Back to top</a>\n</p>\n\n\n<a name=\"license\"></a>\n## \ud83d\udd11 License\nThis project is licensed under the terms of the [MIT license](https://choosealicense.com/licenses/mit/).\n<br><br>\n\n<p align=\"right\">\n <a href=\"#readme-top\">\ud83d\udd3c Back to top</a>\n</p>\n",
"bugtrack_url": null,
"license": null,
"summary": "The \"Criteria Pattern\" is a Python package that simplifies and standardizes criteria based filtering, validation and selection.",
"version": "2024.11.5",
"project_urls": {
"Homepage": "https://github.com/adriamontoto/criteria-pattern",
"Issues": "https://github.com/adriamontoto/criteria-pattern/issues",
"Repository": "https://github.com/adriamontoto/criteria-pattern"
},
"split_keywords": [
"criteria",
" development",
" filtering",
" pattern",
" python",
" selection",
" tools",
" utilities",
" validation"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "bff8c79f0be236b7211984793082847ab2b75d7f973c9ae32569d0d5a729ec62",
"md5": "f5915a81fb3aa97462de978d256fadcc",
"sha256": "227a296457eca409129596a475269cd5e5856c926226c4e90105f720638adf6d"
},
"downloads": -1,
"filename": "criteria_pattern-2024.11.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f5915a81fb3aa97462de978d256fadcc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 12448,
"upload_time": "2024-11-05T16:34:01",
"upload_time_iso_8601": "2024-11-05T16:34:01.305117Z",
"url": "https://files.pythonhosted.org/packages/bf/f8/c79f0be236b7211984793082847ab2b75d7f973c9ae32569d0d5a729ec62/criteria_pattern-2024.11.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e4e684d0ef6e9ac521aa91838e953c9a32feb178b81c5b45652a043d30a81215",
"md5": "8ca91870b5be447da4367c7410eb9dd2",
"sha256": "7edc0d038d309cb565030fd5370984e9bc56cad6c12e50b43d8d485074305d9c"
},
"downloads": -1,
"filename": "criteria_pattern-2024.11.5.tar.gz",
"has_sig": false,
"md5_digest": "8ca91870b5be447da4367c7410eb9dd2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 15774,
"upload_time": "2024-11-05T16:34:02",
"upload_time_iso_8601": "2024-11-05T16:34:02.557766Z",
"url": "https://files.pythonhosted.org/packages/e4/e6/84d0ef6e9ac521aa91838e953c9a32feb178b81c5b45652a043d30a81215/criteria_pattern-2024.11.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-05 16:34:02",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "adriamontoto",
"github_project": "criteria-pattern",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "criteria-pattern"
}