Example #1
0
 def decorator(func):
     try:
         name = methodname or func.__name__
     except AttributeError:
         raise AttributeError('%s has no __name__ attribute: '
                              'you should provide an explicit `methodname`'
                              % func)
     if callable(func) and sys.version_info < (3, 0):
         setattr(klass, name, method_type(func, None, klass))
     else:
         # likely a property
         # this is quite borderline but usage already in the wild ...
         setattr(klass, name, func)
     return func
Example #2
0
 def decorator(func):
     try:
         name = methodname or func.__name__
     except AttributeError:
         raise AttributeError(
             '%s has no __name__ attribute: '
             'you should provide an explicit `methodname`' % func)
     if callable(func) and sys.version_info < (3, 0):
         setattr(klass, name, method_type(func, None, klass))
     else:
         # likely a property
         # this is quite borderline but usage already in the wild ...
         setattr(klass, name, func)
     return func
Example #3
0
 def __get__(self, instance, objtype):
     if instance is None:
         return method_type(self.func, objtype, objtype.__class__)
     return method_type(self.func, instance, objtype)
Example #4
0
 def __get__(self, instance, objtype):
     if instance is None:
         return method_type(self.func, objtype, objtype.__class__)
     return method_type(self.func, instance, objtype)