Kaydet (Commit) 4fa7ea95 authored tarafından Batuhan Taşkaya's avatar Batuhan Taşkaya

remove default conditioning and working demo

üst 15b85f0b
......@@ -8,7 +8,6 @@ from functools import partial, reduce, wraps
from types import FunctionType
from typing import Any, Dict, Optional, Sequence, Union
DEFAULT_CONDITION = "PRE"
HOOK_SIGN = "__condition"
HOOK_SPEC = "hook_spec"
......@@ -88,9 +87,7 @@ class Hook:
def __init_subclass__(cls):
methods: Sequence[str] = getattr(cls, "methods", [])
callbacks: Sequence[callable] = getattr(cls, "callbacks", [])
if not hasattr(cls, HOOK_SIGN):
setattr(cls, HOOK_SIGN, [getattr(HookConditions, DEFAULT_CONDITION)])
setattr(cls, HOOK_SPEC, HookSpec(methods, callbacks))
super().__init_subclass__()
......
......@@ -18,7 +18,7 @@ class PreLoggingHook(Hook):
methods = ['add_task']
callbacks = [lambda result: print(result.args, result.kwargs)]
@Hook.post
@Hook.on_call
class PostLoggingHook(Hook):
methods = ['pop_task', 'get_tasks']
callbacks = [lambda result: print(result.result)]
......@@ -26,3 +26,5 @@ class PostLoggingHook(Hook):
tm_catlizor = Catlizor.hook(TaskManager, PreLoggingHook, PostLoggingHook)
tm = TaskManager()
tm.add_task("süt al", "markete git", "süt reyonuna ulaş")
tm.get_tasks("süt al")
tm.pop_task()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment