The Criteria Pattern is a Python package that simplifies and standardizes criteria based filtering, validation and selection.
Project description
🤏🏻 Criteria Pattern
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 🚀.
Table of Contents
📥 Installation
You can install Criteria Pattern using pip:
pip install criteria-pattern
📚 Documentation
This project's documentation is powered by DeepWiki, which provides a comprehensive overview of the Criteria Pattern and its usage.
💻 Utilization
from criteria_pattern import Criteria, Filter, Operator
from criteria_pattern.converters import CriteriaToPostgresqlConverter
is_adult = Criteria(filters=[Filter(field='age', operator=Operator.GREATER_OR_EQUAL, value=18)])
email_is_gmail = Criteria(filters=[Filter(field='email', operator=Operator.ENDS_WITH, value='@gmail.com')])
email_is_yahoo = Criteria(filters=[Filter(field='email', operator=Operator.ENDS_WITH, value='@yahoo.com')])
query, parameters = CriteriaToPostgresqlConverter.convert(criteria=is_adult & (email_is_gmail | email_is_yahoo), table='user')
print(query)
print(parameters)
# >>> SELECT * FROM user WHERE (age >= %(parameter_0)s AND (email LIKE '%%' || %(parameter_1)s OR email LIKE '%%' || %(parameter_2)s));
# >>> {'parameter_0': 18, 'parameter_1': '@gmail.com', 'parameter_2': '@yahoo.com'}
🤝 Contributing
We love community help! Before you open an issue or pull request, please read:
Thank you for helping make 🤏🏻 Criteria Pattern package awesome! 🌟
🔑 License
This project is licensed under the terms of the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file criteria_pattern-3.4.0.tar.gz.
File metadata
- Download URL: criteria_pattern-3.4.0.tar.gz
- Upload date:
- Size: 24.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aafd5af8ab7c976b44e9825959ed3e1367f01427240ddaa365f238db43756b07
|
|
| MD5 |
79e6006811981d9b26ab9afaf667b894
|
|
| BLAKE2b-256 |
6061dca7c36ca31d5986e7053640dbb25da3c755569f5c3e0f19aae4b33e703f
|
Provenance
The following attestation bundles were made for criteria_pattern-3.4.0.tar.gz:
Publisher:
ci.yaml on adriamontoto/criteria-pattern
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
criteria_pattern-3.4.0.tar.gz -
Subject digest:
aafd5af8ab7c976b44e9825959ed3e1367f01427240ddaa365f238db43756b07 - Sigstore transparency entry: 523618835
- Sigstore integration time:
-
Permalink:
adriamontoto/criteria-pattern@e223adf7c92d4e12863fef2e3dd399c7b10e0881 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/adriamontoto
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yaml@e223adf7c92d4e12863fef2e3dd399c7b10e0881 -
Trigger Event:
push
-
Statement type:
File details
Details for the file criteria_pattern-3.4.0-py3-none-any.whl.
File metadata
- Download URL: criteria_pattern-3.4.0-py3-none-any.whl
- Upload date:
- Size: 50.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d858558112f225f154174f0feb98bc46aae6d120116a3e161b86e07edd157a52
|
|
| MD5 |
3df9a5fc64d2851451ffaef989b1f07f
|
|
| BLAKE2b-256 |
428ac81ca02cca80ba59c0fa88b73ef4a9d7c7e3357acd257acbffe0c2fbae7c
|
Provenance
The following attestation bundles were made for criteria_pattern-3.4.0-py3-none-any.whl:
Publisher:
ci.yaml on adriamontoto/criteria-pattern
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
criteria_pattern-3.4.0-py3-none-any.whl -
Subject digest:
d858558112f225f154174f0feb98bc46aae6d120116a3e161b86e07edd157a52 - Sigstore transparency entry: 523618843
- Sigstore integration time:
-
Permalink:
adriamontoto/criteria-pattern@e223adf7c92d4e12863fef2e3dd399c7b10e0881 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/adriamontoto
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yaml@e223adf7c92d4e12863fef2e3dd399c7b10e0881 -
Trigger Event:
push
-
Statement type: