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.1.0.tar.gz (6.0 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.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: epic_expreval-0.1.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.24.1 CPython/3.9.22 Linux/6.11.0-1012-azure

File hashes

Hashes for epic_expreval-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4ec296dd33404167f8aa18d0bafe2f639cf6ff214193275b26fc7bcb6589935d
MD5 960d6521a8effe67020747f6b13bb2f7
BLAKE2b-256 2d18e0bcf2f66fdd60b4b71b41129ac41505049ec4d01e61c9b47c15db746266

See more details on using hashes here.

File details

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

File metadata

  • Download URL: epic_expreval-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.24.1 CPython/3.9.22 Linux/6.11.0-1012-azure

File hashes

Hashes for epic_expreval-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4a888129ce5a2c989f13c44141ec2291bdc3c518becb553f62ab5dc44ce534f3
MD5 ed079f2ea82220cf44d79d87c7578800
BLAKE2b-256 83b56fd8e37aa0fc701d7eeb23b8c51eaa864037488da4627b92aca10ca7c52c

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