##// END OF EJS Templates
extensions: set attributes to wrappers so we can trace them back...
Jun Wu -
r29763:ce6317dc default
parent child Browse files
Show More
@@ -210,11 +210,13 b' def bind(func, *args):'
210 return func(*(args + a), **kw)
210 return func(*(args + a), **kw)
211 return closure
211 return closure
212
212
213 def _updatewrapper(wrap, origfn):
213 def _updatewrapper(wrap, origfn, unboundwrapper):
214 '''Copy attributes to wrapper function'''
214 '''Copy and add some useful attributes to wrapper'''
215 wrap.__module__ = getattr(origfn, '__module__')
215 wrap.__module__ = getattr(origfn, '__module__')
216 wrap.__doc__ = getattr(origfn, '__doc__')
216 wrap.__doc__ = getattr(origfn, '__doc__')
217 wrap.__dict__.update(getattr(origfn, '__dict__', {}))
217 wrap.__dict__.update(getattr(origfn, '__dict__', {}))
218 wrap._origfunc = origfn
219 wrap._unboundwrapper = unboundwrapper
218
220
219 def wrapcommand(table, command, wrapper, synopsis=None, docstring=None):
221 def wrapcommand(table, command, wrapper, synopsis=None, docstring=None):
220 '''Wrap the command named `command' in table
222 '''Wrap the command named `command' in table
@@ -254,7 +256,7 b' def wrapcommand(table, command, wrapper,'
254
256
255 origfn = entry[0]
257 origfn = entry[0]
256 wrap = bind(util.checksignature(wrapper), util.checksignature(origfn))
258 wrap = bind(util.checksignature(wrapper), util.checksignature(origfn))
257 _updatewrapper(wrap, origfn)
259 _updatewrapper(wrap, origfn, wrapper)
258 if docstring is not None:
260 if docstring is not None:
259 wrap.__doc__ += docstring
261 wrap.__doc__ += docstring
260
262
@@ -303,7 +305,7 b' def wrapfunction(container, funcname, wr'
303 origfn = getattr(container, funcname)
305 origfn = getattr(container, funcname)
304 assert callable(origfn)
306 assert callable(origfn)
305 wrap = bind(wrapper, origfn)
307 wrap = bind(wrapper, origfn)
306 _updatewrapper(wrap, origfn)
308 _updatewrapper(wrap, origfn, wrapper)
307 setattr(container, funcname, wrap)
309 setattr(container, funcname, wrap)
308 return origfn
310 return origfn
309
311
General Comments 0
You need to be logged in to leave comments. Login now