Metadata-Version: 2.1
Name: logics-py
Version: 0.0.9
Summary: Logics is a user-friendly formula language with a subset of Python''s expression syntax
Home-page: https://github.com/viur-framework/logics
Author: Jan Max Meyer
Author-email: jmm@phorward.de
License: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Interpreters
Requires-Python: >=3.10
Description-Content-Type: text/markdown

<!-- README for PyPI -->

<div align="center">
    <img src="https://github.com/viur-framework/viur-artwork/raw/main/icons/icon-logics.svg" height="196" alt="A hexagonal logo of Logics" title="Logics logo">
    <h1>Logics</h1>
    <a href="https://pypi.org/project/logics-py">
        <img alt="Badge showing current PyPI version if logics-py" title="logics-py" src="https://img.shields.io/pypi/v/logics-py?label=logics-py">
    </a>
    <a href="https://www.npmjs.com/package/logics-js">
        <img alt="Badge showing current npm version if logics-js" title="logics-js" src="https://img.shields.io/npm/v/logics-js?label=logics-js">
    </a>
    <a href="https://github.com/viur-framework/logics/LICENSE">
        <img src="https://img.shields.io/github/license/viur-framework/logics" alt="Badge displaying the license" title="License badge">
    </a>
    <br>
    A tiny, sandboxed, secure and extendable formula language with a flavor of Python.
</div>

## About

Logics is a simple expression language with the goal to provide equal syntax and semantics for different runtime contexts and host languages.

- [logics-js](https://www.npmjs.com/package/logics-js) is a pure JavaScript implementation of Logics provided as npm-package.
- [logics-py](https://pypi.org/project/logics-py/) is a pure Python implementation of Logics provided as PyPI-package.

Both packages are under recent development and not stable right now. They are maintained in separate version numbers.

## Features

- Secure, native, running in a sandboxed environment apart from the host language
  - Disallows variable assignment, except in comprehensions
  - *logics-js*: Implementation in JavaScript
  - *logics-py*: Implementation in Python
- Python-inspired syntax and semantics
  - Make use of all standard operators
    - Unary `+`, `-`, `~`, `not`
    - Binary `+`, `*`, `-`, `/`, `//`, `**`
    - Comparison `==`, `!=`, `<>`, `<`, `<=`, `>`, `>=`, `in`, `not in`
    - Logical `and`, `or`
    - Conditions `y if x else z`
    - Comprehensions `[x for x in y if z]`
  - Slices `x[:]`
  - Attribute access `x[y]`
  - `# comments` in separate lines
  - Dedicated Value object abstraction of native types for
    - `True`, `False`, `None`
    - `int`, `float`, `str`
    - `list` for arrays
    - `dict` for structured objects
- Provides a set of functions that can be used in expressions
- Extendable to custom functions
