tag-expressions
Package to evaluate logical tag expressions by using a modified version of the Shunting Yard algorithm. This package is a Python port of cucumbers tag expression.
It’s also used by radish.
Installing
$ pip install tag-expressions
Here is a tease
>>> 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
Metadata
Release files for tag-expressions 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| tag_expressions-2.0.1.tar.gz | 6.1 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tag_expressions-2.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.6 kB
Release files / tag_expressions-2.0.1.tar.gz
| Download URL | tag_expressions-2.0.1.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
11b4b07c01feb0bdc9196f8239f0c0d9fedc2c6c8a99032c6f2c831b2d772e48
|
|
BLAKE2b-256 checksum How to use checksums |
74ef4a21b9ea08301762a18a1f5b0c84909c7a6dacf75c4eb359915d46348e73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2024.
Transparency logRelease files / tag_expressions-2.0.1-py3-none-any.whl
| Download URL | tag_expressions-2.0.1-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2b7e544a5b7ed963082e2cd0f0fabca7e914638b679d0c04da125094e7cfa26d
|
|
BLAKE2b-256 checksum How to use checksums |
8bae5d7ca47dcb8e043110da47b2ff8615b77f2c52bc1502c2c8c1ab713e1096
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2024.
Transparency logSecurity for tag-expressions 2.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for tag_expressions-2.0.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2024.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.