Skip to main content

The "Criteria Pattern" is a Python package that simplifies and standardizes criteria based filtering, validation and selection.

Project description

🤏🏻 Criteria Pattern

Test Pipeline Lint Pipeline Coverage Pipeline Package Version Supported Python Versions

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

🔼 Back to top

📥 Installation

pip install criteria-pattern



🔼 Back to top

💻 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'));



🔼 Back to top

🔑 License

This project is licensed under the terms of the MIT license.

🔼 Back to top

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

criteria_pattern-2024.11.5.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

criteria_pattern-2024.11.5-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

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

Hashes for criteria_pattern-2024.11.5.tar.gz
Algorithm Hash digest
SHA256 7edc0d038d309cb565030fd5370984e9bc56cad6c12e50b43d8d485074305d9c
MD5 8ca91870b5be447da4367c7410eb9dd2
BLAKE2b-256 e4e684d0ef6e9ac521aa91838e953c9a32feb178b81c5b45652a043d30a81215

See more details on using hashes here.

Provenance

The following attestation bundles were made for criteria_pattern-2024.11.5.tar.gz:

Publisher: publish.yaml on adriamontoto/criteria-pattern

Attestations:

File details

Details for the file criteria_pattern-2024.11.5-py3-none-any.whl.

File metadata

File hashes

Hashes for criteria_pattern-2024.11.5-py3-none-any.whl
Algorithm Hash digest
SHA256 227a296457eca409129596a475269cd5e5856c926226c4e90105f720638adf6d
MD5 f5915a81fb3aa97462de978d256fadcc
BLAKE2b-256 bff8c79f0be236b7211984793082847ab2b75d7f973c9ae32569d0d5a729ec62

See more details on using hashes here.

Provenance

The following attestation bundles were made for criteria_pattern-2024.11.5-py3-none-any.whl:

Publisher: publish.yaml on adriamontoto/criteria-pattern

Attestations:

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page