home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.6)
-
- from __future__ import with_statement
- from peak.util.plugins import Hook
- import traceback
- __all__ = [
- 'register',
- 'reduce']
-
- def register(hook_identifier, cb, impl = None):
- return Hook(hook_identifier, impl).register(cb)
-
-
- def reduce(hook_identifier, arg, *args, **kwargs):
- raise_exceptions = kwargs.pop('raise_exceptions', False)
- impl = kwargs.pop('impl', None)
- for hook in Hook(hook_identifier, impl):
- if raise_exceptions:
- arg = hook(arg, *args, **kwargs)
- continue
-
- try:
- arg = hook(arg, *args, **kwargs)
- continue
- except Exception:
- traceback.print_exc()
- continue
-
-
-
- return arg
-
-
- def notify(hook_identifier, *a, **k):
- for res in each(hook_identifier, *a, **k):
- pass
-
-
-
- def each(hook_identifier, *a, **k):
- impl = k.pop('impl', None)
- for hook in Hook(hook_identifier, impl):
-
- try:
- yield hook(*a, **k)
- continue
- except Exception:
- traceback.print_exc()
- continue
-
-
-
-
-
- def first(hook_identifier, *a, **k):
- impls = k.pop('impls', [
- k.pop('impl', None)])
- raise_exceptions = k.pop('raise_hook_exceptions', False)
- for impl in impls:
- for hook in Hook(hook_identifier, impl = impl):
-
- try:
- v = hook(*a, **k)
- if v is not None:
- return v
- continue
- except Exception:
- if raise_exceptions:
- raise
- raise_exceptions
- traceback.print_exc()
- continue
-
-
-
-
-
- builtin_any = any
-
- def any(hook_identifier, *a, **k):
- return builtin_any(each(hook_identifier, *a, **k))
-
-