safe embedded python expression parser
Project description
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
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
embexpr-1.1.1.tar.gz
(4.5 kB
view details)
Built Distribution
File details
Details for the file embexpr-1.1.1.tar.gz
.
File metadata
- Download URL: embexpr-1.1.1.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbe1cc1cdd95cbc49418b628d94d2ae8d4304177b5bb2bf72d2ed749703c98a2 |
|
MD5 | 164731425abfe36adfd5cec76823c265 |
|
BLAKE2b-256 | ad39a54e3511ff35af28d2ebe3f354aefeb29d2799dee2788dd294e2620d3b19 |
File details
Details for the file embexpr-1.1.1-py2.py3-none-any.whl
.
File metadata
- Download URL: embexpr-1.1.1-py2.py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 2, Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9acdd3e865c0aea735dc22d93d1c52adfce88e5fbca47eebf46f45fa5cccebbe |
|
MD5 | 2512ce158b42f718d93f298acc33f7ff |
|
BLAKE2b-256 | 02fc32aebe99fa852d4ca1bb9150ccef0d79e81578aebd734dee43c2629afe9f |