##// END OF EJS Templates
extensions: extract function that copies function attributes to wrapper...
Yuya Nishihara -
r28310:01dc11e7 default
parent child Browse files
Show More
@@ -195,6 +195,11 b' def bind(func, *args):'
195 return func(*(args + a), **kw)
195 return func(*(args + a), **kw)
196 return closure
196 return closure
197
197
198 def _updatewrapper(wrap, origfn):
199 '''Copy attributes to wrapper function'''
200 wrap.__module__ = getattr(origfn, '__module__')
201 wrap.__doc__ = getattr(origfn, '__doc__')
202
198 def wrapcommand(table, command, wrapper, synopsis=None, docstring=None):
203 def wrapcommand(table, command, wrapper, synopsis=None, docstring=None):
199 '''Wrap the command named `command' in table
204 '''Wrap the command named `command' in table
200
205
@@ -233,13 +238,9 b' def wrapcommand(table, command, wrapper,'
233
238
234 origfn = entry[0]
239 origfn = entry[0]
235 wrap = bind(util.checksignature(wrapper), util.checksignature(origfn))
240 wrap = bind(util.checksignature(wrapper), util.checksignature(origfn))
236
241 _updatewrapper(wrap, origfn)
237 wrap.__module__ = getattr(origfn, '__module__')
238
239 doc = getattr(origfn, '__doc__')
240 if docstring is not None:
242 if docstring is not None:
241 doc += docstring
243 wrap.__doc__ += docstring
242 wrap.__doc__ = doc
243
244
244 newentry = list(entry)
245 newentry = list(entry)
245 newentry[0] = wrap
246 newentry[0] = wrap
General Comments 0
You need to be logged in to leave comments. Login now