Skip to main content

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

Metadata

Release files for epic-expreval 0.2.0

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

Source distribution (sdist)

Source distribution for epic-expreval 0.2.0
File Size Uploaded
epic_expreval-0.2.0.tar.gz 6.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for epic-expreval 0.2.0
File Interpreter ABI Platform
epic_expreval-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.6 kB

Release files / epic_expreval-0.2.0.tar.gz

Download URL epic_expreval-0.2.0.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a3795b225a2e389380593bd8dd076f371e2351f68ed09120934058f24729f8e1
BLAKE2b-256 checksum
How to use checksums
61212bf2db82ce6d617896265dcaa16b769301586e739d5b30e8267a35b89649
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.26.1 CPython/3.9.23 Linux/6.11.0-1018-azure

Release files / epic_expreval-0.2.0-py3-none-any.whl

Download URL epic_expreval-0.2.0-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2abea11662ecb8e01cb01a4cc29acf4e4b3004b47e6fb007654e6770f8293b0f
BLAKE2b-256 checksum
How to use checksums
28eb36edfe0ab7237f8df2043a9647ebaa7a104cb6d3859d1d7b98a3c838e552
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.26.1 CPython/3.9.23 Linux/6.11.0-1018-azure

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

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