##// 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 195 return func(*(args + a), **kw)
196 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 203 def wrapcommand(table, command, wrapper, synopsis=None, docstring=None):
199 204 '''Wrap the command named `command' in table
200 205
@@ -233,13 +238,9 b' def wrapcommand(table, command, wrapper,'
233 238
234 239 origfn = entry[0]
235 240 wrap = bind(util.checksignature(wrapper), util.checksignature(origfn))
236
237 wrap.__module__ = getattr(origfn, '__module__')
238
239 doc = getattr(origfn, '__doc__')
241 _updatewrapper(wrap, origfn)
240 242 if docstring is not None:
241 doc += docstring
242 wrap.__doc__ = doc
243 wrap.__doc__ += docstring
243 244
244 245 newentry = list(entry)
245 246 newentry[0] = wrap
General Comments 0
You need to be logged in to leave comments. Login now