A complete gutting of the internals of ytdl-sub to support functions in our variable syntax, in addition to being able to access a yt-dlp entry's .info.json fields using functions. Functionally, ytdl-sub should still look and behave the same from a user-perspective. With so many lines of code changed (+8927, -2708), no doubt there will be new issues. Please make a GH issue or reach out on Discord if your config/subscriptions break in any way/shape/form. Details on how to use function support will come soon in the form of proper documentation in our readthedocs.
23 lines
883 B
Python
23 lines
883 B
Python
from ytdl_sub.script.types.resolvable import AnyArgument
|
|
from ytdl_sub.script.types.resolvable import ReturnableArgument
|
|
from ytdl_sub.script.types.resolvable import String
|
|
from ytdl_sub.script.utils.exceptions import UserThrownRuntimeError
|
|
|
|
|
|
class ErrorFunctions:
|
|
@staticmethod
|
|
def throw(error_message: String) -> AnyArgument:
|
|
"""
|
|
Explicitly throw an error with the provided error message.
|
|
"""
|
|
raise UserThrownRuntimeError(error_message)
|
|
|
|
@staticmethod
|
|
def assert_(value: ReturnableArgument, assert_message: String) -> ReturnableArgument:
|
|
"""
|
|
Explicitly throw an error with the provided assert message if ``value`` evaluates to False.
|
|
If it evaluates to True, it will return ``value``.
|
|
"""
|
|
if not bool(value.value):
|
|
raise UserThrownRuntimeError(assert_message)
|
|
return value
|