def _GetConfigFromKwargs(kwargs, convert_rpc=False,
                         config_class=datastore_rpc.Configuration):
  if not kwargs:
    return None


  rpc = kwargs.pop('rpc', None)
  if rpc is not None:
    if not isinstance(rpc, apiproxy_stub_map.UserRPC):
      raise datastore_errors.BadArgumentError(
        'rpc= argument should be None or a UserRPC instance')
    if 'config' in kwargs:
      raise datastore_errors.BadArgumentError(
          'Expected rpc= or config= argument but not both')
    if not convert_rpc:
      if kwargs:
        raise datastore_errors.BadArgumentError(
            'Unexpected keyword arguments: %s' % ', '.join(kwargs))
      return rpc


    read_policy = getattr(rpc, 'read_policy', None)
    kwargs['config'] = datastore_rpc.Configuration(
       deadline=rpc.deadline, read_policy=read_policy,
       config=_GetConnection().config)

  return config_class(**kwargs)
Get a Configuration object from the keyword arguments.
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/api/datastore.py/_GetConfigFromKwargs