tag-expressions


Nametag-expressions JSON
Version 2.0.0 PyPI version JSON
download
home_pagehttp://github.com/timofurrer/tag-expressions
SummaryBuilt-in functions, types, exceptions, and other objects.
upload_time2023-10-02 14:23:34
maintainer
docs_urlNone
authorTimo Furrer
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            tag-expressions
===============

Package to evaluate logical tag expressions by using a modified version of the `Shunting Yard algorithm <https://en.wikipedia.org/wiki/Shunting-yard_algorithm>`_.
This package is a Python port of cucumbers tag expression.

It's also used by `radish <https://github.com/radish-bdd/radish>`_.

|Build Status| |PyPI package version| |PyPI python versions|


Installing
----------

.. code:: bash

    $ pip install tag-expressions

Here is a tease
---------------


.. code:: python

    >>> from tagexpressions import parse
    >>>
    >>> expression = '( a and b ) or ( c and d )'
    >>> compiled_expression = parse(expression)
    >>> print(compiled_expression)
    ( ( a and b ) or ( c and d ) )
    >>>
    >>> data = ['a', 'b', 'c', 'd']
    >>> assert compiled_expression.evaluate(data) == True
    >>>
    >>> data = ['a', 'c']
    >>> assert compiled_expression.evaluate(data) == False
    >>>
    >>>
    >>> expression = 'not a or b and not c or not d or e and f'
    >>> compiled_expression = parse(expression)
    >>> print(compiled_expression)
    ( ( ( not ( a ) or ( b and not ( c ) ) ) or not ( d ) ) or ( e and f ) )
    >>>
    >>> data = ['b', 'e', 'f']
    >>> assert compiled_expression.evaluate(data) == True
    >>>
    >>> data = ['a', 'c', 'd']
    >>> assert compiled_expression.evaluate(data) == False


Usage
-----

Available operators
~~~~~~~~~~~~~~~~~~~

* **or** - "or" conjunction of two given variables
* **and** - "and" conjunction of two given variables
* **not** - negation of a single variable

Every other token given in an *infix* is considered a variable.

Operator precedence
~~~~~~~~~~~~~~~~~~~

From high to low:

* ()
* or
* and
* not

.. |Build Status| image:: https://travis-ci.org/timofurrer/tag-expressions.png?branch=master
   :target: https://travis-ci.org/timofurrer/tag-expressions
.. |PyPI package version| image:: https://badge.fury.io/py/tag-expressions.svg
   :target: https://badge.fury.io/py/tag-expressions
.. |PyPI python versions| image:: https://img.shields.io/pypi/pyversions/tag-expressions.svg
   :target: https://pypi.python.org/pypi/tag-expressions

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/timofurrer/tag-expressions",
    "name": "tag-expressions",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Timo Furrer",
    "author_email": "tuxtimo@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e4/20/8395065c523ce9f6030d93c1c7f564e684b2c3d0098cb34ee49160ee9332/tag-expressions-2.0.0.tar.gz",
    "platform": null,
    "description": "tag-expressions\n===============\n\nPackage to evaluate logical tag expressions by using a modified version of the `Shunting Yard algorithm <https://en.wikipedia.org/wiki/Shunting-yard_algorithm>`_.\nThis package is a Python port of cucumbers tag expression.\n\nIt's also used by `radish <https://github.com/radish-bdd/radish>`_.\n\n|Build Status| |PyPI package version| |PyPI python versions|\n\n\nInstalling\n----------\n\n.. code:: bash\n\n    $ pip install tag-expressions\n\nHere is a tease\n---------------\n\n\n.. code:: python\n\n    >>> from tagexpressions import parse\n    >>>\n    >>> expression = '( a and b ) or ( c and d )'\n    >>> compiled_expression = parse(expression)\n    >>> print(compiled_expression)\n    ( ( a and b ) or ( c and d ) )\n    >>>\n    >>> data = ['a', 'b', 'c', 'd']\n    >>> assert compiled_expression.evaluate(data) == True\n    >>>\n    >>> data = ['a', 'c']\n    >>> assert compiled_expression.evaluate(data) == False\n    >>>\n    >>>\n    >>> expression = 'not a or b and not c or not d or e and f'\n    >>> compiled_expression = parse(expression)\n    >>> print(compiled_expression)\n    ( ( ( not ( a ) or ( b and not ( c ) ) ) or not ( d ) ) or ( e and f ) )\n    >>>\n    >>> data = ['b', 'e', 'f']\n    >>> assert compiled_expression.evaluate(data) == True\n    >>>\n    >>> data = ['a', 'c', 'd']\n    >>> assert compiled_expression.evaluate(data) == False\n\n\nUsage\n-----\n\nAvailable operators\n~~~~~~~~~~~~~~~~~~~\n\n* **or** - \"or\" conjunction of two given variables\n* **and** - \"and\" conjunction of two given variables\n* **not** - negation of a single variable\n\nEvery other token given in an *infix* is considered a variable.\n\nOperator precedence\n~~~~~~~~~~~~~~~~~~~\n\nFrom high to low:\n\n* ()\n* or\n* and\n* not\n\n.. |Build Status| image:: https://travis-ci.org/timofurrer/tag-expressions.png?branch=master\n   :target: https://travis-ci.org/timofurrer/tag-expressions\n.. |PyPI package version| image:: https://badge.fury.io/py/tag-expressions.svg\n   :target: https://badge.fury.io/py/tag-expressions\n.. |PyPI python versions| image:: https://img.shields.io/pypi/pyversions/tag-expressions.svg\n   :target: https://pypi.python.org/pypi/tag-expressions\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Built-in functions, types, exceptions, and other objects.",
    "version": "2.0.0",
    "project_urls": {
        "Homepage": "http://github.com/timofurrer/tag-expressions"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d7008900a6569172a4c177f4449725c5e149fa9140c757f760bcedfb3ff24c36",
                "md5": "35737dea11eb365e4ca581a6cd9837af",
                "sha256": "87f04c141f14ee70ec2cfa8a16409acf5e1e0e5cfed859c68533803343eb1eb9"
            },
            "downloads": -1,
            "filename": "tag_expressions-2.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "35737dea11eb365e4ca581a6cd9837af",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 5443,
            "upload_time": "2023-10-02T14:23:33",
            "upload_time_iso_8601": "2023-10-02T14:23:33.895401Z",
            "url": "https://files.pythonhosted.org/packages/d7/00/8900a6569172a4c177f4449725c5e149fa9140c757f760bcedfb3ff24c36/tag_expressions-2.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e4208395065c523ce9f6030d93c1c7f564e684b2c3d0098cb34ee49160ee9332",
                "md5": "894c2f4a267b59baf04589f99062c8bc",
                "sha256": "ffa626ef68e58157697a5e15d96d9a08a36d2120d3f72e6acfbfa04e5954b8f8"
            },
            "downloads": -1,
            "filename": "tag-expressions-2.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "894c2f4a267b59baf04589f99062c8bc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6090,
            "upload_time": "2023-10-02T14:23:34",
            "upload_time_iso_8601": "2023-10-02T14:23:34.954091Z",
            "url": "https://files.pythonhosted.org/packages/e4/20/8395065c523ce9f6030d93c1c7f564e684b2c3d0098cb34ee49160ee9332/tag-expressions-2.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-02 14:23:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "timofurrer",
    "github_project": "tag-expressions",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "tag-expressions"
}
        
Elapsed time: 0.49806s