import sys import traceback from .parser import ParseResultBase from fer.ferutil import of, logger log = logger.get_logger() class InterceptorNotTrigerableSentinel(object): pass class InterceptorError(Exception): pass class Interceptor(object): CUSTOM_TRIGGERS = 0 def __init__(self): self.calls = {} # triggers >= 0 are reserved for the parser compiler # triggers < 0 are for instance users def register_trigger(self): self.CUSTOM_TRIGGERS -= 1 return self.CUSTOM_TRIGGERS def register(self, call_id, f, context=None): if call_id == InterceptorNotTrigerableSentinel:
def init(): env.vars.init() logger.init(env.vars.get(EV_LOGLEVEL)) modmain = sys.modules[__name__] setattr(modmain, "log", logger.get_logger()) env.vars.forall(lambda k, v: modmain.log.debug("{} = {}".format(k, repr(v))))