Source code for cryptoolz.base
import abc
from typing import Any, List, Callable, Optional
from pydantic import BaseModel
[docs]class Super:
[docs] @staticmethod
def PreCall(func):
def PrecallsSuper(self, *args, **kwargs):
getattr(super(type(self), self), func.__name__)(*args, **kwargs)
return func(self, *args, **kwargs)
return PrecallsSuper
[docs]class AdHoc:
[docs] @staticmethod
def ListMorph(index) -> Callable[..., Any]:
def Decorator(func) -> Callable[..., Any]:
def Morphed(self, *args, **kwargs) -> Any:
results: List[Any] = []
if isinstance(args[index], list):
for val in args[index]:
results.append(
func(
self, *args[0:index], val, *args[index + 1 :], **kwargs
)
)
return results
else:
return func(self, *args, **kwargs)
return Morphed
return Decorator