{ "info": { "author": "Harry Lee", "author_email": "tclh123@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# Rule\n\nA rule engine written in python.\n\nThe rule is a json/yaml string or python object of a list expression.\nThe expression is like `[op, arg0, arg1, ..., argn]`, the `op` is the operator,\nand `arg0..n` is the arguments for the operator. Any argument can be another expression.\n\nFor writing convenience, the first argument will be tried to resolve as the context parameter.\nOr, you can just use the special `var` operator to indicate the context parameter.\n\n## Usage\n\n```\n>>> from rule import Rule\n>>>\n>>> context = dict(a=1, world='hello')\n>>> Rule(['=', ['var', 'a'], 1]).match(context)\nTrue\n>>> Rule(\"['=', ['var', 'a'], 1]\").match(context)\nTrue\n>>> Rule(['=', 'a', 1]).match(context)\nTrue\n>>> Rule(['=', 'hello', 'hello']).match(context)\nTrue\n>>> Rule(['=', 'world', 'hello']).match(context)\nTrue\n>>> Rule(['<', 'a', 10]).match(context)\nTrue\n>>> Rule(['=', ['>', 'a', 10], False]).match(context)\nTrue\n>>>\n>>> context = dict(ldap_id='Harry', hosts='sa,sb,sc', reason='hehe', nologin=False,\n... group='wheel,sysadmin,platform', package='dev-python/sa-tools',\n... branch='release', cc='Tony,Mike',)\n>>> Rule(['contains', 'hosts', 'sa,']).match(context)\nTrue\n>>> Rule(['contains', ['split', 'hosts', ','], 'sa']).match(context)\nTrue\n>>> Rule(['in', 'branch', 'master', 'release']).match(context)\nTrue\n>>> Rule(['=', 'ldap_id', 'Harry']).match(context)\nTrue\n>>> Rule(['match', 'package', 'dev-python/*']).match(context)\nTrue\n>>> Rule(['regex', 'package', 'dev-python/.*']).match(context)\nTrue\n>>> Rule(['is', 'nologin', False]).match(context)\nTrue\n```\n\n\nSee [rule/op.py](rule/op.py) for more supported operators.\n\n## License\n\nhttp://tclh123.mit-license.org/\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/tclh123/rule", "keywords": "rule", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "rule", "package_url": "https://pypi.org/project/rule/", "platform": "", "project_url": "https://pypi.org/project/rule/", "project_urls": { "Homepage": "https://github.com/tclh123/rule" }, "release_url": "https://pypi.org/project/rule/0.1.1/", "requires_dist": [ "setuptools", "six", "pyyaml" ], "requires_python": "", "summary": "A rule engine written in python.", "version": "0.1.1" }, "last_serial": 5400464, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "9c8c66e1f96a0aeefbf9d3e59e23815a", "sha256": "9c6aa761afa44225871e954aba6f43efdba2e1c46b6c6fb3ab6fcf325f78a61f" }, "downloads": -1, "filename": "rule-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "9c8c66e1f96a0aeefbf9d3e59e23815a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5058, "upload_time": "2019-06-14T12:36:29", "url": "https://files.pythonhosted.org/packages/40/68/288b0947525752e0742c049d5febda289caf6446b6f983c1f46a4e135328/rule-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3903781e63d42fd38dbc27023809f80d", "sha256": "b4cae6eed59ffae9e6e5b82053a23b3335a9edf9a1bf9fd7394e5b8ff6294c75" }, "downloads": -1, "filename": "rule-0.1.0.tar.gz", "has_sig": false, "md5_digest": "3903781e63d42fd38dbc27023809f80d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3621, "upload_time": "2019-06-14T12:36:32", "url": "https://files.pythonhosted.org/packages/50/25/da9c1c4e2c3c7295572b9764f8b5123ed2ba7b58d00e745c49db34a7f03a/rule-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "1c0f4e7d1bc2d5ec7ec5c535229d21ca", "sha256": "34e5acbde1ff501d883e6f8ad28b077b9b5ff6f4de7f417f02415f5652fcf5ab" }, "downloads": -1, "filename": "rule-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "1c0f4e7d1bc2d5ec7ec5c535229d21ca", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5237, "upload_time": "2019-06-14T12:54:24", "url": "https://files.pythonhosted.org/packages/57/bc/af60966bf257be796c455b108e88ecf8abb16dda1cb6f6a9cbe06482ccd1/rule-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b97e9e27ad351cff712a520a9fb9da08", "sha256": "dde458f4229b71c5de0c97780f244cfc8d101ac17ac10d2345f3364b091cf961" }, "downloads": -1, "filename": "rule-0.1.1.tar.gz", "has_sig": false, "md5_digest": "b97e9e27ad351cff712a520a9fb9da08", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3854, "upload_time": "2019-06-14T12:54:25", "url": "https://files.pythonhosted.org/packages/df/33/d4d2304f60d8daa63e5952d1739e75b30f89fecda1d82d110e8e9e321293/rule-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1c0f4e7d1bc2d5ec7ec5c535229d21ca", "sha256": "34e5acbde1ff501d883e6f8ad28b077b9b5ff6f4de7f417f02415f5652fcf5ab" }, "downloads": -1, "filename": "rule-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "1c0f4e7d1bc2d5ec7ec5c535229d21ca", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5237, "upload_time": "2019-06-14T12:54:24", "url": "https://files.pythonhosted.org/packages/57/bc/af60966bf257be796c455b108e88ecf8abb16dda1cb6f6a9cbe06482ccd1/rule-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b97e9e27ad351cff712a520a9fb9da08", "sha256": "dde458f4229b71c5de0c97780f244cfc8d101ac17ac10d2345f3364b091cf961" }, "downloads": -1, "filename": "rule-0.1.1.tar.gz", "has_sig": false, "md5_digest": "b97e9e27ad351cff712a520a9fb9da08", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3854, "upload_time": "2019-06-14T12:54:25", "url": "https://files.pythonhosted.org/packages/df/33/d4d2304f60d8daa63e5952d1739e75b30f89fecda1d82d110e8e9e321293/rule-0.1.1.tar.gz" } ] }