Skip to main content

Unreal Engine expression evaluator written in Python

Project description

epic-expreval

Epic expression evaluator

Test Release

Usage

Basic usage is quite simple. At the moment the library provides following functions that can be used in expressions

  • Regex
  • RegexGroupInt64
  • RegexGroupString
  • RandomAccessMemoryGB
from epic_expreval import Tokenizer, EvaluationContext

# Initialize tokenizer with expression and context
ctx = EvaluationContext()
tk = Tokenizer("<expression here>", ctx)
# Parse the expression, call this after you are done setting the Tokenizer up
tk.compile()

# Run the expression against the input
tk.execute("<input here>")

Adding more functions

At least in Selective Downloads manifests, Epic uses more functions that are related to DirectX, UI state or even game ownership. For obvious reasons those functions can't be implemented by this library out of the box.

However extending available functions is also really simple

from epic_expreval import Tokenizer, EvaluationContext

def my_function(context: EvaluationContext, param: str):
    # Do your stuff here, you are also free to extend EvaluationContext to add your own fields
    return True 

new_functions = {
    "MyFunction": my_function
}

# Initialize tokenizer with expression and context
ctx = EvaluationContext()
tk = Tokenizer("MyFunction()", ctx)
# This will call an update on dict
# So this can also be used to overwrite functions provided by this library
tk.extend_functions(new_functions)
# You can also completely nuke built-in functions
# tk.overwrite_functions(new_functions)

# Parse the expression
tk.compile()
# Parse and run the expression against the input
tk.execute("<input here>")

Remarks

At the moment the library doesn't handle short-circuting in AND (&&) statements

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

epic_expreval-0.2.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

epic_expreval-0.2.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file epic_expreval-0.2.0.tar.gz.

File metadata

  • Download URL: epic_expreval-0.2.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.26.1 CPython/3.9.23 Linux/6.11.0-1018-azure

File hashes

Hashes for epic_expreval-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a3795b225a2e389380593bd8dd076f371e2351f68ed09120934058f24729f8e1
MD5 e28e3a122a9e45b0f8af9d6beba33953
BLAKE2b-256 61212bf2db82ce6d617896265dcaa16b769301586e739d5b30e8267a35b89649

See more details on using hashes here.

File details

Details for the file epic_expreval-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: epic_expreval-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.26.1 CPython/3.9.23 Linux/6.11.0-1018-azure

File hashes

Hashes for epic_expreval-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2abea11662ecb8e01cb01a4cc29acf4e4b3004b47e6fb007654e6770f8293b0f
MD5 cd8b58b76e80b32651ba9ba69c971c71
BLAKE2b-256 28eb36edfe0ab7237f8df2043a9647ebaa7a104cb6d3859d1d7b98a3c838e552

See more details on using hashes here.

Supported by

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