@@ -0,0 +1,1499 @@
+BEHAVIOR = %22behaviors%22%0A%0A%0Aclass LocalEventType(type):%0A  %0A  def __call__(cls, *args, **kwargs):%0A    missing = set(cls.subjects).difference(kwargs)%0A    if missing:%0A      raise Exception(%22%7B0%7D did not receive all subjects: %7B1%7D%22.format(cls, missing))%0A    instance = super().__call__(*args, **kwargs)%0A    subjects = %7Bk:v for (k, v) in kwargs.items() if k in cls.subjects%7D%0A    if any(hasattr(instance, s) for s in subjects):%0A      raise Exception(%22%7B0%7D initialized with attributes: %7B1%7D%22.format(cls, set(subjects)))%0A    instance.__dict__.update(subjects)%0A    for base in reversed(cls.mro()):%0A      if base is object: continue%0A      for name in cls.subjects:%0A        subject = subjects%5Bname%5D%0A        try:%0A          behaviors = getattr(subject, BEHAVIOR)%0A        except AttributeError: continue%0A        behavior = behaviors.get(base.__name__, None)%0A        if behavior:%0A          scripts = behavior.get(name, None)%0A          if scripts:%0A            for script in scripts:%0A              script(instance)%0A    for base in reversed(cls.mro()):%0A      instance.apply_rules(base)%0A    instance.finalize()%0A    for s in subjects:%0A      delattr(instance, s)%0A    return instance%0A%0A%0Aclass LocalEvent(metaclass=LocalEventType):%0A  subjects = %5B%22agent%22%5D%0A%0A  def finalize(self):%0A    pass%0A%0A  def apply_rules(self, cls):%0A    if %22rules%22 in cls.__dict__:%0A      for rule in cls.rules:%0A        rule(self)%0A%0A  @classmethod%0A  def add_rule(cls, rule):%0A    if %22rules%22 not in cls.__dict__:%0A      cls.rules = list()%0A    cls.rules.append(rule)%0A%0A

Create core.py