def strip_boolean_result(method, exc_type=None, exc_str=None, fail_ret=None):
 @wraps(method)
 def wrapped(*args, **kwargs):
  ret = method(*args, **kwargs)
  if ret[0]:
   if (len(ret) == 2):
    return ret[1]
   else:
    return ret[1:]
  else:
   if exc_type:
    raise exc_type((exc_str or 'call failed'))
   return fail_ret
 return wrapped

def strip_boolean_result ( method , exc_type = None , exc_str = None , fail_ret = None ) : @ wraps ( method ) def wrapped ( * args , ** kwargs ) : ret = method ( * args , ** kwargs ) if ret [ 0 ] : if ( len ( ret ) == 2 ) : return ret [ 1 ] else : return ret [ 1 : ] else : if exc_type : raise exc_type ( ( exc_str or 'call failed' ) ) return fail_ret return wrapped
translate methods return value for stripping off success flag .