def option_default(self, opt, optdict=None):
     """return the default value for an option"""
     if optdict is None:
         optdict = self.get_option_def(opt)
     default = optdict.get('default')
     if callable(default):
         default = default()
     return default
示例#2
0
 def option_default(self, opt, optdict=None):
     """return the default value for an option"""
     if optdict is None:
         optdict = self.get_option_def(opt)
     default = optdict.get('default')
     if callable(default):
         default = default()
     return default
示例#3
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
示例#4
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