/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: 2017-05-22 00:56:52 UTC
  • mfrom: (6621.2.26 py3_pokes)
  • Revision ID: jelmer@jelmer.uk-20170522005652-yjahcr9hwmjkno7n
Merge Python3 porting work ('py3 pokes')

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from __future__ import absolute_import
20
20
 
21
 
from breezy import (
 
21
from . import (
22
22
    registry,
23
23
    symbol_versioning,
24
24
    )
25
 
from breezy.lazy_import import lazy_import
 
25
from .lazy_import import lazy_import
26
26
lazy_import(globals(), """
27
27
import textwrap
28
28
 
57
57
        for key in self.keys():
58
58
            yield key, self.key_to_parent_and_attribute(key)
59
59
 
60
 
    def key_to_parent_and_attribute(self, (module_name, member_name)):
 
60
    def key_to_parent_and_attribute(self, key):
61
61
        """Convert a known_hooks key to a (parent_obj, attr) pair.
62
62
 
63
63
        :param key: A tuple (module_name, member_name) as found in the keys of
65
65
        :return: The parent_object of the hook and the name of the attribute on
66
66
            that parent object where the hook is kept.
67
67
        """
68
 
        parent_mod, parent_member, attr = pyutils.calc_parent_name(module_name,
69
 
            member_name)
 
68
        parent_mod, parent_member, attr = pyutils.calc_parent_name(*key)
70
69
        return pyutils.get_named_object(parent_mod, parent_member), attr
71
70
 
72
71
 
96
95
del _builtin_known_hooks, _hook_module, _hook_attribute, _hook_class
97
96
 
98
97
 
99
 
def known_hooks_key_to_object((module_name, member_name)):
 
98
def known_hooks_key_to_object(key):
100
99
    """Convert a known_hooks key to a object.
101
100
 
102
101
    :param key: A tuple (module_name, member_name) as found in the keys of
103
102
        the known_hooks registry.
104
103
    :return: The object this specifies.
105
104
    """
106
 
    return pyutils.get_named_object(module_name, member_name)
 
105
    return pyutils.get_named_object(*key)
107
106
 
108
107
 
109
108
class Hooks(dict):
321
320
        return '\n'.join(strings)
322
321
 
323
322
    def __eq__(self, other):
324
 
        return (type(other) == type(self) and other.__dict__ == self.__dict__)
 
323
        return (isinstance(other, type(self)) and other.__dict__ == self.__dict__)
325
324
 
326
325
    def hook_lazy(self, callback_module, callback_member, callback_label):
327
326
        """Lazily register a callback to be called when this HookPoint fires.