Skip to main content

lla

Interpreter for a basic logic language, inspired by two-element boolean algebra.

Demo

Here's a quick demo, based on the example that prompted its creation:

>>> from lla.interpreter import Interpreter
>>> variables = {
...     'ssh': True,
...     'website_up': True,
...     'search_up': False,
...     'elasticsearch.http': False,
...     'elasticsearch.process': True,
... }
>>> interpreter = Interpreter(variables)
>>> interpreter.run('ssh & website_up')
True
>>> interpreter.run('ssh & website_up & search_up')
False
>>> interpreter.run('!search_up & !elasticsearch.http & elasticsearch.process')
True
>>> interpreter.run('undefined_variable')
Traceback (most recent call last):
    ...
lla.interpreter.UndefinedVariableException: Undefined variable: undefined_variable

By replacing the variables dict with a class implementing __getitem__, it becomes incredibly flexible.

Overview

Here's the gist of it:

  1. All variables are booleans.
  2. You can't define variables in the language itself, but it be provided a dict or any object implementing __getitem__.
  3. Only fully-resolvable statements are supported. a. Anything else raises a Python exception.
  4. You provide the interpreter a single statement and it gets simplified to a single boolean value, which is then returned.

Dependencies

In theory, all you need is Python 3.6+.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/duckinator/lla.

The code for lla is available under the MIT License.

Metadata

Release files for lla 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lla 0.0.6
File Size Uploaded Provenance
lla-0.0.6.tar.gz 5.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for lla 0.0.6
File Interpreter ABI Platform
lla-0.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 11.4 kB

Release files / lla-0.0.6.tar.gz

Download URL lla-0.0.6.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
26ed85cb54a91e14c1c80ff72cf2f6378b09d9ccf4c3f125ebcffb862d53d886
BLAKE2b-256 checksum
How to use checksums
bd0bd47047cf9c1a84fbb289dd3055a9f889fb5ff7f4318c3094414d5a63e170
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/49.3.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Release files / lla-0.0.6-py3-none-any.whl

Download URL lla-0.0.6-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8f649fd46b934debc6b10cb798d73df40fdd8f1447fdaf362ffe987a1f032aa7
BLAKE2b-256 checksum
How to use checksums
9980858e5a4db380774f4472f591aba0c53b39b6ee721ea4d7134530278e7964
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/49.3.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Security for lla 0.0.6

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page