Skip to main content

Scriptable is a sand-boxed scripting engine which can be used safely in an embedded environment.

Its canonical abstract syntax tree model is designed to support various syntax forms. At the moment the typescript syntax as well as the hypothesis syntax (a typescript syntax subset used for logical reasoning) and the mustache syntax are supported.

The scripting engine forbids endless loops and has a recursion guard, which detects loops in a function call stack. In addition to that scriptable allows to define more detailed AST restrictions. At the moment following restrictions are supported:

  • max_precision # The max allowed number of digits in a number.
  • max_scale # The max allowed digits to the right of the decimal point in a number.
  • max_loops # The max allowed number of loop iterations.

Usage

TypescriptEngine

engine = TypescriptEngine.parse("""
   function fibonacci(n:number) {
      if (n == 0) return 0
      if (n == 1) return 1
      if (n == 2) return 1
      return fibonacci(n - 1) + fibonacci(n - 2)
   }
   
   fibonacci(8) // returns 21
""")
    
engine.execute()

HypothesisEngine

engine = HypothesisEngine.parse("x > 0")
engine.execute({"x": 1}) // returns True

MustacheEngine

engine = MustacheEngine.parse("text {{x}} text")
engine.execute({"x": 1}) // returns "text 1 text"

Metadata

Release files for scriptable 0.1.8

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

Source distribution (sdist)

Source distribution for scriptable 0.1.8
File Size Uploaded Provenance
scriptable-0.1.8.tar.gz 99.2 kB Without provenance Details

Release files / scriptable-0.1.8.tar.gz

Download URL scriptable-0.1.8.tar.gz
Size 99.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6a4657d98b2e87a868103521160475aad78cdbcbdc49ace220c92c8e1a7eed08
BLAKE2b-256 checksum
How to use checksums
48572fa5d92041c31f5bdb240ab157eac4e649b0a96a39cd5ad517edae1df92b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.42.1 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.3 CPython/3.7.3

Security for scriptable 0.1.8

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.

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