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.0.0.tar.gz
(5.0 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-1.0.0.tar.gz.
File metadata
- Download URL: tag-expressions-1.0.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0622e40d625fb738324b2591d11c86588d448d0f34e43c73e545cc89d219301d
|
|
| MD5 |
49ca46144f12aeb9c337d0e16ca0c0ee
|
|
| BLAKE2b-256 |
1000ba91152c22e3548ae3dd188120f858dd569c16eebb2da105a46b8246a218
|
File details
Details for the file tag_expressions-1.0.0-py3-none-any.whl.
File metadata
- Download URL: tag_expressions-1.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 |
8e4b289b97d476e19420a2348437544d62a4e5bd2e9f5cf6ee4c16427026a5c6
|
|
| MD5 |
7a3d5122bf561644c1a9c1b7e232bc39
|
|
| BLAKE2b-256 |
1d4267fbfaca4fc6cd3e7c10f5c9c6c3492ecf5073851a3c861a8c495134f874
|