fix: 'Action' as regular Exception

This commit is contained in:
2026-05-08 11:41:12 +08:00
parent 6829750f01
commit 21982afd64
3 changed files with 10 additions and 11 deletions

View File

@@ -1,8 +1,8 @@
from abc import abstractmethod, ABCMeta
class Unavailable(BaseException): pass
class NotAllowed(BaseException): pass
class Unavailable(Exception): pass
class NotAllowed(Exception): pass
class Action(BaseException, metaclass=ABCMeta):
class Action(Exception, metaclass=ABCMeta):
def __init__(self, *args):
super().__init__(*args)
@@ -28,14 +28,13 @@ class ActionFlow:
if self.on[index]: raise Unavailable(name)
if self.on[index] is None: raise NotAllowed(name)
value = self.actions[index].prepare()
self.on[index] = bool(value)
self.on[index] = bool(self.actions[index].prepare())
def react(self):
for index in self.indices.values():
if (self.on[index]):
self.on[index] = False
self.actions[index].perform()
self.on[index] = None
self.on[index] = bool(self.actions[index].perform())
def index(self, action: type[Action]) -> int:
name = action.__name__

View File

@@ -52,4 +52,4 @@ const RemoteProceduralCall = {
window.LogRecord = LogRecord;
window.Rpc2 = RemoteProceduralCall;
main(...arguments); // entrypoint to user-defined (async) main stub of the script
main(...arguments); // user-defined code

View File

@@ -10,8 +10,7 @@ from selenium.webdriver.support.wait import WebDriverWait
from selenium.common.exceptions import StaleElementReferenceException, TimeoutException
driver: WebDriver|None = None
attempts, timeout, interval = int(), float(), float()
identity = ''.join(random.choices(string.ascii_uppercase + string.digits, k=8))
attempts, timeout, interval, identity = int(), float(), float(), None
def until(condition: typing.Callable[[WebDriver], bool], watch=True):
try:
@@ -70,7 +69,8 @@ def click(selector: str|WebElement, wait=True, condition=False):
except: break
def setup(a: WebDriver, b: int, c: float, d: float):
global driver, attempts, timeout, interval
global identity, driver, attempts, timeout, interval
identity = ''.join(random.choices(string.ascii_uppercase + string.digits, k=8))
driver = a
attempts = b
timeout = c