def status_before_must_be(*valid_start_statuses):
 def decorator_func(func):
  '\n        Decorator function that gets returned\n        '
  @functools.wraps(func)
  def with_status_check(obj, *args, **kwargs):
   if (obj.status not in valid_start_statuses):
    exception_msg = u"Error calling {} {}: status is '{}', must be one of: {}".format(func, obj, obj.status, valid_start_statuses)
    raise VerificationException(exception_msg)
   return func(obj, *args, **kwargs)
  return with_status_check
 return decorator_func

def status_before_must_be ( * valid_start_statuses ) : def decorator_func ( func ) : @ functools . wraps ( func ) def with_status_check ( obj , * args , ** kwargs ) : if ( obj . status not in valid_start_statuses ) : exception_msg = u"Error calling {} {}: status is '{}', must be one of: {}" . format ( func , obj , obj . status , valid_start_statuses ) raise VerificationException ( exception_msg ) return func ( obj , * args , ** kwargs ) return with_status_check return decorator_func
helper decorator with arguments to make sure that an object with a status attribute is in one of a list of acceptable status states before a method is called .