Built-in functions, types, exceptions, and other objects.
Project description
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tag_expressions-2.0.1.tar.gz
.
File metadata
- Download URL: tag_expressions-2.0.1.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11b4b07c01feb0bdc9196f8239f0c0d9fedc2c6c8a99032c6f2c831b2d772e48 |
|
MD5 | fbc2b2a956711ab9b085eaa0b2965add |
|
BLAKE2b-256 | 74ef4a21b9ea08301762a18a1f5b0c84909c7a6dacf75c4eb359915d46348e73 |
Provenance
The following attestation bundles were made for tag_expressions-2.0.1.tar.gz
:
Publisher:
deploy.yml
on timofurrer/tag-expressions
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
tag_expressions-2.0.1.tar.gz
- Subject digest:
11b4b07c01feb0bdc9196f8239f0c0d9fedc2c6c8a99032c6f2c831b2d772e48
- Sigstore transparency entry: 151032113
- Sigstore integration time:
- Predicate type:
File details
Details for the file tag_expressions-2.0.1-py3-none-any.whl
.
File metadata
- Download URL: tag_expressions-2.0.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b7e544a5b7ed963082e2cd0f0fabca7e914638b679d0c04da125094e7cfa26d |
|
MD5 | a029c6d90ae2f786e4656cb30ee33ed3 |
|
BLAKE2b-256 | 8bae5d7ca47dcb8e043110da47b2ff8615b77f2c52bc1502c2c8c1ab713e1096 |
Provenance
The following attestation bundles were made for tag_expressions-2.0.1-py3-none-any.whl
:
Publisher:
deploy.yml
on timofurrer/tag-expressions
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
tag_expressions-2.0.1-py3-none-any.whl
- Subject digest:
2b7e544a5b7ed963082e2cd0f0fabca7e914638b679d0c04da125094e7cfa26d
- Sigstore transparency entry: 151032114
- Sigstore integration time:
- Predicate type: