hack-house/.venv/lib/python3.12/site-packages/sanic/touchup/schemes/base.py
leetcrypt bb1d662ee1 chore: rename project coven → hack-house ⛧
Rebrand the Rust client crate (coven/ → hh/, package+binary "hack-house"),
README, CLI strings, and branch (coven → hack-house). Gitea repo renamed
cmd-chat → hack-house to match. Crypto/server logic unchanged; selftest +
golden-vector test still green, binary is now `hack-house`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-30 13:29:14 -07:00

38 lines
992 B
Python

from abc import ABC, abstractmethod
from ast import NodeTransformer, parse
from inspect import getsource
from textwrap import dedent
from typing import Any
class BaseScheme(ABC):
ident: str
_registry: set[type] = set()
def __init__(self, app) -> None:
self.app = app
@abstractmethod
def visitors(self) -> list[NodeTransformer]: ...
def __init_subclass__(cls):
BaseScheme._registry.add(cls)
def __call__(self):
return self.visitors()
@classmethod
def build(cls, method, module_globals, app):
raw_source = getsource(method)
src = dedent(raw_source)
node = parse(src)
for scheme in cls._registry:
for visitor in scheme(app)():
node = visitor.visit(node)
compiled_src = compile(node, method.__name__, "exec")
exec_locals: dict[str, Any] = {}
exec(compiled_src, module_globals, exec_locals) # nosec
return exec_locals[method.__name__]