/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 breezy/hooks.py

  • Committer: Jelmer Vernooij
  • Date: 2018-02-18 21:42:57 UTC
  • mto: This revision was merged to the branch mainline in revision 6859.
  • Revision ID: jelmer@jelmer.uk-20180218214257-jpevutp1wa30tz3v
Update TODO to reference Breezy, not Bazaar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Support for plugin hooking logic."""
18
18
 
 
19
from __future__ import absolute_import
 
20
 
19
21
from . import (
20
22
    errors,
21
23
    registry,
49
51
    # callable to get the empty specific Hooks for that attribute
50
52
 
51
53
    def register_lazy_hook(self, hook_module_name, hook_member_name,
52
 
                           hook_factory_member_name):
 
54
            hook_factory_member_name):
53
55
        self.register_lazy((hook_module_name, hook_member_name),
54
 
                           hook_module_name, hook_factory_member_name)
 
56
            hook_module_name, hook_factory_member_name)
55
57
 
56
58
    def iter_parent_objects(self):
57
59
        """Yield (hook_key, (parent_object, attr)) tuples for every registered
162
164
        hook_docs = []
163
165
        name = self.__class__.__name__
164
166
        hook_docs.append(name)
165
 
        hook_docs.append("-" * len(name))
 
167
        hook_docs.append("-"*len(name))
166
168
        hook_docs.append("")
167
169
        for hook_name in hook_names:
168
170
            hook = self[hook_name]
175
177
                strings.append("~" * len(hook_name))
176
178
                strings.append("")
177
179
                strings.append("An old-style hook. For documentation see the __init__ "
178
 
                               "method of '%s'\n" % (name,))
 
180
                    "method of '%s'\n" % (name,))
179
181
                hook_docs.extend(strings)
180
182
        return "\n".join(hook_docs)
181
183
 
196
198
            return 'No hook name'
197
199
        return name
198
200
 
 
201
 
199
202
    def install_named_hook_lazy(self, hook_name, callable_module,
200
 
                                callable_member, name):
 
203
        callable_member, name):
201
204
        """Install a_callable in to the hook hook_name lazily, and label it.
202
205
 
203
206
        :param hook_name: A hook name. See the __init__ method for the complete
216
219
            hook_lazy = getattr(hook, "hook_lazy")
217
220
        except AttributeError:
218
221
            raise errors.UnsupportedOperation(self.install_named_hook_lazy,
219
 
                                              self)
 
222
                self)
220
223
        else:
221
224
            hook_lazy(callable_module, callable_member, name)
222
225
        if name is not None:
267
270
        self._callable_names[a_callable] = name
268
271
 
269
272
    def name_hook_lazy(self, callable_module, callable_member, callable_name):
270
 
        self._lazy_callable_names[(callable_module, callable_member)] = \
 
273
        self._lazy_callable_names[(callable_module, callable_member)]= \
271
274
            callable_name
272
275
 
273
276
 
309
312
        """
310
313
        strings = []
311
314
        strings.append(self.name)
312
 
        strings.append('~' * len(self.name))
 
315
        strings.append('~'*len(self.name))
313
316
        strings.append('')
314
317
        if self.introduced:
315
318
            introduced_string = _format_version_tuple(self.introduced)
321
324
            strings.append(gettext('Deprecated in: %s') % deprecated_string)
322
325
        strings.append('')
323
326
        strings.extend(textwrap.wrap(self.__doc__,
324
 
                                     break_long_words=False))
 
327
            break_long_words=False))
325
328
        strings.append('')
326
329
        return '\n'.join(strings)
327
330
 
338
341
            processing.
339
342
        """
340
343
        obj_getter = registry._LazyObjectGetter(callback_module,
341
 
                                                callback_member)
 
344
            callback_member)
342
345
        self._callbacks.append((obj_getter, callback_label))
343
346
 
344
347
    def hook(self, callback, callback_label):
390
393
 
391
394
 
392
395
_help_prefix = \
393
 
    """
 
396
"""
394
397
Hooks
395
398
=====
396
399
 
422
425
 
423
426
"""
424
427
 
425
 
 
426
428
def hooks_help_text(topic):
427
429
    segments = [_help_prefix]
428
430
    for hook_key in sorted(known_hooks.keys()):
437
439
 
438
440
 
439
441
def install_lazy_named_hook(hookpoints_module, hookpoints_name, hook_name,
440
 
                            a_callable, name):
 
442
    a_callable, name):
441
443
    """Install a callable in to a hook lazily, and label it name.
442
444
 
443
445
    :param hookpoints_module: Module name of the hook points.