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-0.0.0.tar.gz
(4.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tag-expressions-0.0.0.tar.gz.
File metadata
- Download URL: tag-expressions-0.0.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1bac34ed90ee5acd3749ea8c45a08dc8d7d0465a1937726599f2a3f6a12bc68f
|
|
| MD5 |
e0c80c426ba38c06292e0423488a180b
|
|
| BLAKE2b-256 |
62fba0fc0da6fcc25c3ffdd7d741ae8da63df5765745776386fe83a2e607584e
|
File details
Details for the file tag_expressions-0.0.0-py3-none-any.whl.
File metadata
- Download URL: tag_expressions-0.0.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ddc263e3408dfaf1f3a8d4f3e4ebffb64c8cfb78c346c9411cbe65c89db31f70
|
|
| MD5 |
85542dbfc5b13efd111a9f50cbf3845f
|
|
| BLAKE2b-256 |
cb7b448524c5b578d1a0fb5d061e03bf62974c7defe3ebf2d160d725a5c906d6
|