From f467320ce7c8d9ccc30f161aa2fc8978541fae92 Mon Sep 17 00:00:00 2001 From: H2Sxxa Date: Sun, 12 May 2024 10:59:37 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20rename?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/saleyo/operation/hook.py | 12 +++++++----- src/saleyo/operation/intercept.py | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/saleyo/operation/hook.py b/src/saleyo/operation/hook.py index 6e12ce4..1be0f09 100644 --- a/src/saleyo/operation/hook.py +++ b/src/saleyo/operation/hook.py @@ -38,10 +38,12 @@ def mixin(self, target: M, toolchain: ToolChain = ToolChain()) -> None: target_name = ( self.target_name if self.target_name is not None else self.argument.__name__ ) - native_function: Callable[..., T] = toolchain.tool_getattr(target, target_name) + original_function: Callable[..., T] = toolchain.tool_getattr( + target, target_name + ) def post(*args, **kwargs) -> Union[T, RT]: - result = native_function(*args, **kwargs) + result = original_function(*args, **kwargs) post_result = self.argument(result) if post_result is not None: return post_result @@ -83,12 +85,12 @@ def mixin(self, target: M, toolchain: ToolChain = ToolChain()) -> None: target_name = ( self.target_name if self.target_name is not None else self.argument.__name__ ) - native_function = toolchain.tool_getattr(target, target_name) + original_function = toolchain.tool_getattr(target, target_name) def pre(*args: P.args, **kwargs: P.kwargs) -> Any: arguments = self.argument(*args, **kwargs) if arguments is not None: - return native_function(*arguments.args, **arguments.kwargs) - return native_function(*args, **kwargs) + return original_function(*arguments.args, **arguments.kwargs) + return original_function(*args, **kwargs) return toolchain.tool_setattr(target, target_name, pre) diff --git a/src/saleyo/operation/intercept.py b/src/saleyo/operation/intercept.py index d5ee19c..fd4305c 100644 --- a/src/saleyo/operation/intercept.py +++ b/src/saleyo/operation/intercept.py @@ -14,7 +14,7 @@ class Intercept(Generic[_PA, _PB], MixinOperation[Callable[[_A[_PA]], _B[_PB]]]) """ The `Intercept` allow you to intercept the arguments before invoking target method. - Then, you can handle these arguments in your own function and make a redirect to another function. + Then, you can handle thefse arguments in your own function and make a redirect to another function. If you just want to modify the arguments or the result, please see `Pre` and `Post`. """ @@ -50,7 +50,7 @@ def mixin( self.target_name if self.target_name is not None else self.argument.__name__ ) - native_function = toolchain.tool_getattr( + original_function = toolchain.tool_getattr( target, target_name, ) @@ -59,6 +59,6 @@ def mixin( target, target_name, lambda *args, **kwargs: self.argument( - InvokeEvent(native_function, *args, **kwargs) + InvokeEvent(original_function, *args, **kwargs) ).invoke_target(), )