Utils

bTagScript.utils.escape_content(string: str) str[source]

Escapes given input to avoid tampering with engine/block behavior.

Parameters

string (str) – The string to escape.

Returns

The escaped content.

Return type

str

async bTagScript.utils.maybe_await(func: Union[Callable[[...], Any], Awaitable[Any]], *args, **kwargs) Any[source]

Await the given function if it is awaitable or call it synchronously.

Parameters
  • func (Union[Callable[..., Any], Awaitable[Any]]) – The function callable to call.

  • *args (Any) – The arguments to pass to the function.

  • **kwargs (Any) – The keyword arguments to pass to the function.

Returns

The result of the awaitable function.

Return type

Any