util
Various utilities.
cache_result(func)
Cache result of function to recall on reuse.
A better version of the stateful lambda decorator. (@lambda : ())
Uses a generated class w/ unique name to store state, modifying the generated class defintion so state persists.
Returns:
| Type | Description |
|---|---|
Callable | Result on first use, cached state on second. |
Source code in client/ayon_comfyui/api/util.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
demangle_method(cls_or_instance, function_name, *, use_mro=False)
Return function object by name, demangled.
Evil way to grab a method preceded by 2 underscores.
Example:
class A:
def __func(self, arg):
...
class A_A(A):
def func(self, arg):
return demangle_method(self,"__func")(self, arg)
Source code in client/ayon_comfyui/api/util.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
extract_default_kwargs(func)
Returns a dict with default arguments to a function.
Source code in client/ayon_comfyui/api/util.py
82 83 84 85 86 87 88 89 90 91 | |
syncify(coro)
Transform async function into a synchronous function.
Returns:
| Type | Description |
|---|---|
Callable | Blocking version of async function. |
Source code in client/ayon_comfyui/api/util.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |