embexpr
safe embedded python expression parser (for mainly easy DSL or config file).
Getting Started
pip install embexpr
How to Use
from embexpr import Expr, ParseError
assert Expr('3 * 5')() == 15
assert Expr('"foo" + "bar"')() == "foobar"
assert Expr('len("example")')() == 7
assert Expr('s.startswith("prefix_")')(s="prefix_suffix") == True
try:
Expr('eval("1")')()
except ParseError as e:
print(e)
Reference
https://github.com/ansible/ansible/blob/devel/lib/ansible/template/safe_eval.py http://stackoverflow.com/questions/12523516/using-ast-and-whitelists-to-make-pythons-eval-safe
License
MIT
Metadata
Release files for embexpr 1.1.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 | |
|---|---|---|---|
| embexpr-1.1.1.tar.gz | 4.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| embexpr-1.1.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 9.0 kB
Release files / embexpr-1.1.1.tar.gz
| Download URL | embexpr-1.1.1.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cbe1cc1cdd95cbc49418b628d94d2ae8d4304177b5bb2bf72d2ed749703c98a2
|
|
BLAKE2b-256 checksum How to use checksums |
ad39a54e3511ff35af28d2ebe3f354aefeb29d2799dee2788dd294e2620d3b19
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.9.0
|
Release files / embexpr-1.1.1-py2.py3-none-any.whl
| Download URL | embexpr-1.1.1-py2.py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
9acdd3e865c0aea735dc22d93d1c52adfce88e5fbca47eebf46f45fa5cccebbe
|
|
BLAKE2b-256 checksum How to use checksums |
02fc32aebe99fa852d4ca1bb9150ccef0d79e81578aebd734dee43c2629afe9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.9.0
|