def format_call(fun, data, initial_ret=None, expected_extra_kws=()):
 ret = (((initial_ret is not None) and initial_ret) or {})
 ret['args'] = []
 ret['kwargs'] = {}
 aspec = salt.utils.args.get_function_argspec(fun)
 arg_data = arg_lookup(fun, aspec)
 args = arg_data['args']
 kwargs = arg_data['kwargs']
 data = data.copy()
 missing_args = []
 for key in kwargs:
  try:
   kwargs[key] = data.pop(key)
  except KeyError:
   pass
 while args:
  arg = args.pop(0)
  try:
   ret['args'].append(data.pop(arg))
  except KeyError:
   missing_args.append(arg)
 if missing_args:
  used_args_count = (len(ret['args']) + len(args))
  args_count = (used_args_count + len(missing_args))
  raise SaltInvocationError('{0} takes at least {1} argument{2} ({3} given)'.format(fun.__name__, args_count, (((args_count > 1) and 's') or ''), used_args_count))
 ret['kwargs'].update(kwargs)
 if aspec.keywords:
  for (key, value) in six.iteritems(data):
   if (key in expected_extra_kws):
    continue
   ret['kwargs'][key] = value
  return ret
 extra = {}
 for (key, value) in six.iteritems(data):
  if (key in expected_extra_kws):
   continue
  extra[key] = copy.deepcopy(value)
 warn_until('Nitrogen', "It's time to start raising `SaltInvocationError` instead of returning warnings", _dont_call_warnings=True)
 if extra:
  if (len(extra) == 1):
   msg = "'{0[0]}' is an invalid keyword argument for '{1}'".format(list(extra.keys()), ret.get('full', '{0}.{1}'.format(fun.__module__, fun.__name__)))
  else:
   msg = "{0} and '{1}' are invalid keyword arguments for '{2}'".format(', '.join(["'{0}'".format(e) for e in extra][:(-1)]), list(extra.keys())[(-1)], ret.get('full', '{0}.{1}'.format(fun.__module__, fun.__name__)))
  ret.setdefault('warnings', []).append("{0}. If you were trying to pass additional data to be used in a template context, please populate 'context' with 'key: value' pairs. Your approach will work until Salt Nitrogen is out.{1}".format(msg, ('' if ('full' not in ret) else ' Please update your state files.')))
  ret.setdefault('context', {}).update(extra)
 return ret

def format_call ( fun , data , initial_ret = None , expected_extra_kws = ( ) ) : ret = ( ( ( initial_ret is not None ) and initial_ret ) or { } ) ret [ 'args' ] = [ ] ret [ 'kwargs' ] = { } aspec = salt . utils . args . get_function_argspec ( fun ) arg_data = arg_lookup ( fun , aspec ) args = arg_data [ 'args' ] kwargs = arg_data [ 'kwargs' ] data = data . copy ( ) missing_args = [ ] for key in kwargs : try : kwargs [ key ] = data . pop ( key ) except KeyError : pass while args : arg = args . pop ( 0 ) try : ret [ 'args' ] . append ( data . pop ( arg ) ) except KeyError : missing_args . append ( arg ) if missing_args : used_args_count = ( len ( ret [ 'args' ] ) + len ( args ) ) args_count = ( used_args_count + len ( missing_args ) ) raise SaltInvocationError ( '{0} takes at least {1} argument{2} ({3} given)' . format ( fun . __name__ , args_count , ( ( ( args_count > 1 ) and 's' ) or '' ) , used_args_count ) ) ret [ 'kwargs' ] . update ( kwargs ) if aspec . keywords : for ( key , value ) in six . iteritems ( data ) : if ( key in expected_extra_kws ) : continue ret [ 'kwargs' ] [ key ] = value return ret extra = { } for ( key , value ) in six . iteritems ( data ) : if ( key in expected_extra_kws ) : continue extra [ key ] = copy . deepcopy ( value ) warn_until ( 'Nitrogen' , "It's time to start raising `SaltInvocationError` instead of returning warnings" , _dont_call_warnings = True ) if extra : if ( len ( extra ) == 1 ) : msg = "'{0[0]}' is an invalid keyword argument for '{1}'" . format ( list ( extra . keys ( ) ) , ret . get ( 'full' , '{0}.{1}' . format ( fun . __module__ , fun . __name__ ) ) ) else : msg = "{0} and '{1}' are invalid keyword arguments for '{2}'" . format ( ', ' . join ( [ "'{0}'" . format ( e ) for e in extra ] [ : ( - 1 ) ] ) , list ( extra . keys ( ) ) [ ( - 1 ) ] , ret . get ( 'full' , '{0}.{1}' . format ( fun . __module__ , fun . __name__ ) ) ) ret . setdefault ( 'warnings' , [ ] ) . append ( "{0}. If you were trying to pass additional data to be used in a template context, please populate 'context' with 'key: value' pairs. Your approach will work until Salt Nitrogen is out.{1}" . format ( msg , ( '' if ( 'full' not in ret ) else ' Please update your state files.' ) ) ) ret . setdefault ( 'context' , { } ) . update ( extra ) return ret
returns a nicely formatted statement displaying the function call with the given arguments .