{"id":13501258,"url":"https://github.com/zeroSteiner/rule-engine","last_synced_at":"2025-03-29T08:32:16.495Z","repository":{"id":37549343,"uuid":"127063639","full_name":"zeroSteiner/rule-engine","owner":"zeroSteiner","description":"A lightweight, optionally typed expression language with a custom grammar for matching arbitrary Python objects.","archived":false,"fork":false,"pushed_at":"2025-02-14T03:05:06.000Z","size":47223,"stargazers_count":511,"open_issues_count":5,"forks_count":56,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-27T15:05:43.793Z","etag":null,"topics":["python","python-library","python3"],"latest_commit_sha":null,"homepage":"https://zerosteiner.github.io/rule-engine/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zeroSteiner.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"ko_fi":"zerosteiner"}},"created_at":"2018-03-28T00:58:06.000Z","updated_at":"2025-03-26T08:19:30.000Z","dependencies_parsed_at":"2023-12-03T01:25:19.519Z","dependency_job_id":"d5caace3-d6a5-4754-ba0d-2a739d25ede2","html_url":"https://github.com/zeroSteiner/rule-engine","commit_stats":{"total_commits":479,"total_committers":7,"mean_commits":68.42857142857143,"dds":0.04175365344467641,"last_synced_commit":"0448d9af0c8e8be2cd9253ce2933e1c281811f3b"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeroSteiner%2Frule-engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeroSteiner%2Frule-engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeroSteiner%2Frule-engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeroSteiner%2Frule-engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zeroSteiner","download_url":"https://codeload.github.com/zeroSteiner/rule-engine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245868294,"owners_count":20685607,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","python-library","python3"],"created_at":"2024-07-31T22:01:30.802Z","updated_at":"2025-03-29T08:32:16.487Z","avatar_url":"https://github.com/zeroSteiner.png","language":"Python","readme":"Rule Engine\n===========\n|badge-build| |badge-pypi|\n\nA lightweight, optionally typed expression language with a custom grammar for matching arbitrary Python objects.\n\nDocumentation is available at https://zeroSteiner.github.io/rule-engine/.\n\n:Warning:\n  The next major version (5.0) will remove support Python versions 3.6, 3.7 and 3.8. There is currently no timeline for\n  its release.\n\nRule Engine expressions are written in their own language, defined as strings in Python. The syntax is most similar to\nPython with some inspiration from Ruby. Some features of this language includes:\n\n- Optional type hinting\n- Matching strings with regular expressions\n- Datetime datatypes\n- Compound datatypes (equivalents for Python dict, list and set types)\n- Data attributes\n- Thread safety\n\nExample Usage\n-------------\nThe following example demonstrates the basic usage of defining a rule object and applying it to two dictionaries,\nshowing that one matches while the other does not. See `Getting Started`_ for more information.\n\n.. code-block:: python\n\n   import rule_engine\n   # match a literal first name and applying a regex to the email\n   rule = rule_engine.Rule(\n       'first_name == \"Luke\" and email =~ \".*@rebels.org$\"'\n   ) # =\u003e \u003cRule text='first_name == \"Luke\" and email =~ \".*@rebels.org$\"' \u003e\n   rule.matches({\n       'first_name': 'Luke', 'last_name': 'Skywalker', 'email': 'luke@rebels.org'\n   }) # =\u003e True\n   rule.matches({\n      'first_name': 'Darth', 'last_name': 'Vader', 'email': 'dvader@empire.net'\n   }) # =\u003e False\n\nThe next example demonstrates the optional type system. A custom context is created that defines two symbols, one string\nand one float. Because symbols are defined, an exception will be raised if an unknown symbol is specified or an invalid\noperation is used. See `Type Hinting`_ for more information.\n\n.. code-block:: python\n\n   import rule_engine\n   # define the custom context with two symbols\n   context = rule_engine.Context(type_resolver=rule_engine.type_resolver_from_dict({\n       'first_name': rule_engine.DataType.STRING,\n       'age': rule_engine.DataType.FLOAT\n   }))\n\n   # receive an error when an unknown symbol is used\n   rule = rule_engine.Rule('last_name == \"Vader\"', context=context)\n   # =\u003e SymbolResolutionError: last_name\n\n   # receive an error when an invalid operation is used\n   rule = rule_engine.Rule('first_name + 1', context=context)\n   # =\u003e EvaluationError: data type mismatch\n\nWant to give the rule expression language a try? Checkout the `Debug REPL`_ that makes experimentation easy. After\ninstalling just run ``python -m rule_engine.debug_repl``.\n\nInstallation\n------------\nInstall the latest release from PyPi using ``pip install rule-engine``. Releases follow `Semantic Versioning`_ to\nindicate in each new version whether it fixes bugs, adds features or breaks backwards compatibility. See the\n`Change Log`_ for a curated list of changes.\n\nCredits\n-------\n* Spencer McIntyre - zeroSteiner |social-github|\n\nLicense\n-------\nThe Rule Engine library is released under the BSD 3-Clause license. It is able to be used for both commercial and\nprivate purposes. For more information, see the `LICENSE`_ file.\n\n.. |badge-build| image:: https://img.shields.io/github/actions/workflow/status/zeroSteiner/rule-engine/ci.yml?branch=master\u0026style=flat-square\n   :alt: GitHub Workflow Status (branch)\n   :target: https://github.com/zeroSteiner/rule-engine/actions/workflows/ci.yml\n\n.. |badge-pypi| image:: https://img.shields.io/pypi/v/rule-engine?style=flat-square\n   :alt: PyPI\n   :target: https://pypi.org/project/rule-engine/\n\n.. |social-github| image:: https://img.shields.io/github/followers/zeroSteiner?style=social\n   :alt: GitHub followers\n   :target: https://github.com/zeroSteiner\n\n.. |social-twitter| image:: https://img.shields.io/twitter/follow/zeroSteiner\n   :alt: Twitter Follow\n   :target: https://twitter.com/zeroSteiner\n\n.. _Change Log: https://zerosteiner.github.io/rule-engine/change_log.html\n.. _Debug REPL: https://zerosteiner.github.io/rule-engine/debug_repl.html\n.. _Getting Started: https://zerosteiner.github.io/rule-engine/getting_started.html\n.. _LICENSE: https://github.com/zeroSteiner/rule-engine/blob/master/LICENSE\n.. _Semantic Versioning: https://semver.org/\n.. _Type Hinting: https://zerosteiner.github.io/rule-engine/getting_started.html#type-hinting\n","funding_links":["https://ko-fi.com/zerosteiner"],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FzeroSteiner%2Frule-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FzeroSteiner%2Frule-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FzeroSteiner%2Frule-engine/lists"}