/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: Robert Collins
  • Date: 2009-03-10 03:05:21 UTC
  • mto: This revision was merged to the branch mainline in revision 4104.
  • Revision ID: robertc@robertcollins.net-20090310030521-1ew21nsm0ktgcv26
Review feedback.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
        """Create a hook which can have callbacks registered for it.
44
44
 
45
45
        :param hook: The hook to create. An object meeting the protocol of
46
 
            bzrlib.hooks.Hook. It's name is used as the key for future
 
46
            bzrlib.hooks.HookPoint. It's name is used as the key for future
47
47
            lookups.
48
48
        """
49
49
        if hook.name in self:
122
122
        self._callable_names[a_callable] = name
123
123
 
124
124
 
125
 
class Hook(object):
 
125
class HookPoint(object):
126
126
    """A single hook that clients can register to be called back when it fires.
127
127
 
128
128
    :ivar name: The name of the hook.
136
136
    """
137
137
 
138
138
    def __init__(self, name, doc, introduced, deprecated):
139
 
        """Create a Hook.
 
139
        """Create a HookPoint.
140
140
        
141
141
        :param name: The name of the hook, for clients to use when registering.
142
142
        :param doc: The docs for the hook.
152
152
        self._callback_names = {}
153
153
 
154
154
    def docs(self):
155
 
        """Generate the documentation for this Hook.
 
155
        """Generate the documentation for this HookPoint.
156
156
        
157
157
        :return: A string terminated in \n.
158
158
        """
176
176
        return '\n'.join(strings)
177
177
 
178
178
    def hook(self, callback, callback_label):
179
 
        """Call this hook with callback, using callback_label to describe it.
 
179
        """Register a callback to be called when this HookPoint fires.
180
180
 
181
 
        :param callback: The callable to use when this Hook fires.
 
181
        :param callback: The callable to use when this HookPoint fires.
182
182
        :param callback_label: A label to show in the UI while this callback is
183
183
            processing.
184
184
        """
190
190
 
191
191
    def __repr__(self):
192
192
        strings = []
193
 
        strings.append("<bzrlib.hooks.Hook(")
 
193
        strings.append("<%s(" % type(self).__name__)
194
194
        strings.append(self.name)
195
195
        strings.append("), callbacks=[")
196
196
        for callback in self._callbacks: