/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/hooks.py

  • Committer: Jelmer Vernooij
  • Date: 2011-01-20 20:30:14 UTC
  • mto: (5622.4.1 uninstall-hook)
  • mto: This revision was merged to the branch mainline in revision 5669.
  • Revision ID: jelmer@samba.org-20110120203014-sn88wcb24cpq0d4r
Some work on lazy hooks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
318
318
 
319
319
def hooks_help_text(topic):
320
320
    segments = [_help_prefix]
321
 
    for hook_key in sorted(known_hooks.keys()):
322
 
        hooks = known_hooks_key_to_object(hook_key)
 
321
    for (hook_module, hook_attribute, hook_class) in sorted(
 
322
        known_hooks.keys()):
 
323
        hooks = pyutils.get_named_object(hook_module, hook_attribute)
323
324
        segments.append(hooks.docs())
324
325
    return '\n'.join(segments)
 
326
 
 
327
 
 
328
_lazy_hooks = {}
 
329
 
 
330
 
 
331
def install_lazy_named_hook(hookpoints_module, hookpoints_name, hook_name,
 
332
    a_callable, name):
 
333
    """Install a callable in to a hook lazily, and label it name.
 
334
 
 
335
    :param hookpoints_module: Module name of the hook points.
 
336
    :param hookpoints_name: Name of the hook points.
 
337
    :param hook_name: A hook name.
 
338
    :param callable: a callable to call for the hook.
 
339
    :param name: A name to associate a_callable with, to show users what is
 
340
        running.
 
341
    """
 
342
    key = (hookpoints_module, hookpoints_name, hook_name)
 
343
    _lazy_hooks.setdefault(key, []).append((a_callable, name))