def _method_magic_marker(magic_kind):
 validate_type(magic_kind)
 def magic_deco(arg):
  call = (lambda f, *a, **k: f(*a, **k))
  if callable(arg):
   func = arg
   name = func.__name__
   retval = decorator(call, func)
   record_magic(magics, magic_kind, name, name)
  elif isinstance(arg, str):
   name = arg
   def mark(func, *a, **kw):
    record_magic(magics, magic_kind, name, func.__name__)
    return decorator(call, func)
   retval = mark
  else:
   raise TypeError('Decorator can only be called with string or function')
  return retval
 magic_deco.__doc__ = _docstring_template.format('method', magic_kind)
 return magic_deco

def _method_magic_marker ( magic_kind ) : validate_type ( magic_kind ) def magic_deco ( arg ) : call = ( lambda f , * a , ** k : f ( * a , ** k ) ) if callable ( arg ) : func = arg name = func . __name__ retval = decorator ( call , func ) record_magic ( magics , magic_kind , name , name ) elif isinstance ( arg , str ) : name = arg def mark ( func , * a , ** kw ) : record_magic ( magics , magic_kind , name , func . __name__ ) return decorator ( call , func ) retval = mark else : raise TypeError ( 'Decorator can only be called with string or function' ) return retval magic_deco . __doc__ = _docstring_template . format ( 'method' , magic_kind ) return magic_deco
decorator factory for methods in magics subclasses .