# aml Accounting Mini Language — Small and simple expression language running on Python.
aml is a very small programming language running on top of Python. aml is ideal for exposing a powerful but safe interface to users who need to define business rules but have no programming knowledge. In this respect aml is an alternative to cumbersome mouse-driven rule engine configurations.
The grammar and parser utilise the [pypeg2](http://fdik.org/pyPEG/) library which must be installed for aml to work.
To use aml the programmer creates a “language instace”. Calling the compile function yields an object (essentially an AST). This object can then be evaluated directly using the evaluate function or translated to Python or SQL using the respective functions.
Since the language is very simple, sufficient documentation can be given by example:
>>> lang_instance = create_lang_instance()
>>> lang_instance.aml_evaluate(lang_instance.aml_compile('1 = 1'))
True
>>> li = create_lang_instance()
>>> c = li.aml_compile
>>> e = li.aml_evaluate
>>> p = li.aml_translate_python
>>> s = li.aml_translate_sql
>>> u = li.aml_suggest
>>> e(c('1 = 0'))
False
>>> e(c('"1" = "1"'))
True
>>> e(c('(1=1)'))
True
>>> e(c('1 > 1'))
False
>>> e(c('not 1 > 1'))
True
>>> e(c('1 != 1'))
False
>>> e(c('-2 = -2'))
True
>>> eval(p(c('-2 = -2')))
True
>>> eval(p(c('null = null')))
True
>>> eval(p(c('1 = null')))
False
>>> e(c('"foo" = "foo"'))
True
>>> e(c('"foo" = \\'foo\\''))
True
>>> e(c('"fo\\'o" = "fo\\'o"'))
True
>>> e(c("'foo'" + '=' + '"foo"'))
True
>>> li = create_lang_instance({'foo' : 1});
>>> c = li.aml_compile
>>> e = li.aml_evaluate
>>> e(c('foo = 1'))
True
>>> li = create_lang_instance({'foo' : 1.00})
>>> c = li.aml_compile
>>> e = li.aml_evaluate
>>> e(c('foo = 1'))
True
>>> li = create_lang_instance({'foo' : 2.24})
>>> c = li.aml_compile
>>> e = li.aml_evaluate
>>> e(c('foo = 2.24'))
True
>>> li = create_lang_instance({'foo' : 'foo'})
>>> c = li.aml_compile
>>> e = li.aml_evaluate
>>> e(c('foo = "foo"'))
True
>>> li = create_lang_instance()
>>> c = li.aml_compile
>>> p = li.aml_translate_python
>>> s = li.aml_translate_sql
>>> s(c('null = null'))
u'null is null'
>>> p(c('null = null'))
u'None == None'
>>> s(c('null != null'))
u'null is not null'
>>> p(c('null != null'))
u'None != None'
>>> s(c('5 != 3'))
u'5 <> 3'
>>> p(c('5 != 3'))
u'5 != 3'
>>> li = create_lang_instance({'foo' : 'bar', 'fo2' : 'ba2'})
>>> c = li.aml_compile
>>> p = li.aml_translate_python
>>> e = li.aml_evaluate
>>> u = li.aml_suggest
>>> u('1 = fo')
[u'fo2', u'foo']
>>> u('1 = FO')
[u'fo2', u'foo']
>>> p(c('null = null'))
u'None == None'
>>> e(c('foo = "bar"'))
True
>>> e(c('fo2 = "ba2"'))
True
Metadata
Release files for amlang 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distributions (sdists)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| amlang-1.0.0.zip | 6.4 kB | Without provenance | Details for amlang-1.0.0.zip | |
| amlang-1.0.0.tar.gz | 4.9 kB | Without provenance | Details for amlang-1.0.0.tar.gz |
Release files / amlang-1.0.0.zip
| Download URL | amlang-1.0.0.zip |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f97a298c09de398af8a1a9af58642a05c96ec691826b0ea95743de3a5fcf4ddb
|
|
BLAKE2b-256 checksum How to use checksums |
34a21ea219e8b11d45477cdf16c75de826417125c0f548b506f083afc9bd5078
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / amlang-1.0.0.tar.gz
| Download URL | amlang-1.0.0.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ff2068028ea16e7ff98f64dd5554a533e3fd1f7815b116c3b0558f24e3a65e10
|
|
BLAKE2b-256 checksum How to use checksums |
9f881604cfe5b094274dd1840f28ff1e28576b29ea2f98d620ce577cc0b38268
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for amlang 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.