def make_step_decorator(context, instance, update_instance_progress, total_offset=0):
 step_info = dict(total=total_offset, current=0)
 def bump_progress():
  step_info['current'] += 1
  update_instance_progress(context, instance, step_info['current'], step_info['total'])
 def step_decorator(f):
  step_info['total'] += 1
  @functools.wraps(f)
  def inner(*args, **kwargs):
   rv = f(*args, **kwargs)
   bump_progress()
   return rv
  return inner
 return step_decorator

def make_step_decorator ( context , instance , update_instance_progress , total_offset = 0 ) : step_info = dict ( total = total_offset , current = 0 ) def bump_progress ( ) : step_info [ 'current' ] += 1 update_instance_progress ( context , instance , step_info [ 'current' ] , step_info [ 'total' ] ) def step_decorator ( f ) : step_info [ 'total' ] += 1 @ functools . wraps ( f ) def inner ( * args , ** kwargs ) : rv = f ( * args , ** kwargs ) bump_progress ( ) return rv return inner return step_decorator
factory to create a decorator that records instance progress as a series of discrete steps .