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
pip install criteria-pattern
💻 Utilization
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'));
🔑 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
File details
Details for the file criteria_pattern-2024.11.5.tar.gz
.
File metadata
- Download URL: criteria_pattern-2024.11.5.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7edc0d038d309cb565030fd5370984e9bc56cad6c12e50b43d8d485074305d9c |
|
MD5 | 8ca91870b5be447da4367c7410eb9dd2 |
|
BLAKE2b-256 | e4e684d0ef6e9ac521aa91838e953c9a32feb178b81c5b45652a043d30a81215 |
Provenance
The following attestation bundles were made for criteria_pattern-2024.11.5.tar.gz
:
Publisher:
publish.yaml
on adriamontoto/criteria-pattern
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
criteria_pattern-2024.11.5.tar.gz
- Subject digest:
7edc0d038d309cb565030fd5370984e9bc56cad6c12e50b43d8d485074305d9c
- Sigstore transparency entry: 146788573
- Sigstore integration time:
- Predicate type:
File details
Details for the file criteria_pattern-2024.11.5-py3-none-any.whl
.
File metadata
- Download URL: criteria_pattern-2024.11.5-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 227a296457eca409129596a475269cd5e5856c926226c4e90105f720638adf6d |
|
MD5 | f5915a81fb3aa97462de978d256fadcc |
|
BLAKE2b-256 | bff8c79f0be236b7211984793082847ab2b75d7f973c9ae32569d0d5a729ec62 |
Provenance
The following attestation bundles were made for criteria_pattern-2024.11.5-py3-none-any.whl
:
Publisher:
publish.yaml
on adriamontoto/criteria-pattern
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
criteria_pattern-2024.11.5-py3-none-any.whl
- Subject digest:
227a296457eca409129596a475269cd5e5856c926226c4e90105f720638adf6d
- Sigstore transparency entry: 146788575
- Sigstore integration time:
- Predicate type: