Skip to main content

A simple script language for event-based automation tasks.

Project description

EveScript is a simple script language for event-based automation tasks.

from evescript.compiler import EveScriptCompiler
from evescript.executor import EveScriptExecutor

script = '''
if ($lightSensor > 20) {
  say("It's daytime now!")
}
'''

def lightSensor():
    return read_light_sensor_port()

compiler = EveScriptCompiler()
compiled_script = compiler.compile(script)

executor = EveScriptExecutor({
    'actions': { 'say': lambda x: print(x) },
    'variables': { '$lightSensor': lightSensor },
})

executor.run_script(compiled_script)
# Out: It's daytime now!

EveScript allows you to write simple event-based scripts that evaluate various conditions and execute actions. The conditions and actions are highly customizable to maximize the flexibility. EveScript can be used in embedded systems (such as Raspberry Pi) to implement a flexible event-based system.

Installation

pip install evescript

Changelog

0.5.0 (2021-03-29)

  • Support if…else statement.

  • Support executing actions outside if statement.

  • Support nested if statement.

  • Support actions with no params.

0.4.0 (2021-03-27)

  • Added support for using true/false as conditions.

0.3.0 (2021-03-20)

  • Fixed typo (EveScriptExector => EveScriptExecutor)

0.2.1 (2021-03-20)

  • Added decompiler.

  • Compiler will not rename built-in operators.

0.1.1 (2021-03-19)

  • First release on PyPI.

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

evescript-0.5.0.tar.gz (63.7 kB view hashes)

Uploaded Source

Built Distribution

evescript-0.5.0-py2.py3-none-any.whl (21.0 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page