No project description provided
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
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
tag-expressions-1.1.0.tar.gz
(5.2 kB
view details)
Built Distribution
File details
Details for the file tag-expressions-1.1.0.tar.gz
.
File metadata
- Download URL: tag-expressions-1.1.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c0a49c3c0357976822b03c43db8d4a1c5548e16fb07ac939c10bbd5183f529d |
|
MD5 | 2f4fe9635eba94ce24bd1f0b203d31cf |
|
BLAKE2b-256 | 9602e3056e924b4ce7af16cd02cfe9e65e550e125062fb1eb4cbdbd7130606d7 |
Provenance
File details
Details for the file tag_expressions-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: tag_expressions-1.1.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45d2b616495b56778ec54ab5581b9196f4c08eb8dafa3dc54b25e26ba6a37e51 |
|
MD5 | 3208bcb478a232d6692ee481dbb287e2 |
|
BLAKE2b-256 | 809cd7f83ffcb34a267b03a742e25239d05fdf151cb749035a107ceec2432398 |