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

CI 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

You can install Criteria Pattern using pip:

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, parameters = SqlConverter.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'}

🔼 Back to top



🤝 Contributing

We love community help! Before you open an issue or pull request, please read:

Thank you for helping make 🤏🏻 Criteria Pattern package awesome! 🌟

🔼 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-0.1.1.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

criteria_pattern-0.1.1-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file criteria_pattern-0.1.1.tar.gz.

File metadata

  • Download URL: criteria_pattern-0.1.1.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for criteria_pattern-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c8c6b124f078c946748b0c8c6ee31862271d3f2c4fc4d6232ddffb82e692dcf7
MD5 6ef1297c32d1f8f1ad81511b09d0706c
BLAKE2b-256 4b506d5aab83e4e995b83d08bd7d7496294fed180237bac96ad96372e60c17bb

See more details on using hashes here.

Provenance

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

Publisher: ci.yaml on adriamontoto/criteria-pattern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for criteria_pattern-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d8e2375780ae214613cd720d7cd2d7b6d9385ce86364eee4354822656e3b32c9
MD5 8d41f7375fba4746deff071738c279ad
BLAKE2b-256 84257bca44ef263c563ba797c08d91c56f88e464c475a17c880752e800b0c97e

See more details on using hashes here.

Provenance

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

Publisher: ci.yaml on adriamontoto/criteria-pattern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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