This commit is contained in:
Jesse Bannon 2024-09-25 22:31:44 -07:00
parent ee81f84fdb
commit 59ea8bbe9f
2 changed files with 13 additions and 8 deletions

View file

@ -4,7 +4,7 @@ from typing import List
from typing import Match from typing import Match
from typing import Optional from typing import Optional
from ytdl_sub.script.functions import ArrayFunctions from ytdl_sub.script.functions.array_functions import ArrayFunctions
from ytdl_sub.script.types.array import Array from ytdl_sub.script.types.array import Array
from ytdl_sub.script.types.resolvable import Boolean from ytdl_sub.script.types.resolvable import Boolean
from ytdl_sub.script.types.resolvable import Float from ytdl_sub.script.types.resolvable import Float
@ -47,11 +47,13 @@ class RegexFunctions:
:description: :description:
Returns True if any regex pattern in the regex array matches the string. False otherwise. Returns True if any regex pattern in the regex array matches the string. False otherwise.
""" """
return Boolean(any( return Boolean(
len(RegexFunctions.regex_search(regex=String(str(regex)), string=string).value) > 0 any(
for regex in regex_array.value len(RegexFunctions.regex_search(regex=String(str(regex)), string=string).value) > 0
if isinstance(regex, (String, Integer, Boolean, Float)) for regex in regex_array.value
)) if isinstance(regex, (String, Integer, Boolean, Float))
)
)
@staticmethod @staticmethod
def regex_fullmatch(regex: String, string: String) -> Array: def regex_fullmatch(regex: String, string: String) -> Array:
@ -134,7 +136,8 @@ class RegexFunctions:
RegexFunctions.regex_capture_groups(regex).value > len(default) for regex in regex_list RegexFunctions.regex_capture_groups(regex).value > len(default) for regex in regex_list
): ):
raise RuntimeException( raise RuntimeException(
"When using %regex_capture_array, number of regex capture groups must be less than or equal to the number of defaults" "When using %regex_capture_array, number of regex capture groups must be less than "
"or equal to the number of defaults"
) )
output = Array([]) output = Array([])

View file

@ -80,6 +80,8 @@ class ScriptingFunctionsDocGen(DocGen):
level=2, level=2,
) )
except Exception as exc: except Exception as exc:
raise ValueError(f"Invalid docs for function {display_function_name}") from exc raise ValueError(
f"Invalid docs for function {display_function_name}"
) from exc
return docs return docs