Metadata-Version: 2.5
Name: pyrulecc
Version: 0.0.3
Summary: Evaluate field conditions against records, with dotted paths.
Project-URL: Homepage, https://pypi.org/project/pyrulecc/
Author-email: lqxnjk <lqxnjk@qq.com>
License: MIT
License-File: LICENSE
Keywords: conditions,filter,match,records,rules
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# pyrulecc

[English](#english) | 中文

用数据描述筛选条件，按字段匹配记录，支持点号路径。

## 安装

```console
pip install pyrulecc
```

## 用法

```python
from pyrulecc import filter_records, match_record

row = {"name": "alice", "age": 30, "org": {"code": "A1"}}

match_record(row, {"age": (">=", 18)})            # True
match_record(row, {"name": ("contains", "li")})   # True
match_record(row, {"org.code": "A1"})             # True

rows = [{"n": 1}, {"n": 5}, {"n": 9}]
filter_records(rows, {"n": (">", 2)})            # [{'n': 5}, {'n': 9}]
```

## 说明

规则值可以写裸值（等价 `eq`）或 `(运算符, 值)`；键支持 `a.b` 形式的嵌套路径。记录缺少该字段时**永不匹配**——带洞的数据不该被静默放行。未知运算符抛 `ValueError`。

## 许可证

MIT

---

<a id="english"></a>
## English

Evaluate field conditions against records, with dotted paths.

## Install

```console
pip install pyrulecc
```

## Usage

```python
from pyrulecc import filter_records, match_record

row = {"name": "alice", "age": 30, "org": {"code": "A1"}}

match_record(row, {"age": (">=", 18)})            # True
match_record(row, {"name": ("contains", "li")})   # True
match_record(row, {"org.code": "A1"})             # True

rows = [{"n": 1}, {"n": 5}, {"n": 9}]
filter_records(rows, {"n": (">", 2)})            # [{'n': 5}, {'n': 9}]
```

## Notes

A rule value is either a bare value (means `eq`) or an `(operator, value)` pair. Keys may be dotted paths into nested dicts. A missing field never matches, and an unknown operator raises `ValueError`.

## License

MIT
