def with_tmpdir(f):
 @wraps(f)
 def wrapper(self, *args, **kwargs):
  tmp = tempfile.mkdtemp(prefix='f2b-temp')
  try:
   return f(self, tmp, *args, **kwargs)
  finally:
   shutil.rmtree(tmp)
 return wrapper

def with_tmpdir ( f ) : @ wraps ( f ) def wrapper ( self , * args , ** kwargs ) : tmp = tempfile . mkdtemp ( prefix = 'f2b-temp' ) try : return f ( self , tmp , * args , ** kwargs ) finally : shutil . rmtree ( tmp ) return wrapper
helper decorator to create a temporary directory directory gets removed after function returns .