| Name | lumi-filter JSON |
| Version |
0.2.0
JSON |
| download |
| home_page | None |
| Summary | A powerful and flexible data filtering library with unified interface for multiple data sources |
| upload_time | 2025-09-01 02:49:02 |
| maintainer | None |
| docs_url | None |
| author | None |
| requires_python | >=3.12 |
| license | MIT |
| keywords |
filter
flask
peewee
pydantic
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# lumi_filter
> For specific use cases, please refer to the examples:
[Examples](https://github.com/chaleaoch/lumi_filter/tree/main/example)
lumi_filter is a powerful and flexible data filtering library designed to simplify how you filter and sort data across different data sources in your Python applications. Whether you're dealing with database queries, API responses, or in-memory data structures, lumi_filter provides a unified, intuitive interface that makes complex filtering operations effortless. Inspired by Django REST Framework's filtering system, lumi_filter has been redesigned to support multiple backends and data sources. Flask-friendly and compatible.
lumi_filter is a model-based filtering library that bridges the gap between different data sources and filtering needs. At its core, it provides a consistent API for filtering the following data sources:
- **Peewee ORM queries** - Direct database filtering through automatic SQL generation
- **Pydantic models** - Filter structured data with type validation
- **Iterable data structures** - Filter lists, dictionaries, and other Python collections
This library eliminates the need to write different filtering logic for each data source, allowing you to define filtering requirements once and apply them universally.
## Why Choose lumi_filter?
### Unified Filtering Interface
Suppose you need to implement filtering functionality throughout your application that needs to handle both database records and API responses. Without lumi_filter, you would typically need to write separate filtering logic for each data source:
#### Database Filtering (Peewee)
```python
query = Product.select().where(Product.name.contains("apple") & Product.price >= 100)
```
#### List Filtering (Python)
```python
filtered_products = [p for p in products if "apple" in p["name"] and p["price"] >= 100]
```
With lumi_filter, you define the filtering model once and use it everywhere:
```python
class FilterProduct(Model):
name = StrField(source="name")
price = DecimalField(source="price")
```
#### For Database Queries
```python
db_filter = FilterProduct(Product.select(), request.args)
filtered_query = db_filter.filter().result()
```
#### For Iterable Data
```python
list_filter = FilterProduct(products_list, request.args)
filtered_list = list_filter.filter().result()
```
## Rich Filtering Expressions
lumi_filter supports a comprehensive set of filtering operators that go beyond simple equality checks:
| Operator | Description | Example |
|----------|-------------|---------|
| (none) | Exact match | name=Apple |
| __in | In value list | name__in=Apple,Orange |
| __nin | Not in value list | name__nin=Apple,Orange |
| __gte | Greater than or equal | price__gte=100 |
| __lte | Less than or equal | price__lte=500 |
| __contains | Contains substring | name__contains=apple |
| __startswith | Starts with | name__startswith=A |
| __endswith | Ends with | name__endswith=e |
## Automatic Type Detection and Mapping
The library intelligently detects field types and maps them to appropriate filter fields, supporting:
- String fields with pattern matching
- Numeric fields with range comparisons
- Date/time fields with temporal filtering
- Boolean fields with truthiness filtering
- Nested fields with dot notation support
## TODO
- [ ] Support for pagination
- [ ] Field-level permission control
- [ ] Field-level custom filtering
- [ ] Support for more ORMs (e.g., SQLAlchemy)
Raw data
{
"_id": null,
"home_page": null,
"name": "lumi-filter",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": "chaleaoch <chaleaoch@gmail.com>",
"keywords": "filter, flask, peewee, pydantic",
"author": null,
"author_email": "chaleaoch <chaleaoch@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/08/30/9bc505f7145d842f796a40dcc44c1d256c0cd7ecd73e96cc71c6a6430eec/lumi_filter-0.2.0.tar.gz",
"platform": null,
"description": "# lumi_filter\n\n> For specific use cases, please refer to the examples:\n[Examples](https://github.com/chaleaoch/lumi_filter/tree/main/example)\n\nlumi_filter is a powerful and flexible data filtering library designed to simplify how you filter and sort data across different data sources in your Python applications. Whether you're dealing with database queries, API responses, or in-memory data structures, lumi_filter provides a unified, intuitive interface that makes complex filtering operations effortless. Inspired by Django REST Framework's filtering system, lumi_filter has been redesigned to support multiple backends and data sources. Flask-friendly and compatible.\n\nlumi_filter is a model-based filtering library that bridges the gap between different data sources and filtering needs. At its core, it provides a consistent API for filtering the following data sources:\n\n- **Peewee ORM queries** - Direct database filtering through automatic SQL generation\n- **Pydantic models** - Filter structured data with type validation\n- **Iterable data structures** - Filter lists, dictionaries, and other Python collections\n\nThis library eliminates the need to write different filtering logic for each data source, allowing you to define filtering requirements once and apply them universally.\n\n## Why Choose lumi_filter?\n\n### Unified Filtering Interface\n\nSuppose you need to implement filtering functionality throughout your application that needs to handle both database records and API responses. Without lumi_filter, you would typically need to write separate filtering logic for each data source:\n\n#### Database Filtering (Peewee)\n\n```python\nquery = Product.select().where(Product.name.contains(\"apple\") & Product.price >= 100)\n```\n\n#### List Filtering (Python)\n\n```python\nfiltered_products = [p for p in products if \"apple\" in p[\"name\"] and p[\"price\"] >= 100]\n```\n\nWith lumi_filter, you define the filtering model once and use it everywhere:\n\n```python\nclass FilterProduct(Model):\n name = StrField(source=\"name\")\n price = DecimalField(source=\"price\")\n```\n\n#### For Database Queries\n\n```python\ndb_filter = FilterProduct(Product.select(), request.args)\nfiltered_query = db_filter.filter().result()\n```\n\n#### For Iterable Data\n\n```python\nlist_filter = FilterProduct(products_list, request.args)\nfiltered_list = list_filter.filter().result()\n```\n\n## Rich Filtering Expressions\n\nlumi_filter supports a comprehensive set of filtering operators that go beyond simple equality checks:\n\n| Operator | Description | Example |\n|----------|-------------|---------|\n| (none) | Exact match | name=Apple |\n| __in | In value list | name__in=Apple,Orange |\n| __nin | Not in value list | name__nin=Apple,Orange |\n| __gte | Greater than or equal | price__gte=100 |\n| __lte | Less than or equal | price__lte=500 |\n| __contains | Contains substring | name__contains=apple |\n| __startswith | Starts with | name__startswith=A |\n| __endswith | Ends with | name__endswith=e |\n\n## Automatic Type Detection and Mapping\n\nThe library intelligently detects field types and maps them to appropriate filter fields, supporting:\n\n- String fields with pattern matching\n- Numeric fields with range comparisons\n- Date/time fields with temporal filtering\n- Boolean fields with truthiness filtering\n- Nested fields with dot notation support\n\n## TODO\n\n- [ ] Support for pagination\n- [ ] Field-level permission control\n- [ ] Field-level custom filtering\n- [ ] Support for more ORMs (e.g., SQLAlchemy)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A powerful and flexible data filtering library with unified interface for multiple data sources",
"version": "0.2.0",
"project_urls": {
"Bug Tracker": "https://github.com/chaleaoch/lumi_filter/issues",
"Documentation": "https://github.com/chaleaoch/lumi_filter",
"Homepage": "https://github.com/chaleaoch/lumi_filter",
"Repository": "https://github.com/chaleaoch/lumi_filter"
},
"split_keywords": [
"filter",
" flask",
" peewee",
" pydantic"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "647242162c4903e8493ebc1e02a2aff456d63b08e0dd0d2b97b96fe1c104ea56",
"md5": "96d0ad3fb978dffb5199e43e6aa53352",
"sha256": "ab3574a61b8676ee2a0aa93735b0a85f9824c2e6cefebf96f22b183752d53748"
},
"downloads": -1,
"filename": "lumi_filter-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "96d0ad3fb978dffb5199e43e6aa53352",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 16560,
"upload_time": "2025-09-01T02:49:01",
"upload_time_iso_8601": "2025-09-01T02:49:01.016879Z",
"url": "https://files.pythonhosted.org/packages/64/72/42162c4903e8493ebc1e02a2aff456d63b08e0dd0d2b97b96fe1c104ea56/lumi_filter-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "08309bc505f7145d842f796a40dcc44c1d256c0cd7ecd73e96cc71c6a6430eec",
"md5": "8e46f561ba5673174924496e70893050",
"sha256": "a1e65de724d952df3ce0a960be6bb5fa80c94198b5b8de1dbe88a848070dca27"
},
"downloads": -1,
"filename": "lumi_filter-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "8e46f561ba5673174924496e70893050",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 75033,
"upload_time": "2025-09-01T02:49:02",
"upload_time_iso_8601": "2025-09-01T02:49:02.880264Z",
"url": "https://files.pythonhosted.org/packages/08/30/9bc505f7145d842f796a40dcc44c1d256c0cd7ecd73e96cc71c6a6430eec/lumi_filter-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-01 02:49:02",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "chaleaoch",
"github_project": "lumi_filter",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "lumi-filter"
}