@decorator
def verbose(function, *args, **kwargs):
 arg_names = _get_args(function)
 default_level = verbose_level = None
 if ((len(arg_names) > 0) and (arg_names[0] == 'self')):
  default_level = getattr(args[0], 'verbose', None)
 if ('verbose' in arg_names):
  verbose_level = args[arg_names.index('verbose')]
 elif ('verbose' in kwargs):
  verbose_level = kwargs.pop('verbose')
 verbose_level = (default_level if (verbose_level is None) else verbose_level)
 if (verbose_level is not None):
  with use_log_level(verbose_level):
   return function(*args, **kwargs)
 return function(*args, **kwargs)

@ decorator def verbose ( function , * args , ** kwargs ) : arg_names = _get_args ( function ) default_level = verbose_level = None if ( ( len ( arg_names ) > 0 ) and ( arg_names [ 0 ] == 'self' ) ) : default_level = getattr ( args [ 0 ] , 'verbose' , None ) if ( 'verbose' in arg_names ) : verbose_level = args [ arg_names . index ( 'verbose' ) ] elif ( 'verbose' in kwargs ) : verbose_level = kwargs . pop ( 'verbose' ) verbose_level = ( default_level if ( verbose_level is None ) else verbose_level ) if ( verbose_level is not None ) : with use_log_level ( verbose_level ) : return function ( * args , ** kwargs ) return function ( * args , ** kwargs )
verbose decorator to allow functions to override log-level .