def collect_profile_func(file_prefix, enabled=False):
 import functools
 def _outer(func):
  '\n        Outer function decorator.\n        '
  @functools.wraps(func)
  def _inner(self, *args, **kwargs):
   '\n            Inner wrapper function.\n            '
   if enabled:
    with collect_profile(file_prefix):
     return func(self, *args, **kwargs)
   else:
    return func(self, *args, **kwargs)
  return _inner
 return _outer

def collect_profile_func ( file_prefix , enabled = False ) : import functools def _outer ( func ) : @ functools . wraps ( func ) def _inner ( self , * args , ** kwargs ) : if enabled : with collect_profile ( file_prefix ) : return func ( self , * args , ** kwargs ) else : return func ( self , * args , ** kwargs ) return _inner return _outer
method decorator for collecting profile .