def raise_if_offline(func):
 @functools.wraps(func)
 def decorator(*args, **kwargs):
  if context.is_offline_mode():
   raise RuntimeError((_('%s cannot be called while in offline mode') % func.__name__))
  return func(*args, **kwargs)
 return decorator

def raise_if_offline ( func ) : @ functools . wraps ( func ) def decorator ( * args , ** kwargs ) : if context . is_offline_mode ( ) : raise RuntimeError ( ( _ ( '%s cannot be called while in offline mode' ) % func . __name__ ) ) return func ( * args , ** kwargs ) return decorator
decorator for raising if a function is called in offline mode .